I am now trying to compile sqlitebrowser with Qt 4.7, during compilation run time I get his error:
g++ -c -pipe -O2 -Wall -W -DQT_NO_DEBUG -DQT_QT3SUPPORT_LIB -DQT3_SUPPORT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/share/qt4/mkspecs/freebsd-g++ -I. -I/usr/local/include/qt4/QtCore -I/usr/local/include/qt4/QtGui -I/usr/local/include/qt4/Qt3Support -I/usr/local/include/qt4 -Isqlite_source -I.moc -I/usr/local/include -o .obj/extendedmainform.o extendedmainform.cpp
In file included from findform.h:24,
from form1.h:31,
from extendedmainform.h:4,
from extendedmainform.cpp:1:
sqlitedb.h: In constructor 'DBBrowserField::DBBrowserField()':
sqlitedb.h:44: error: call of overloaded 'QString(int)' is ambiguous
/usr/local/include/qt4/QtCore/qstring.h:428: note: candidates are: QString::QString(const QByteArray&)
/usr/local/include/qt4/QtCore/qstring.h:426: note: QString::QString(const char*)
/usr/local/include/qt4/QtCore/qstring.h:728: note: QString::QString(const QString&)
/usr/local/include/qt4/QtCore/qstring.h:106: note: QString::QString(QChar)
/usr/local/include/qt4/QtCore/qstring.h:105: note: QString::QString(const QChar*)
sqlitedb.h: In constructor 'DBBrowserIndex::DBBrowserIndex()':
sqlitedb.h:58: error: call of overloaded 'QString(int)' is ambiguous
/usr/local/include/qt4/QtCore/qstring.h:428: note: candidates are: QString::QString(const QByteArray&)
/usr/local/include/qt4/QtCore/qstring.h:426: note: QString::QString(const char*)
/usr/local/include/qt4/QtCore/qstring.h:728: note: QString::QString(const QString&)
/usr/local/include/qt4/QtCore/qstring.h:106: note: QString::QString(QChar)
/usr/local/include/qt4/QtCore/qstring.h:105: note: QString::QString(const QChar*)
sqlitedb.h: In constructor 'DBBrowserTable::DBBrowserTable()':
sqlitedb.h:73: error: call of overloaded 'QString(int)' is ambiguous
/usr/local/include/qt4/QtCore/qstring.h:428: note: candidates are: QString::QString(const QByteArray&)
/usr/local/include/qt4/QtCore/qstring.h:426: note: QString::QString(const char*)
/usr/local/include/qt4/QtCore/qstring.h:728: note: QString::QString(const QString&)
/usr/local/include/qt4/QtCore/qstring.h:106: note: QString::QString(QChar)
/usr/local/include/qt4/QtCore/qstring.h:105: note: QString::QString(const QChar*)
*** Error code 1
I checked Qt documentation (both 4.6 and 4.7) to see any change in Qstring constructor, but I see only a new one overload, so my question what I need to change in sqlitebrowser in order to compile it.
According to QString in Qt 4.6, there is only one candidate that could take pointer as argument. But there are two QString constructors in Qt 4.7 that can take pointer as argument. I think this raised the compiler error.
You can force it to behave like Qt 4.6 as follows:
name((const char*) 0)
whereever you are creating a QString with an int - you need to tell Qt what you mean by an int
If it's an actual literal number you are converting to a string use the QString("%u").arg() function
Related
I'm trying to compile the boost example from http://www.boost.org/doc/libs/1_47_0/doc/html/boost_asio/example/ssl/client.cpp . For some reason I'm getting the following errors and I don't know how to fix them:
ssl_client.cpp:37:25: error: ‘boost::asio::ssl::verify_context’ has not been declared
ssl_client.cpp: In constructor ‘client::client(boost::asio::io_service&, boost::asio::ssl::context&, boost::asio::ip::basic_resolver<boost::asio::ip::tcp>::iterator)’:
ssl_client.cpp:27:13: error: ‘class boost::asio::ssl::stream<boost::asio::basic_stream_socket<boost::asio::ip::tcp> >’ has no member named ‘set_verify_mode’
ssl_client.cpp:27:29: error: ‘verify_peer’ is not a member of ‘boost::asio::ssl’
ssl_client.cpp:28:13: error: ‘class boost::asio::ssl::stream<boost::asio::basic_stream_socket<boost::asio::ip::tcp> >’ has no member named ‘set_verify_callback’
ssl_client.cpp:31:5: error: ‘async_connect’ is not a member of ‘boost::asio’
ssl_client.cpp: In member function ‘bool client::verify_certificate(bool, int&)’:
ssl_client.cpp:48:54: error: request for member ‘native_handle’ in ‘ctx’, which is of non-class type ‘int’
ssl_client.cpp: In function ‘int main(int, char**)’:
ssl_client.cpp:143:68: error: no matching function for call to ‘boost::asio::ssl::basic_context<boost::asio::ssl::context_service>::basic_context(boost::asio::ssl::context_base::method)’
ssl_client.cpp:143:68: note: candidates are:
/usr/include/boost/asio/ssl/basic_context.hpp:47:3: note: boost::asio::ssl::basic_context<Service>::basic_context(boost::asio::io_service&, boost::asio::ssl::context_base::method) [with Service = boost::asio::ssl::context_service]
/usr/include/boost/asio/ssl/basic_context.hpp:47:3: note: candidate expects 2 arguments, 1 provided
/usr/include/boost/asio/ssl/basic_context.hpp:35:7: note: boost::asio::ssl::basic_context<boost::asio::ssl::context_service>::basic_context(const boost::asio::ssl::basic_context<boost::asio::ssl::context_service>&)
/usr/include/boost/asio/ssl/basic_context.hpp:35:7: note: no known conversion for argument 1 from ‘boost::asio::ssl::context_base::method’ to ‘const boost::asio::ssl::basic_context<boost::asio::ssl::context_service>&’
I'm currently compiling with the following line:
g++ -I /usr/include/boost -Wall -o main ssl_client.cpp -lboost_system
And I recently installed boost through:
sudo apt-get install libboost-all-dev
I'm sure there's an easy fix, does anyone know what I'm doing wrong?
========================================================================
Update:
I've now tried compiling with:
g++ -I /usr/include/boost -Wall -o main ssl_client.cpp -lboost_system -lcrypto -lssl -lpthread
but I'm still getting the following errors:
ssl_client.cpp:37:25: error: ‘boost::asio::ssl::verify_context’ has not been declared
ssl_client.cpp: In constructor ‘client::client(boost::asio::io_service&, boost::asio::ssl::context&, boost::asio::ip::basic_resolver<boost::asio::ip::tcp>::iterator)’:
ssl_client.cpp:27:13: error: ‘class boost::asio::ssl::stream<boost::asio::basic_stream_socket<boost::asio::ip::tcp> >’ has no member named ‘set_verify_mode’
ssl_client.cpp:27:29: error: ‘verify_peer’ is not a member of ‘boost::asio::ssl’
ssl_client.cpp:28:13: error: ‘class boost::asio::ssl::stream<boost::asio::basic_stream_socket<boost::asio::ip::tcp> >’ has no member named ‘set_verify_callback’
ssl_client.cpp:31:5: error: ‘async_connect’ is not a member of ‘boost::asio’
ssl_client.cpp: In member function ‘bool client::verify_certificate(bool, int&)’:
ssl_client.cpp:48:54: error: request for member ‘native_handle’ in ‘ctx’, which is of non-class type ‘int’
ssl_client.cpp: In function ‘int main(int, char**)’:
ssl_client.cpp:143:68: error: no matching function for call to ‘boost::asio::ssl::basic_context<boost::asio::ssl::context_service>::basic_context(boost::asio::ssl::context_base::method)’
ssl_client.cpp:143:68: note: candidates are:
/usr/include/boost/asio/ssl/basic_context.hpp:47:3: note: boost::asio::ssl::basic_context<Service>::basic_context(boost::asio::io_service&, boost::asio::ssl::context_base::method) [with Service = boost::asio::ssl::context_service]
/usr/include/boost/asio/ssl/basic_context.hpp:47:3: note: candidate expects 2 arguments, 1 provided
/usr/include/boost/asio/ssl/basic_context.hpp:35:7: note: boost::asio::ssl::basic_context<boost::asio::ssl::context_service>::basic_context(const boost::asio::ssl::basic_context<boost::asio::ssl::context_service>&)
/usr/include/boost/asio/ssl/basic_context.hpp:35:7: note: no known conversion for argument 1 from ‘boost::asio::ssl::context_base::method’ to ‘const boost::asio::ssl::basic_context<boost::asio::ssl::context_service>&’
Fixed it! It was because apt-get was giving me boost version 1.46 and I needed version 1.48. I did the following to fix it:
apt-get purge libboost-all-dev
and
apt-get install libboost1.48-all-dev
Thanks to: http://spencernusbaum.me/blog.php#106
FatalMessageAssembler is a class which collects messages to an inner stringstream variable via << operator. It prints message of result variable and terminates application by += operator. (I have reasons not to put it in a function)
Header:
class FatalMessageAssembler
{
public:
FatalMessageAssembler();
std::stringstream contents;
void operator+=(FatalMessageAssembler& result);
};
template<typename msg_type> FatalMessageAssembler& operator<<(FatalMessageAssembler& target,const msg_type msg);
namespace NLog
{
extern FatalMessageAssembler assembler;
}
Source:
FatalMessageAssembler::FatalMessageAssembler()
{
}
FatalMessageAssembler NLog::assembler=FatalMessageAssembler();
template<typename msg_type> FatalMessageAssembler& operator<<(FatalMessageAssembler& target, const msg_type msg)
{
target.contents<<msg;
return target;
}
void FatalMessageAssembler::operator+=(FatalMessageAssembler& result)
{
qFatal(result.contents.str().c_str());
result.contents.str("");//I'm not sre if qFatal() can be handled not to terminate app
result.contents.clear();
}
This create an error std::ios_base::ios_base(const std::ios_base) is private. I didn't forget reference in return type.
Full log:
06:36:41: Running steps for project tsl...
06:36:41: Configuration unchanged, skipping qmake step.
06:36:41: Starting: "/usr/bin/make"
g++ -c -m64 -pipe -g -Wall -W -D_REENTRANT -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++-64 -I../tsl -I/usr/include/qt4/QtCore -I/usr/include/qt4 -I. -I../tsl -I. -o servicelogger.o ../tsl/servicelogger.cpp
In file included from /usr/include/c++/4.8/ios:42:0,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iterator:64,
from /usr/include/qt4/QtCore/qlist.h:50,
from /usr/include/qt4/QtCore/qobject.h:50,
from /usr/include/qt4/QtCore/QObject:1,
from ../tsl/servicelogger.h:5,
from ../tsl/servicelogger.cpp:2:
/usr/include/c++/4.8/bits/ios_base.h: In copy constructor 'std::basic_ios<char>::basic_ios(const std::basic_ios<char>&)':
/usr/include/c++/4.8/bits/ios_base.h:786:5: error: 'std::ios_base::ios_base(const std::ios_base&)' is private
ios_base(const ios_base&);
^
In file included from /usr/include/c++/4.8/ios:44:0,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iterator:64,
from /usr/include/qt4/QtCore/qlist.h:50,
from /usr/include/qt4/QtCore/qobject.h:50,
from /usr/include/qt4/QtCore/QObject:1,
from ../tsl/servicelogger.h:5,
from ../tsl/servicelogger.cpp:2:
/usr/include/c++/4.8/bits/basic_ios.h:66:11: error: within this context
class basic_ios : public ios_base
^
In file included from ../tsl/servicelogger.h:8:0,
from ../tsl/servicelogger.cpp:2:
/usr/include/c++/4.8/sstream: In copy constructor 'std::basic_stringstream<char>::basic_stringstream(const std::basic_stringstream<char>&)':
/usr/include/c++/4.8/sstream:502:11: note: synthesized method 'std::basic_ios<char>::basic_ios(const std::basic_ios<char>&)' first required here
class basic_stringstream : public basic_iostream<_CharT, _Traits>
^
In file included from /usr/include/c++/4.8/ios:43:0,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iterator:64,
from /usr/include/qt4/QtCore/qlist.h:50,
from /usr/include/qt4/QtCore/qobject.h:50,
from /usr/include/qt4/QtCore/QObject:1,
from ../tsl/servicelogger.h:5,
from ../tsl/servicelogger.cpp:2:
/usr/include/c++/4.8/streambuf: In copy constructor 'std::basic_stringbuf<char>::basic_stringbuf(const std::basic_stringbuf<char>&)':
/usr/include/c++/4.8/streambuf:802:7: error: 'std::basic_streambuf<_CharT, _Traits>::basic_streambuf(const std::basic_streambuf<_CharT, _Traits>&) [with _CharT = char; _Traits = std::char_traits<char>]' is private
basic_streambuf(const basic_streambuf& __sb)
^
In file included from ../tsl/servicelogger.h:8:0,
from ../tsl/servicelogger.cpp:2:
/usr/include/c++/4.8/sstream:64:11: error: within this context
class basic_stringbuf : public basic_streambuf<_CharT, _Traits>
^
/usr/include/c++/4.8/sstream: In copy constructor 'std::basic_stringstream<char>::basic_stringstream(const std::basic_stringstream<char>&)':
/usr/include/c++/4.8/sstream:502:11: note: synthesized method 'std::basic_stringbuf<char>::basic_stringbuf(const std::basic_stringbuf<char>&)' first required here
class basic_stringstream : public basic_iostream<_CharT, _Traits>
^
In file included from ../tsl/servicelogger.cpp:2:0:
../tsl/servicelogger.h: In copy constructor 'FatalMessageAssembler::FatalMessageAssembler(const FatalMessageAssembler&)':
../tsl/servicelogger.h:39:7: note: synthesized method 'std::basic_stringstream<char>::basic_stringstream(const std::basic_stringstream<char>&)' first required here
class FatalMessageAssembler
^
../tsl/servicelogger.cpp: At global scope:
../tsl/servicelogger.cpp:47:61: note: synthesized method 'FatalMessageAssembler::FatalMessageAssembler(const FatalMessageAssembler&)' first required here
FatalMessageAssembler NLog::assembler=FatalMessageAssembler();
^
../tsl/servicelogger.cpp: In member function 'void FatalMessageAssembler::operator+=(FatalMessageAssembler&)':
../tsl/servicelogger.cpp:55:41: warning: format not a string literal and no format arguments [-Wformat-security]
qFatal(result.contents.str().c_str());
^
make: *** [servicelogger.o] Error 1
06:36:46: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project tsl (kit: Desktop)
When executing step "Make"
06:36:46: Elapsed time: 00:05.
FatalMessageAssembler NLog::assembler=FatalMessageAssembler();
This is the crucial line that causes the error. You can't copy streams, and thus you can't copy FatalMessageAssemblers1. However, the initialization with a temporary is actually not needed.
FatalMessageAssembler NLog::assembler;
Should also initialize assembler appropriately.
1) The move constructor of your class isn't implicitly declared because stringstream, the type of one of the members, is not copyable.
I am currently working on a Oculus Rift project (DK1) on Ubuntu 14.04 and I try to compile a github projet.
This is a Qt project written in C++. I have the following error about "unique_ptr". I think have installed the right libraries. I know this code have already worked on a Ubuntu computer.
g++ -c -m64 -pipe -Ofast -Wno-deprecated -O2 -std=c++0x -Wall -W -fPIE -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -I. -o Camera.o Camera.cpp
In file included from Include/OVR/LibOVR/Include/../Src/OVR_Device.h:33:0,
from Include/OVR/LibOVR/Include/OVR.h:35,
from Oculus.h:13,
from Input.h:13,
from Camera.h:12,
from Camera.cpp:1:
Include/OVR/LibOVR/Include/../Src/OVR_DeviceMessages.h: In constructor ‘OVR::MessageCameraFrame::MessageCameraFrame(OVR::DeviceBase*)’:
Include/OVR/LibOVR/Include/../Src/OVR_DeviceMessages.h:255:13: warning: ‘OVR::MessageCameraFrame::CameraHandle’ will be initialized after [-Wreorder]
UInt32* CameraHandle; // Identifies the camera object associated with this frame
^
Include/OVR/LibOVR/Include/../Src/OVR_DeviceMessages.h:249:18: warning: ‘const UByte* OVR::MessageCameraFrame::pFrameData’ [-Wreorder]
const UByte* pFrameData; // a ptr to frame data.
^
Include/OVR/LibOVR/Include/../Src/OVR_DeviceMessages.h:226:5: warning: when initialized here [-Wreorder]
MessageCameraFrame(DeviceBase* dev)
^
Camera.cpp: In constructor ‘Camera::Camera(const vec3&, const vec3&, const vec3&, float, float, const Input&)’:
Camera.cpp:20:18: error: use of deleted function ‘Input::Input(const Input&)’
speed_ {speed}
^
In file included from Camera.h:12:0,
from Camera.cpp:1:
Input.h:33:7: note: ‘Input::Input(const Input&)’ is implicitly deleted because the default definition would be ill-formed:
class Input
^
Input.h:33:7: error: use of deleted function ‘std::unique_ptr<_Tp, _Dp>::unique_ptr(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = GenericOculus; _Dp = std::default_delete<GenericOculus>]’
In file included from /usr/include/c++/4.8/memory:81:0,
from LogCpp/Log.h:8,
from Oculus.h:23,
from Input.h:13,
from Camera.h:12,
from Camera.cpp:1:
/usr/include/c++/4.8/bits/unique_ptr.h:273:7: error: declared here
unique_ptr(const unique_ptr&) = delete;
^
Camera.cpp:20:18: warning: a temporary bound to ‘Camera::input_’ only persists until the constructor exits [-Wextra]
speed_ {speed}
^
make: *** [Camera.o] Erreur 1
Thank you
The problem here lies in this message:
Input.h:33:7: error: use of deleted function ‘std::unique_ptr<_Tp, _Dp>::unique_ptr(const std::unique_ptr<_Tp, _Dp>&)
You're apparently trying to construct a unique_ptr from another unique_ptr. That's forbidden, as unique_ptr can't be copied (that's the point of having a unique pointer). You can only move a unique_ptr to transfer ownership.
So you'll have to revise that code with this information in mind.
Note: As you apparently have a member unique_ptr in your class, and as its copy constructor is deleted (i.e. explicitely forbidden), thus the default copy constructor of your class is itself deleted, which explains the following error message in your stack:
Camera.cpp:20:18: error: use of deleted function ‘Input::Input(const Input&)
I'm trying to write a container class using C++ and templates. However, I'm having a compilation error I don't understand...
The variable elems is a private vector, declaration is:
private:
vector<DataType> elems;
The vector is a custom vector. Its constructor is:
vector::vector(int init_capacity) : vect_capacity(init_capacity), vect_size(0), vect_elems(NULL){
assert(init_capacity >= 0);
if (init_capacity > 0){
vect_elems = new Object[init_capacity];
}
}
The constructor can be seen below:
template <class DataType>
bag<DataType>::bag(int init_capacity) : elems(init_capacity) {
}
This code returns the following error:
../src/vector.h: In instantiation of ‘vector<DataType>::vector(int) [with DataType = int]’:
../src/bag.h:33:60: required from ‘bag<DataType>::bag(int) [with DataType = int]’
../src/bag_test.cpp:6:17: required from here
I honestly have no idea what could be possibly happening. Will be immensely grateful to anyone that can point me in the right direction...
Sorry for the very stupid question. It's true that the compiler does complain about this, but the code actually compiles. Thanks to #WhozCraig and #n.m who insisted that this wasn't an error, I noticed that it actually was building. Thanks! For future reference, I do post the whole message:
**** Build of configuration Debug for project ADS ****
make all
Building file: ../src/bag_test.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/bag_test.d" -MT"src/bag_test.d" -o "src/bag_test.o" "../src/bag_test.cpp"
In file included from ../src/bag_test.cpp:2:0:
../src/bag.h:23:66: warning: friend declaration ‘std::ostream& operator<<(std::ostream&, const bag<DataType>&)’ declares a non-template function [-Wnon-template-friend]
../src/bag.h:23:66: note: (if this is not what you intended, make sure the function template has already been declared and add <> after the function name here)
In file included from ../src/bag.h:2:0,
from ../src/bag_test.cpp:2:
../src/vector.h: In instantiation of ‘vector<DataType>::vector(int) [with DataType = int]’:
../src/bag.h:34:53: required from ‘bag<DataType>::bag(int) [with DataType = int]’
../src/bag_test.cpp:6:17: required from here
../src/vector.h:100:6: warning: ‘vector<int>::vect_capacity’ will be initialized after [-Wreorder]
../src/vector.h:99:6: warning: ‘int vector<int>::vect_size’ [-Wreorder]
../src/vector.h:108:1: warning: when initialized here [-Wreorder]
Finished building: ../src/bag_test.cpp
Building target: ADS
Invoking: GCC C++ Linker
g++ -o "ADS" ./src/bag_test.o
Finished building target: ADS
**** Build Finished ****
I'm trying to compile some code on one of our systems for our DBA...I've edited the makefiles to include the pertinent libraries listed in the documentation, but I keep getting these errors... Can you discern any obvious problems from my command lines in reference to the errors listed?
Thank you!
make -f /u01/app/banner/ban8/TEST3/links/Makefile_tm_linux64_redhat5_ban8.mk
gcc -m64 -D_NOFIXARGPTR -fpic -shared -DTMCILIB_EXPORTS -D_TMUNICODE
-I/usr/local/ban_icu -I/usr/local/src/icu/source/i18n/ -I/usr/local/src/icu/source/common/ -I/usr/local/src/icu/source/extra/ustdio/ -I/usr/local/src/icu/source/io -L/usr/lib64 -L/usr/lib -L/usr/local/src/icu/source/data/ -L/usr/local/src/icu/source/data/out/ -L/usr/local/src/icu/source/tools/toolutil/ -L/usr/lib/im/icuconv/ -L/usr/local/lib/ -L. -licui18n -licudata -licuuc -licu-toolutil -licuio
msgfmttm.cpp umsgtm.cpp tmcilib.cpp -o /u01/app/banner/ban8/TEST3/general/exe/libtmciuc.so
umsgtm.cpp: In function ‘void fixArgPtr(const UChar*, __va_list_tag (*)[1])’:
umsgtm.cpp:158: error: array must be initialized with a brace-enclosed initializer
umsgtm.cpp:194: error: ISO C++ forbids assignment of arrays
umsgtm.cpp: In function ‘int32_t tmumsg_vformat(void**, UChar*, int32_t, __va_list_tag*, UErrorCode*)’:
umsgtm.cpp:305: error: cannot convert ‘__va_list_tag**’ to ‘__va_list_tag ()[1]’ for argument ‘2’ to ‘void fixArgPtr(const UChar, __va_list_tag (*)[1])’
tmcilib.cpp: In function ‘int tmprintf(TMBundle*, const UChar*, ...)’:
tmcilib.cpp:743: error: array must be initialized with a brace-enclosed initializer
tmcilib.cpp: In function ‘int tmfprintf(TMBundle*, UFILE*, const UChar*, ...)’:
tmcilib.cpp:757: error: array must be initialized with a brace-enclosed initializer
tmcilib.cpp: In function ‘int tmsprintf(TMBundle*, UChar*, const UChar*, ...)’:
tmcilib.cpp:808: error: array must be initialized with a brace-enclosed initializer
Maybe that url => here will help you.