How to fix /usr/bin/ld: cannot find -lboost_python - g++

I just installed boost.python following the instructions on https://www.boost.org/doc/libs/1_69_0/libs/python/doc/html/building/no_install_quickstart.html
but when I try to run the code
bjam toolset=gcc --verbose-test test
it throws:
...found 23 targets...
...updating 6 targets...
gcc.link.dll extending.so
/usr/bin/ld: cannot find -lboost_python
collect2: error: ld returned 1 exit status
"g++" -o "extending.so" -Wl,-h -Wl,extending.so -shared -Wl,--start-group "extending.o" -Wl,-Bstatic -Wl,-Bdynamic -lboost_python -ldl -lpthread -lutil -Wl,--end-group -fPIC -g
...failed gcc.link.dll extending.so...
...skipped <p.>test_ext for lack of <p.>extending.so...
gcc.link test_embed
/usr/bin/ld: cannot find -lboost_python
collect2: error: ld returned 1 exit status
"g++" -L"/usr/lib" -L"/usr/lib/python2.7/config" -Wl,-rpath -Wl,"/usr/lib" -Wl,-rpath -Wl,"/usr/lib/python2.7/config" -o "test_embed" -Wl,--start-group "embedding.o" -Wl,-Bstatic -Wl,-Bdynamic -lboost_python -ldl -lpthread -lutil -lpython2.7 -Wl,--end-group -fPIC -g
...failed gcc.link test_embed...
...skipped <p.>test_embed.run for lack of <p.>test_embed...
...failed updating 2 targets...
...skipped 4 targets...
Anyone knows how to solve it? I only want boost to use boost.python.
Thanks

It's a linker error. Probably the lib file is under a different name, so have to create a symbolic link manually.
Search and locate the "libboost_pythonXX.so" file in the usr/lib directory
XX will match the python version with which you configured boost while building, From the exception thrown you probably configured it with python2.7, so the file probably will be named as libboost_python27.so
and then create a symbolic link :
sudo ln -s "libboost_pythonXX.so" libboost_python.so
You can use this link for reference.
https://github.com/BVLC/caffe/issues/4843
It helped me to solve the error for me.

Related

cmake -> libpthread.so.0: error adding symbols: DSO missing from command line

I am getting the error
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libgtest.a(gtest-all.cc.o): undefined reference to symbol 'pthread_key_delete##GLIBC_2.2.5'
/lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
in a project built via cmake.
The actual command line generating that error is (I am copying only the relevant part)
/usr/bin/c++ ... -lpthread -ldl -Wl,-Bstatic -lgtest -Wl,-Bdynamic ...
The error means that -lpthread should go after -lgtest.
After fixing that by hand, another error prompts me to moving -lpthread after -Wl,-Bdynamic.
After that change, linking works ok with
/usr/bin/c++ ... -ldl -Wl,-Bstatic -lgtest -Wl,-Bdynamic -lpthread ...
But I did this by hand at the command line.
How should I modify my cmake configuration (either in CMakeLists.txt for my project, or elsewhere) to get the correct order of flags or remove the error?
Note:
Trying to find out where can this be set, I ran
$ find . -type f -iname "*cmake*" -exec grep -B 4 -A 4 pthread {} \;
at the root of my project.
There is only one instance reported in ./CMake/FindMyprojMKL.cmake
set(MKL_LIBS
# mkl_solver_lp64
mkl_intel_lp64
mkl_core
pthread
mkl_gnu_thread)
message(STATUS "MKL_LIBS= ${MKL_LIBS}")
ELSE(MKL_LIBRARY)
message(STATUS "Error: can not found MKL_LIBRARY")
I guess this is not the right place to fix the issue.

Percona5.7 cmake failed on centos 7

