[CXX-740] wrong settings in SConstruct for --ssl option Created: 19/Nov/15  Updated: 11/Dec/15  Resolved: 11/Dec/15

Status: Closed
Project: C++ Driver
Component/s: Build
Affects Version/s: legacy-1.0.5, legacy-1.1.0-rc0
Fix Version/s: None

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


 Description   

I ran into issue when tried to compile driver with -ssl option.
Test "def CheckLinkSSL(context)" from SConstruct is not passed.
I checked config.log and it tries to build simple ssl test with gcc (because of *.c extension of generated file), but with boost_regext, boost_thread libraries.
It can be fixed simply by fixing dependencies for test or renaming that file to have cpp extention - g++ will be picked up.



 Comments   
Comment by Andrew Morrow (Inactive) [ 11/Dec/15 ]

bayda - I'm closing this issue as I haven't heard back from you with any further details. If you are still having trouble building the driver please feel free to re-open the ticket.

Comment by Andrew Morrow (Inactive) [ 07/Dec/15 ]

Why are you using the --runtime-library-search-path option? It should not be necessary if your boost installation is properly done.

Comment by Vladimir Bayda [ 19/Nov/15 ]

I use following scons command line
scons --prefix=${INSTALL_TO} --disable-warnings-as-errors --runtime-library-search-path=${BOOST_LIB} --cc=${CC} --cxx=${CXX} --extrapath=${BOOST},${OPENSSL} --c++11=on --ssl install

command lines from scons config.log
gcc -o build/scons/sconf_temp/conftest_31.o -c -std=c99 -fPIC -ggdb -pthread -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch -pipe -O3 -Wno-unused-local-typedefs -Wno-unused-function -Wno-deprecated-declarations -Wno-missing-braces -DMONGO_EXPOSE_MACROS -D_FILE_OFFSET_BITS=64 -DMONGO_HAVE___THREAD -DBOOST_THREAD_USES_DATETIME -DMONGO_HAVE_HEADER_UNISTD_H -DMONGO_HAVE_POSIX_MONOTONIC_CLOCK -I/skipped/ssl/third_party/gtest-1.7.0/include -I/skipped/ssl -I/skipped/ssl/mongo -I/skipped/boost/include -I/skipped/openssl-0.9.7g-m64/include build/scons/sconf_temp/conftest_31.c
gcc -o build/scons/sconf_temp/conftest_31 -fPIC -Wl,-z,now -rdynamic -pthread build/scons/sconf_temp/conftest_31.o -L$ -L/skipped/openssl-0.9.7g-m64/lib -L/usr/lib64 -L/lib64 -lm -lpthread -lssl -lcrypto -lboost_regex -lboost_thread -lboost_system

I replaced long parts of pathes on /skipped/.

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

Interestingly, it doesn't fail for me, either on OS X or on Linux. It is somewhat strange to me that this would fail. The executable itself doesn't have any dependencies on the C++ runtime symbols. The boost library of course does, but I would expect that libboost_regex.so, for instance, would have a DT_NEEDED entry for libstdc++ and libgcc_s.so. On my system, for instance:

$ readelf -a /usr/lib/x86_64-linux-gnu/libboost_regex.so | grep NEEDED
 0x0000000000000001 (NEEDED)             Shared library: [libicui18n.so.55]
 0x0000000000000001 (NEEDED)             Shared library: [libicuuc.so.55]
 0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libpthread.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]

Are you passing any extra flags to the build system? What does your SCons invocation look like? Does your boost_regex have a DT_NEEDED entry for the C++ runtime libraries?

Comment by Vladimir Bayda [ 19/Nov/15 ]

libboost_regex.so: undefined reference to `__cxa_throw_bad_array_new_length@CXXABI_1.3.8'
libboost_regex.so: undefined reference to `std::__detail::_List_node_base::_M_unhook()@GLIBCXX_3.4.15'
libboost_regex.so: undefined reference to `std::overflow_error::~overflow_error()@GLIBCXX_3.4.15'
libboost_regex.so: undefined reference to `std::_detail::_List_node_base::_M_hook(std::_detail::_List_node_base*)@GLIBCXX_3.4.15'
libboost_regex.so: undefined reference to `std::invalid_argument::~invalid_argument()@GLIBCXX_3.4.15'
libboost_regex.so: undefined reference to `std::__throw_out_of_range_fmt(char const*, ...)@GLIBCXX_3.4.20'
libboost_regex.so: undefined reference to `std::_detail::_List_node_base::_M_transfer(std::detail::_List_node_base*, std::_detail::_List_node_base*)@GLIBCXX_3.4.15'

It happens because it compiles file with gcc instead of g++ and links -lboost_regex -lboost_thread -lboost_system

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

Thanks for the bug report. What error is emitted in the config.log when linking that way?

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