2014년 12월 4일 목요일

Compile driver c++ error in majaro openbox.

Hi, when i try compile the example tutotial file:


$ g++ tutorial.cpp -pthread -lmongoclient -lboost_thread-mt -lboost_system -lboost_regex -o tutorialIn file included from mongoTest.cpp:4:0:
mongo
-client-install/include/mongo/bson/bson.h:66:26: fatal error:mongo/config.h: No such file or directory
 
#include "mongo/config.h"
                          
^
compilation terminated
.



the file is:

#include <cstdlib>
#include <iostream>
#include "mongo-client-install/include/mongo/bson/bson.h"
#include "mongo-client-install/include/mongo/client/dbclient.h"
void run() {
    mongo
::DBClientConnection c;
    c
.connect("localhost");
}
int main() {
    mongo
::client::initialize();
    
try {
        run
();
        cout 
<< "Connect ok." << endl;
    
} catch (const mongo::DBException &e) {
        cout 
<< "Caught " << e.what() << endl;
    
}

    
return EXIT_SUCCESS;
}

the code to  build driver:

scons --prefix=$HOME/mongo-client-install --sharedclient install
the git clone repo is in the data partion in my HDD and i use legacy version.



You should include the bson.h and dbclient.h files as:
#include "mongo/bson/bson.h"
and
#include "mongo/client/dbclient.h"
You need to do this because those headers contain additional #include statements that expect that files like config.h can be found when prefixed with the exact string 'mongo/client' or 'mongo/bson'. You should edit your #include lines in the example above to remove 'mongo-client-install/include', and update your compiler invocation so that the header search path is $HOME/mongo-client-install/include.
Same error.
$ g++ mongTest.cpp -pthread -lmongoclient -lboost_thread-mt -lboost_system -lboost_regex -o mongTestIn file included from mongTest.cpp:4:0: include/mongo/bson/bson.h:66:26: fatal error: mongo/config.h: No such file or directory  #include "mongo/config.h"                           ^ compilation terminated.
i do not understand because of this error, compilation is on the path /home/user/mongo-client-install. Might you tell me another way to install the legacy version please'd like to try another way. thanks for your time and patience.
I don't see that you are specifying an include search path to g++. If you build the driver with --prefix=/path/to/install, you will end up with installed headers like /path/to/install/include/mongo/config.h. Your application should include files like #include "mongo/bson/bson.h" (e.g. no part of the prefix is present), and the g++ line to compile your application should have -I/path/to/install/include among the compile flags, and -L/path/to/install/lib -lmongoclient on the link line.
To help diagnose further, could you please reiterate:
- The exact SCons invocation used to build the driver
- The complete source file you are trying to compile against the driver
- The complete compiler invocation you are using to build your source file
hey andrew, I have another error with the library boost_thread-mt, this is the error: first.
$ g++ mongoTest.cpp -pthread -Imongo-client/include -Lmongo-client/lib -lboost_thread-mt -lboost_system -lboost_regex -o mongoTest/usr/bin/ld: cannot find -lboost_thread-mt collect2: error: ld returned 1 exit status
and i remove -mt:
$ g++ mongoTest.cpp -pthread -Imongo-client/include -Lmongo-client/lib -lboost_thread -lboost_system -lboost_regex -o mongoTest/usr/bin/ld: warning: libicuuc.so.54, needed by /usr/lib/gcc/i686-pc-linux-gnu/4.9.1/../../../libboost_regex.so, not found (try using -rpathor -rpath-link) /usr/bin/ld: warning: libicui18n.so.54, needed by /usr/lib/gcc/i686-pc-linux-gnu/4.9.1/../../../libboost_regex.so, not found (try using -rpathor -rpath-link) /usr/bin/ld: warning: libicudata.so.54, needed by /usr/lib/gcc/i686-pc-linux-gnu/4.9.1/../../../libboost_regex.so, not found (try using -rpathor -rpath-link) /tmp/ccdfhfRA.o: In function `main': mongoTest.cpp:(.text+0xf8): undefined reference to `mongo::client::Options::Options()' mongoTest.cpp:(.text+0x10b): undefined reference to `mongo::client::initialize(mongo::client::Options const&)' /tmp/ccdfhfRA.o: In function `mongo::DBException::DBException(std::string const&, int)': mongoTest.cpp:(.text._ZN5mongo11DBExceptionC2ERKSsi[_ZN5mongo11DBExceptionC5ERKSsi]+0x1b): undefined reference to `vtable formongo::DBException' /tmp/ccdfhfRA.o: In function `mongo::DBException::~DBException()': mongoTest.cpp:(.text._ZN5mongo11DBExceptionD2Ev[_ZN5mongo11DBExceptionD5Ev]+0xa): undefined reference to `vtable for mongo::DBException' /tmp/ccdfhfRA.o: In function `mongo::DBException::addContext(std::stringconst&)': mongoTest.cpp:(.text._ZN5mongo11DBException10addContextERKSs[_ZN5mongo11DBException10addContextERKSs]+0x16): undefined reference to `mongo::causedBy(std::string const&)' /tmp/ccdfhfRA.o: In function `mongo::UserException::UserException(int, std::string const&)': mongoTest.cpp:(.text._ZN5mongo13UserExceptionC2EiRKSs[_ZN5mongo13UserExceptionC5EiRKSs]+0x20): undefined reference to `vtablefor mongo::UserException' /tmp/ccdfhfRA.o: In function `mongo::UserException::~UserException()': mongoTest.cpp:(.text._ZN5mongo13UserExceptionD2Ev[_ZN5mongo13UserExceptionD5Ev]+0xb): undefined reference to `vtable for mongo::UserException' /tmp/ccdfhfRA.o: In function `mongo::DBClientConnection::DBClientConnection(bool, mongo::DBClientReplicaSet*, double)': mongoTest.cpp:(.text._ZN5mongo18DBClientConnectionC2EbPNS_18DBClientReplicaSetEd[_ZN5mongo18DBClientConnectionC5EbPNS_18DBClientReplicaSetEd]+0x21): undefined reference to `mongo::DBClientBase::DBClientBase()' mongoTest.cpp:(.text._ZN5mongo18DBClientConnectionC2EbPNS_18DBClientReplicaSetEd[_ZN5mongo18DBClientConnectionC5EbPNS_18DBClientReplicaSetEd]+0x2d): undefined reference to `vtable for mongo::DBClientConnection' mongoTest.cpp:(.text._ZN5mongo18DBClientConnectionC2EbPNS_18DBClientReplicaSetEd[_ZN5mongo18DBClientConnectionC5EbPNS_18DBClientReplicaSetEd]+0x37): undefined reference to `vtable formongo::DBClientConnection' mongoTest.cpp:(.text._ZN5mongo18DBClientConnectionC2EbPNS_18DBClientReplicaSetEd[_ZN5mongo18DBClientConnectionC5EbPNS_18DBClientReplicaSetEd]+0xa6): undefined reference to `mongo::HostAndPort::HostAndPort()' mongoTest.cpp:(.text._ZN5mongo18DBClientConnectionC2EbPNS_18DBClientReplicaSetEd[_ZN5mongo18DBClientConnectionC5EbPNS_18DBClientReplicaSetEd]+0xfb): undefined reference to`mongo::DBClientConnection::_numConnections' mongoTest.cpp:(.text._ZN5mongo18DBClientConnectionC2EbPNS_18DBClientReplicaSetEd[_ZN5mongo18DBClientConnectionC5EbPNS_18DBClientReplicaSetEd]+0x19a): undefined reference to `mongo::DBClientBase::~DBClientBase()' /tmp/ccdfhfRA.o: In function `mongo::DBClientConnection::~DBClientConnection()': mongoTest.cpp:(.text._ZN5mongo18DBClientConnectionD2Ev[_ZN5mongo18DBClientConnectionD5Ev]+0xc): undefined reference to `vtable for mongo::DBClientConnection' mongoTest.cpp:(.text._ZN5mongo18DBClientConnectionD2Ev[_ZN5mongo18DBClientConnectionD5Ev]+0x16): undefined reference to `vtablefor mongo::DBClientConnection' mongoTest.cpp:(.text._ZN5mongo18DBClientConnectionD2Ev[_ZN5mongo18DBClientConnectionD5Ev]+0x20): undefined reference to `mongo::DBClientConnection::_numConnections' mongoTest.cpp:(.text._ZN5mongo18DBClientConnectionD2Ev[_ZN5mongo18DBClientConnectionD5Ev]+0xa8): undefined reference to`mongo::DBClientBase::~DBClientBase()' mongoTest.cpp:(.text._ZN5mongo18DBClientConnectionD2Ev[_ZN5mongo18DBClientConnectionD5Ev]+0x165): undefined reference to `mongo::DBClientBase::~DBClientBase()' /tmp/ccdfhfRA.o: In function `mongo::DBClientConnection::connect(std::string const&)': mongoTest.cpp:(.text._ZN5mongo18DBClientConnection7connectERKSs[_ZN5mongo18DBClientConnection7connectERKSs]+0x41): undefined reference to`mongo::HostAndPort::HostAndPort(mongo::StringData const&)' /tmp/ccdfhfRA.o:(.gcc_except_table+0x48): undefined reference to `typeinfo for mongo::DBException' /tmp/ccdfhfRA.o:(.rodata._ZTVN5mongo16ConnectExceptionE[_ZTVN5mongo16ConnectExceptionE]+0x18): undefined reference to `mongo::UserException::appendPrefix(std::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >&) const' /tmp/ccdfhfRA.o:(.rodata._ZTVN5mongo16ConnectExceptionE[_ZTVN5mongo16ConnectExceptionE]+0x20): undefined reference to`mongo::DBException::toString() const' /tmp/ccdfhfRA.o:(.rodata._ZTVN5mongo18AssertionExceptionE[_ZTVN5mongo18AssertionExceptionE]+0x20): undefined reference to `mongo::DBException::toString() const' /tmp/ccdfhfRA.o:(.rodata._ZTIN5mongo16ConnectExceptionE[_ZTIN5mongo16ConnectExceptionE]+0x8): undefined reference to `typeinfo for mongo::UserException' /tmp/ccdfhfRA.o:(.rodata._ZTIN5mongo18AssertionExceptionE[_ZTIN5mongo18AssertionExceptionE]+0x8): undefined reference to `typeinfo for mongo::DBException' /usr/lib/gcc/i686-pc-linux-gnu/4.9.1/../../../libboost_regex.so: undefined reference to `u_tolower_54' /usr/lib/gcc/i686-pc-linux-gnu/4.9.1/../../../libboost_regex.so: undefined reference to `icu_54::Collator::createInstance(icu_54::Locale const&, UErrorCode&)' /usr/lib/gcc/i686-pc-linux-gnu/4.9.1/../../../libboost_regex.so:undefined reference to `u_digit_54' /usr/lib/gcc/i686-pc-linux-gnu/4.9.1/../../../libboost_regex.so: undefined reference to `u_isblank_54' /usr/lib/gcc/i686-pc-linux-gnu/4.9.1/../../../libboost_regex.so: undefined reference to `u_isspace_54' /usr/lib/gcc/i686-pc-linux-gnu/4.9.1/../../../libboost_regex.so:undefined reference to `icu_54::Locale::Locale()' /usr/lib/gcc/i686-pc-linux-gnu/4.9.1/../../../libboost_regex.so: undefined reference to `u_charType_54' /usr/lib/gcc/i686-pc-linux-gnu/4.9.1/../../../libboost_regex.so: undefined reference to `icu_54::Locale::Locale(icu_54::Locale const&)' /usr/lib/gcc/i686-pc-linux-gnu/4.9.1/../../../libboost_regex.so:undefined reference to `u_charFromName_54' /usr/lib/gcc/i686-pc-linux-gnu/4.9.1/../../../libboost_regex.so: undefined reference to `icu_54::Locale::~Locale()' collect2: error: ld returned 1 exit status
and this is boost and boost-libs informacion.
$ pacman -Qi boost boost-libsName           : boostVersion        : 1.57.0-2 Description    : Free peer-reviewed portable C++ source libraries -development headersArchitecture   : i686 URL            : http://www.boost.org/ Licenses       : customGroups         : None Provides       : None Depends On     : boost-libs=1.57.0 Optional Deps  : python: for python bindings [installed]                  python2: for python2 bindings [installed]                  boost-build: to use boost jam for building your project. Required By    : None Optional For   : None Conflicts With : None Replaces       : None Installed Size : 132440.00 KiB Packager       : Evangelos Foutras <evangelos@foutrelis.com> Build Date     : Thu 06 Nov 2014 03:55:04 AM ASTInstall Date   : Tue 02 Dec 2014 05:56:20 PM ASTInstall Reason : Installed as a dependency for another package Install Script : No Validated By   : Signature Name           : boost-libsVersion        : 1.57.0-2 Description    : Free peer-reviewed portable C++ source libraries -runtime librariesArchitecture   : i686 URL            : http://www.boost.org/ Licenses       : customGroups         : None Provides       : None Depends On     : bzip2  zlib  icuOptional Deps  : openmpi: for mpi supportRequired By    : blender  boost  clucene  libetonyek  librevenge  mongodb  openimageio  openshadinglanguage  source-highlightOptional For   : None Conflicts With : None Replaces       : None Installed Size : 10453.00 KiB Packager       : Evangelos Foutras <evangelos@foutrelis.com> Build Date     : Thu 06 Nov 2014 03:52:59 AM ASTInstall Date   : Tue 02 Dec 2014 05:56:14 PM ASTInstall Reason : Installed as a dependency for another package Install Script : No Validated By   : Signature
thanks for you help and patience.

댓글 없음:

댓글 쓰기