I get the source code of percona-server from github. And I install boost 1.59 and gcc gcc-c ncurses-devel. I enter the directory of percona-server and run "cmake --DWITH_BOOST=/data/boost" but get the following error. I cannot find some solution so I came to here. Thanks!!
-- Performing Test HAVE_UNUSED_PARAMETER - Success
-- Googletest was not found. gtest-based unit tests will be disabled. You can run cmake . -DENABLE_DOWNLOADS=1 to automatically download and build required components from source.
-- If you are inside a firewall, you may need to use an https proxy: export https_proxy=http://example.com:80
-- Performing Test HAVE_MISLEADING_INDENTATION
-- Performing Test HAVE_MISLEADING_INDENTATION - Failed
-- executable target mysqld debug_target /home/teg/Downloads/debug/sql/mysqld
-- Library mysqlserver depends on OSLIBS -lpthread;/usr/lib64/libz.so;m;rt;crypt;dl;aio;numa
-- MERGE_CONVENIENCE_LIBRARIES TARGET mysqlserver
-- MERGE_CONVENIENCE_LIBRARIES LIBS dbug;strings;regex;mysys;mysys_ssl;vio;/usr/lib64/libz.so;yassl;taocrypt;crypt;dl;archive_embedded;b lackhole_embedded;csv_embedded;federated_embedded; heap_embedded;innobase_embedded;lz4_lib;numa;myisa m_embedded;myisammrg_embedded;partition_embedded;n gram_parser_embedded;sql_embedded
-- MERGE_CONVENIENCE_LIBRARIES MYLIBS dbug;strings;regex;mysys;mysys_ssl;vio;yassl;taocr ypt;archive_embedded;blackhole_embedded;csv_embedd ed;federated_embedded;heap_embedded;innobase_embed ded;lz4_lib;myisam_embedded;myisammrg_embedded;par tition_embedded;ngram_parser_embedded;sql_embedded
-- library target mysqlserver debug_target /home/teg/Downloads/debug/archive_output_directory/libmysqld.a
-- INSTALL perconaserverclient.pc lib/pkgconfig
-- Skipping deb packaging on unsupported platform Core.
-- CMAKE_BUILD_TYPE: RelWithDebInfo
-- COMPILE_DEFINITIONS: _GNU_SOURCE;_FILE_OFFSET_BITS=64;HAVE_CONFIG_H;HAV E_LIBEVENT1
-- CMAKE_C_FLAGS: -Wall -Wextra -Wformat-security -Wvla -Wwrite-strings -Wdeclaration-after-statement
-- CMAKE_CXX_FLAGS: -std=gnu++03 -Wall -Wextra -Wformat-security -Wvla -Woverloaded-virtual -Wno-unused-parameter
-- CMAKE_C_LINK_FLAGS:
-- CMAKE_CXX_LINK_FLAGS:
-- CMAKE_C_FLAGS_RELWITHDEBINFO: -O3 -D_FORTIFY_SOURCE=2 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF -DNDEBUG
-- CMAKE_CXX_FLAGS_RELWITHDEBINFO: -O3 -D_FORTIFY_SOURCE=2 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF -DNDEBUG
-- Configuring incomplete, errors occurred!
See also "/home/teg/Downloads/percona-server-5.7/CMakeFiles/CMakeOutput.log".
See also "/home/teg/Downloads/percona-server-5.7/CMakeFiles/CMakeError.log".
.................................................. .........................
And I open the /home/teg/Downloads/percona-server-5.7/CMakeFiles/CMakeError.log and find the following errors. There are too many errors and I only list part of it.
Run Build Command:/usr/bin/gmake "cmTryCompileExec1295500228/fast"
/usr/bin/gmake -f CMakeFiles/cmTryCompileExec1295500228.dir/build.make CMakeFiles/cmTryCompileExec1295500228.dir/build
gmake[1]: Entering directory `/home/teg/Downloads/percona-server-5.7/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /home/teg/Downloads/percona-server-5.7/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec1295500228.dir/CheckSymbolExists.c.o
/usr/bin/cc -o CMakeFiles/cmTryCompileExec1295500228.dir/CheckSymbolExists.c.o -c /home/teg/Downloads/percona-server-5.7/CMakeFiles/CMakeTmp/CheckSymbolExists.c
Linking C executable cmTryCompileExec1295500228
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec1295500228.dir/link.txt --verbose=1
/usr/bin/cc CMakeFiles/cmTryCompileExec1295500228.dir/CheckSymbolExists.c.o -o cmTryCompileExec1295500228 -rdynamic
CMakeFiles/cmTryCompileExec1295500228.dir/CheckSymbolExists.c.o: In function `main':
CheckSymbolExists.c.text+0x16): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
gmake[1]: Leaving directory `/home/teg/Downloads/percona-server-5.7/CMakeFiles/CMakeTmp'
gmake[1]: *** [cmTryCompileExec1295500228] Error 1
gmake: *** [cmTryCompileExec1295500228/fast] Error 2
File /home/teg/Downloads/percona-server-5.7/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
Run Build Command:/usr/bin/gmake "cmTryCompileExec1916958743/fast"
/usr/bin/gmake -f CMakeFiles/cmTryCompileExec1916958743.dir/build.make CMakeFiles/cmTryCompileExec1916958743.dir/build
gmake[1]: Entering directory `/home/teg/Downloads/percona-server-5.7/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /home/teg/Downloads/percona-server-5.7/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec1916958743.dir/CheckFunctionExists.c.o
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create -o CMakeFiles/cmTryCompileExec1916958743.dir/CheckFunctionExists.c.o -c /usr/share/cmake/Modules/CheckFunctionExists.c
Linking C executable cmTryCompileExec1916958743
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec1916958743.dir/link.txt --verbose=1
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create CMakeFiles/cmTryCompileExec1916958743.dir/CheckFunctionExists.c.o -o cmTryCompileExec1916958743 -rdynamic -lpthreads
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
gmake[1]: Leaving directory `/home/teg/Downloads/percona-server-5.7/CMakeFiles/CMakeTmp'
gmake[1]: *** [cmTryCompileExec1916958743] Error 1
gmake: *** [cmTryCompileExec1916958743/fast] Error 2
Determining if the function floor exists failed with the following output:
Change Dir: /home/teg/Downloads/percona-server-5.7/CMakeFiles/CMakeTmp
Run Build Command:/usr/bin/gmake "cmTryCompileExec1596718479/fast"
/usr/bin/gmake -f CMakeFiles/cmTryCompileExec1596718479.dir/build.make CMakeFiles/cmTryCompileExec1596718479.dir/build
gmake[1]: Entering directory `/home/teg/Downloads/percona-server-5.7/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /home/teg/Downloads/percona-server-5.7/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec1596718479.dir/CheckFunctionExists.c.o
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=floor -o CMakeFiles/cmTryCompileExec1596718479.dir/CheckFunctionExists.c.o -c /usr/share/cmake/Modules/CheckFunctionExists.c
<command-line>:0:23: warning: conflicting types for built-in function ‘floor’ [enabled by default]
/usr/share/cmake/Modules/CheckFunctionExists.c:3:6: note: in expansion of macro ‘CHECK_FUNCTION_EXISTS’
char CHECK_FUNCTION_EXISTS();
^
Linking C executable cmTryCompileExec1596718479
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec1596718479.dir/link.txt --verbose=1
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=floor CMakeFiles/cmTryCompileExec1596718479.dir/CheckFunctionExists.c.o -o cmTryCompileExec1596718479 -rdynamic
CMakeFiles/cmTryCompileExec1596718479.dir/CheckFunctionExists.c.o: In function `main':
CheckFunctionExists.c.text+0x15): undefined reference to `floor'
collect2: error: ld returned 1 exit status
gmake[1]: Leaving directory `/home/teg/Downloads/percona-server-5.7/CMakeFiles/CMakeTmp'
gmake[1]: *** [cmTryCompileExec1596718479] Error 1
gmake: *** [cmTryCompileExec1596718479/fast] Error 2
it seems you haven't all needed dependencies installed.
These are the steps which are needed:
sudo yum install epel-release
sudo yum install git gcc gcc-c++ openssl check cmake bison boost-devel asio-devel
libaio-devel ncurses-devel readline-devel pam-devel wget perl-Env time numactl-devel
rpmdevtools rpm-build curl-devel
git clone https://github.com/percona/percona-server.git
cd percona-server
git submodule init
git submodule update
cmake . -DDOWNLOAD_BOOST=1 -DWITH_BOOST=<PATCH_TO_BOOST_DIR>
Then boost will be downloaded automatically

CMake on Cygwin with clang not creating expected dll.a

I'm building a shared library and an application using that lib on Cygwin. With GCC CMake creates a .dll.a to use when linking. Switching to clang I get
[ 34%] Built target xxx_shared
make[2]: *** No rule to make target 'src/libxxx.dll.a', needed by 'xxx.exe'. Stop.
Is this a bug in the clang CMake extension?
I'm using cmake --version 3.3.2
Yes, it seems to be a bug in CMake. Running make VERBOSE=1 reveals that with GCC:
/usr/bin/c++.exe -g -shared -Wl,--enable-auto-import -o XXX -Wl,-Bstatic -lm -Wl,-Bdynamic -lstdc++ -lcygwin -ladvapi32 -lshell32 -luser32 -lkernel32
while with clang:
/usr/bin/clang++ -fPIC -g -shared -o XXX -Wl,-Bstatic -lm -Wl,-Bdynamic -lstdc++ -lcygwin -ladvapi32 -lshell32 -luser32 -lkernel32
So it seems that somehow clang++ does not get the -Wl,--enable-auto-import flag. Manually running the corrected clang++ command correctly creates the expected .dll.a allowing the rest of the build to proceed as expected.
Haven't figured out why this happens yet, though. At this point I can't decipher CMakes platform extensions, which seems to set this for GCC.
Update: I've reported this here.

Building Chromium, WebRTC without LTO

I'm on Arch Linux x86_64, attempting to build the WebRTC libraries. I get compile errors when I do:
[ghilliard#diadem trunk]$ ninja -C out/Release peerconnection_server
ninja: Entering directory `out/Release'
[1/1] LINK peerconnection_server
FAILED: c++ -Wl,-z,now -Wl,-z,relro -Wl,--fatal-warnings -pthread -Wl,-z,noexecstack -fPIC -B/home/ghilliard/Code/webrtc-attempt2/trunk/third_party/binutils/Linux_x64/Release/bin -Wl,--disable-new-dtags -m64 -Wl,--icf=none -fuse-ld=gold -Wl,-O1 -Wl,--as-needed -Wl,--gc-sections -o peerconnection_server -Wl,--start-group obj/talk/examples/peerconnection/server/peerconnection_server.data_socket.o obj/talk/examples/peerconnection/server/peerconnection_server.main.o obj/talk/examples/peerconnection/server/peerconnection_server.peer_channel.o obj/talk/examples/peerconnection/server/peerconnection_server.utils.o obj/talk/libjingle.a obj/net/third_party/nss/libcrssl.a obj/third_party/jsoncpp/libjsoncpp.a -Wl,--end-group -lsmime3 -lnss3 -lnssutil3 -lplds4 -lplc4 -lnspr4 -ldl -lcrypto -lrt -lXext -lX11 -lXcomposite -lXrender -lexpat
/home/ghilliard/Code/webrtc-attempt2/trunk/third_party/binutils/Linux_x64/Release/bin/ld.gold: -plugin: unknown option
/home/ghilliard/Code/webrtc-attempt2/trunk/third_party/binutils/Linux_x64/Release/bin/ld.gold: use the --help option for usage information
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
There appears to be a problem with link time optimization. However, I cannot figure out how to build WebRTC without LTO enabled. If I manually run the command that failed and append -fno-lto, it links fine. How can I add or change the compiler/linker flags within the gyp configuration so that it gets applied to everything?
ninja does not respect environment variables, but gyp does.
So after setting the LDFAGS environment variables, you have to run gyp_chromium to let the gyp generate correct ninja build file.
export LDFLAGS='-fno-lto'
build/gyp_chromium
ninja -C out/Release peerconnection_server
You might try to set compiler/linker flags in environment variables before build:
export CFLAGS="${CFLAGS} -fno-lto"
export CXXFLAGS="${CXXFLAGS} -fno-lto"
export LDFLAGS="${LDFLAGS} -fno-lto"
ninja -C out/Release

Trouble with g++ & libpqxx lib

I've very simple example, and can't correctly build it, I was using next arguments:
g++ -lpq -libpqxx -Wall -o "pg" "pg.cpp" (in dir: /home/user)
/usr/lib/gcc/i586-suse-linux/4.5/../../../../i586-suse-linux/bin/ld: cannot find -lpq
collect2: ld returned 1 exit status
or
returned 1 exit status g++ -libpqxx -Wall -o "pg" "pg.cpp"
(in dir: /home/user)
/usr/lib/gcc/i586-suse-linux/4.5/../../../../i586-suse-linux/bin/ld:
cannot find -libpqxx collect2: ld
but everywere had error.
libpqxx succ installed
#lisuse-home:~> locate libpqxx | grep /lib/
/usr/lib/libpqxx-3.1.so
/usr/lib/libpqxx.la
/usr/lib/libpqxx.so
/usr/lib/pkgconfig/libpqxx.pc
g++ filename.cpp -o target -lpqxx
-lpqxx should take care of -lpq. If for some reason it does not find pq, find pq and put it in the same directory as pqxx.
compiling g++ -libpqxx-3.1 -Wall -c "%f"
building g++ -Wall -o "%e" /usr/lib/libpqxx-3.1.so "%f"