[CXX-737] #include "mongo/client/dbclient.h" give boost error Created: 09/Nov/15  Updated: 20/Nov/15  Resolved: 20/Nov/15

Status: Closed
Project: C++ Driver
Component/s: BSON, Build, Implementation, Testing
Affects Version/s: legacy-1.0.6
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Fransiskus Lukman Assignee: Andrew Morrow (Inactive)
Resolution: Incomplete Votes: 0
Labels: legacy-cxx
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Compile: g++ -Wall -std=c++11 -l boost_system -pthread -I mongo-client-install/include -L mongo-client-install/lib -l mongoclient -l boost_thread -l boost_regex main.cpp -o Lucy $(mysql_config --libs --cflags) 2>&1

/tmp/ccHC5mIq.o: In function `__static_initialization_and_destruction_0':
/usr/include/boost/system/error_code.hpp:222: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:223: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:224: undefined reference to `boost::system::system_category()'
collect2: error: ld returned 1 exit status

Anybody else getting message like the above? i came accross saying bosst haing a problem with ubuntu 14,04 is that true?



 Comments   
Comment by Andrew Morrow (Inactive) [ 20/Nov/15 ]

fransiskuslukman@gmail.com - I'm closing this since I've not heard back from you. If you are still having difficulty linking with the driver, please feel free to comment on the ticket and we can re-open it.

Comment by Fransiskus Lukman [ 14/Nov/15 ]

sure ill upload it

Comment by Andrew Morrow (Inactive) [ 12/Nov/15 ]

Could you possibly provide a minimal compilable source file that fails to link for you? I'd like to try to reproduce on my local system.

Comment by Andrew Morrow (Inactive) [ 12/Nov/15 ]

I had overlooked that you already had boost _system on the build line, just at the beginning, so clearly that was not actually the issue.

Comment by Fransiskus Lukman [ 10/Nov/15 ]

Andrew,
I tried rebuilding with
g++ -Wall -std=c++11 -l boost_system -pthread -I mongo-client-install/include -L mongo-client-install/lib -l mongoclient -l boost_thread -l boost_regex -l boost_system main.cpp -o Lucy $(mysql_config --libs --cflags)

still the same output of:
/tmp/ccS9fOwE.o: In function `__static_initialization_and_destruction_0':
/usr/include/boost/system/error_code.hpp:222: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:223: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:224: undefined reference to `boost::system::system_category()'
collect2: error: ld returned 1 exit status

Comment by Fransiskus Lukman [ 10/Nov/15 ]

Andrew Morrow I have tried, i think boost don't install easily on Ubuntu 14.04

I used sudo apt-get install libboost-all-dev
currently when i run:
scons --prefix=$HOME/mongo-client-install --ssl --use-sasl-client --sharedclient --extrapath=/usr/include/boost --c++11=on install

This is the output:
scons: Reading SConscript files ...
scons version: 2.3.0
python version: 2 7 6 'final' 0
Checking whether the C++ compiler worksyes
Checking whether the C compiler worksyes
Checking if C++ compiler "g++" is GCC... yes
Checking if C compiler "gcc" is GCC... yes
Checking if C compiler supports -Wno-unused-local-typedefs... yes
Checking if C compiler supports -Wno-unused-function... yes
Checking if C compiler supports -Wno-unused-private-field... no
Checking if C compiler supports -Wno-deprecated-declarations... yes
Checking if C compiler supports -Wno-tautological-constant-out-of-range-compare. .. no
Checking if C compiler supports -Wno-unused-const-variable... no
Checking if C compiler supports -Wno-missing-braces... yes
Checking if we are using libstdc++... yes
Checking for libstdc++ 4.6.0 or better... yes
Checking if C++ compiler supports -std=c++11... yes
Checking if C compiler supports -std=c99... yes
Checking if we are on a POSIX system... yes
Checking if the POSIX monotonic clock is supported... yes
Checking for __thread... no
Checking for C++11 <atomic> support... no
Checking for gcc __atomic builtins... no
Checking for useable __sync builtins... no
Checking for C++11 is_trivially_copyable support... no
Checking for C++ header file boost/version.hpp... yes
Checking for C++ library boost_regex-mt... no
Checking for C++ library boost_regex... no
can't find boost

is there a direction or suggestion for me?

Comment by Andrew Morrow (Inactive) [ 10/Nov/15 ]

fransiskuslukman@gmail.com - Building with --config=force shouldn't ever cause a problem. Actually though, I think the solution might be much simpler: I think you need to add boost_system to your link line. Can you try building your application with :

g++ -Wall -std=c++11 -l boost_system -pthread -I mongo-client-install/include -L mongo-client-install/lib -l mongoclient -l boost_thread -l boost_regex -l boost_system main.cpp -o Lucy $(mysql_config --libs --cflags)

Also, please be aware that boost installed in /usr is most likely not built with C++11. The current understanding of the C++ driver developers is that boost does not offer a stable ABI between C++03 and C++11 builds, so it is still something to look out for.

Comment by Fransiskus Lukman [ 10/Nov/15 ]

Hi andrew,

i build the scons with
scons --prefix=$HOME/mongo-client-install --ssl --sharedclient --c++11=on install

i am currently making a fresh build on ubuntu 14.04 reinstalling because on the previous one i might have used --config=force

Comment by Andrew Morrow (Inactive) [ 09/Nov/15 ]

fransiskuslukman@gmail.com - I see that you are building your application with C++11. Did you build the mongo C++ driver with C++11 enabled? Is the boost in /usr built with C++11 (it usually is not). It is unfortunate, but boost does not offer a stable ABI between C++03 and C++11 builds of the library. As a result, all of your application, the driver, and boost must be consistently built with either C++03 or C++11.

Generated at Wed Feb 07 22:00:08 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.