undefined references during link phase using Boost 1.53 - c++

I am using g++ 4.1.2 and Boost 1.53 on Red Hat Linux rel 5.5. There is an issue during the linking process which is unclear to me. I get the error msg:
/usr/local/boost_1_53_0/stage/lib/libboost_thread.so:
undefined reference to `std::bad_exception::what() const#GLIBCXX_3.4.9'
/usr/local/boost_1_53_0/stage/lib/libboost_thread.so:
undefined reference to `std::bad_alloc::what() const#GLIBCXX_3.4.9'
collect2: ld returned 1 exit status
There seems to be a problem related to the libstdc++.so file version I'm linking with. If I alternate hiding and revealing this file I can get my program to link. However, I would like to be able to 'make' in one step as I did before I introduced the Boost libraries and concurrent threading.
Please help shed some light on this issue if you have any insight.

Please try to install via yum.
yum install boost
You will not encouter such issues.
Try to include rpmforge and epel yum repositories.

http://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html#abi.versioning shows that GLIBCXX_3.4.9 is the symbol version used by the libstdc++.so from GCC 4.2.0, so if the Boost library wants that version then it means it was compiled with GCC 4.2.x
That means you can't use the library with a program linked by GCC 4.1.2, you need to link with GCC 4.2.0 or later
libstdc++.so is backward compatible but not forwards compatible, so you can compile a program with one version and link it to a newer version, but you can't compile with a newer version and link to an older version.

Related

Missing symbols when using Clang with libc++ on CentOS 7 (no C++ ABI lib?)

The following packages were installed from repositories on CentOS 7.6:
clang-3.4.2-9.el7.x86_64
libcxx-3.8.0-3.el7.x86_64
libcxx-devel-3.8.0-3.el7.x86_64
Trying to build a simple C++ program:
clang++ -std=c++11 -stdlib=libc++ junk.cpp
This results in a bunch of linker errors, an example is:
/bin/../lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libc++.so: undefined reference to `__cxa_throw'
AFAIK, this seems to be a problem of missing C++ ABI library, but I can't figure out how to install one that would provide the needed symbols. I could probably build one from source, but would like to stick with what's available from trustworthy repositories.
Any ideas on how to fix this?
I can build the program just fine if -stdlib=libc++ is omitted, in which case libstdc++ is used.
Try passing -lc++abi manually. This problem is fixed in modern installations, but the Linux packages aren't modern. Consider using apt.llvm.org

gcc build behavior when there is are conflicting version of openssl

I am trying to build a c++ library of mine (which is dependent on facebook/folly) with gcc7. Some important points to note
Previously I was using gcc 4.8 to build this library
Since there is ABI incompatibility introduced in gcc 5.2 - I built folly from source (and all other dependent libraries like glog etc.) with gcc 7 - and I am using the updated libraries and shared objects.
My library uses openssl 1.1 (even previously when it was being built with gcc 4.8), where as folly (the version of folly that I am using) uses openssl 1.0.2
Even with the openssl version incompatibility the build of my library would go through fine with gcc 4.8 with the following warning
/usr/bin/ld: warning: libssl.so.10, needed by /home/<username>/folly/folly/1000.37.2.1/lib/libfolly.so, may conflict with libssl.so.1.1
I get the exact same warning with gcc 7 as well, but my build now fails with the following error
/usr/bin/ld: /home/<username>/folly/folly/1000.37.2.1/lib/libfolly.a(SSLSessionCacheManager.o): undefined reference to symbol 'SSL_CTX_get_ex_new_index##libssl.so.10'
/usr/lib64/libssl.so.10: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
I have tried researching this problem in regards to DSO missing from command line - but the solutions mentioned in other questions doesn't seem to be my case.
There are 3 questions that I am seeking to answer here
Can openssl version incompatibility be the reason for the build failure?
Why would the build succeed in gcc 4.8 but fail on gcc 7?
Is there an way to solve this without updating openssl version in folly (I will have to pull in a lot of changes for that - which will require code changes from my side). My library only uses openssl/md5.h

ld for Clang installation

I installed CLang on CentOS using sudo yum install clang. Then tried using it by firing this command clang++ main.cpp -o main. This complained of missing ld.
Prior to this I had deleted the usr/bin/ld
I read that llvm has it's own linker; I am unable to find one. I also read that llvm lld was removed and the documentation says that one can make do with Clang only. Given that I have removed /usr/bin/ld, how do I get it back? Do I need to get it back? How do I make CLang use the linker that is supposed to be included with Clang?
I am debugging an issue and to one of the steps in trying to fix the issue was to reinstall the compiler, hence I resorted to deleting all the previously installed packaged and files, including ld.

Boost 1.44 with Python 2.7.1 on RHEL5 using gcc-4.1.2

Ugh! I have hit one of those errors where I am really clueless. I have built/installed Python (2.7.1) and I've built/installed boost (1.44.0) against that version of python. I don't see any errors in my boost build, everything goes through fine.
When I turn to do my application build that has a lot of boost dependency, where inside my C++ code, I do have a call to Py_Init(...) I am getting the following error:
Linking CXX executable ../../../myapp_exec
../../../../../config/cmake/platforms/../../../../3rdparty/2012/<pack>/rh5_x86_64_gcc-4.1.2/boost-1.44.0/lib/libboost_python-gcc41-1_44.so: undefined reference to `Py_InitModule4' collect2: ld returned 1 exit status
gmake[2]: *** [myapp_exec] Error 1
I googled around but nothin really comes across as a solution. I don't see this issue on Windows. Appreciate if anyone can share their experiences with similar issues on Linux (RHEL5), and how they overcame it. I could try building boost-1.44.0 against older versions of Python (2.6.4 or older).
Thanks in advance, for your time & interest.
-T.
why not use the repository and rpm/yum install everything? it looks to me like gcc 4.1.2(2007) might be too old for boost 1.44(2010) and similarly with python. I think moving to a more recent compiler or a linux distro(latest RHEL based linux..i.e RHEL ,CentOs exc..) upgrade is the way to go.
also did you run make check on boost and python to see if they compiled correctly?
I think I have resolved the issue. It was basically a matter of adding the arguments linkflags="-m64 -Wl,-E" during the boost build. That it appears fixes the issue.
Adding -lpython<version> such as -lpython2.7 solves the problem form me.
NOTE: path to libpython<version> such as libpython2.7.so must be specified using -L
so for python2.7 whose library (libpython2.7.so) is installed at /usr/lib would use:
-L/usr/lib -lpython2.7 as one of the linking option when compiling program that uses boost

gcc 4.7.1 build ends with undefined reference

I am getting a
fortran/arith.o: In function gfc_mpfr_to_mpz(__mpz_struct*,
__mpfr_struct*, locus*)': arith.c:(.text+0x1169): undefined reference tompfr_get_z_2exp'
from gcc 4.7.1 build process. I am following
gcc-wiki
However, I have made a little change to the
download_prequisites
script. And that is I am downloading the latest releases of all the prequisites for gcc where the original one was downloading a bit older ones since the above link was given for gcc 4.6. However, it can not find some symbols related to mpfr library.
A related google search gives me this thread however it also did not help me, maybe someone else could understand that differently than me:
A similar thread
Any hints on how to resolve this problem?
I recently built gcc 4.7.1 for Mountain Lion and followed a very nice tutorial of how to do a gcc build. In it, it describes all the necessary lib compilations, include mpfr, gmp and others. If you're running linux, I think it will work for you as well, give it a try:
http://solarianprogrammer.com/2012/07/21/compiling-gcc-4-7-1-mac-osx-lion/
Let me know if that helps.