Error concerning an " undefined reference to `__dso_handle' " when complinging Glibc - c

I am working on a Linux from Scratch system for the first time.
Background Info:
Book version - 10.1
Host distrobution - EndeavorOS
Problem occurs in step 5.5.1 https://www.linuxfromscratch.org/lfs/view/stable/chapter05/glibc.html
I begin to compile Glibc, but then about a minute or so in it ends the process. It appears things start to go downhill here:
/mnt/lfs/tools/lib/gcc/x86_64-lfs-linux-gnu/10.2.0/../../../../x86_64-lfs-lin
ux-gnu/bin/ld: /mnt/lfs/sources/glibc-2.33/build/nptl/libpthread_pic.a(old_pt
hread_atfork.os): in function `__dyn_pthread_atfork':
/mnt/lfs/sources/glibc-2.33/nptl/pthread_atfork.c:51: undefined reference to
`__dso_handle'
/mnt/lfs/tools/lib/gcc/x86_64-lfs-linux-gnu/10.2.0/../../../../x86_64-lfs-lin
ux-gnu/bin/ld: /mnt/lfs/sources/glibc-2.33/build/nptl/libpthread_pic.a(old_pt
hread_atfork.os): relocation R_X86_64_PC32 against undefined hidden symbol `_
_dso_handle' can not be used when making a shared object
/mnt/lfs/tools/lib/gcc/x86_64-lfs-linux-gnu/10.2.0/../../../../x86_64-lfs-lin
ux-gnu/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make[2]: *** [../Makerules:536: /mnt/lfs/sources/glibc-2.33/build/nptl/libpth
read.so] Error 1
make[2]: Leaving directory '/mnt/lfs/sources/glibc-2.33/nptl'
make[1]: *** [Makefile:479: nptl/others] Error 2
make[1]: Leaving directory '/mnt/lfs/sources/glibc-2.33'
make: *** [Makefile:9: all] Error 2
[lfs#Endeavour build]$
(The full non-shortened output can be found here: https://pastebin.com/7Qk40xr2)
Multiple times it mentions `__dso_handle'
I have tried using "make -j4", "make", and "make -j1", but they all lead to the same problem.
If any assistance could be provided, I would be grateful.

Related

undefined reference to `ceilf'

I am trying to "make" a program and yet face these errors; I used make -lm and even did #include but still I face the same problem. I tried installing the application on both Ubuntu and Debian just to make sure I remove doubts on corrupted libraries.Still no success !
nat_src_endpoint_ip.o: In function `__new':
/root/softwares/sweetspot-0.0.20/src/nat_src_endpoint_ip.c:95: undefined reference to `ceilf'
nat_src_endpoint_tcp.o: In function `__create':
/root/softwares/sweetspot-0.0.20/src/nat_src_endpoint_tcp.c:58: undefined reference to `ceilf'
nat_src_endpoint_udp.o: In function `__create':
/root/softwares/sweetspot-0.0.20/src/nat_src_endpoint_udp.c:59: undefined reference to `ceilf'
nat_src_endpoint_icmp.o: In function `__create':
/root/softwares/sweetspot-0.0.20/src/nat_src_endpoint_icmp.c:48: undefined reference to `ceilf'
collect2: ld returned 1 exit status
make[1]: *** [sweetspot] Error 1
make[1]: Leaving directory `/root/softwares/sweetspot-0.0.20/src'
make: *** [all] Error 2
You should link with the math library. In Gcc this means that you should add -lm to the linking command line (if you only use one command line it means that this command line is both for compiling and linking).

linker error while osg build osgviewer

I am trying to build osg 14.0 on slackware 14.0 from source. I get linker error while creating executable files from osgviewer:
Linking CXX executable ../../bin/osgviewer
../../lib/libosg.so.3.0.1: undefined reference to `std::__detail::_List_node_base::_M_transfer(std::__detail::_List_node_base*, std::__detail::_List_node_base*)'
../../lib/libosg.so.3.0.1: undefined reference to `std::__detail::_List_node_base::_M_hook(std::__detail::_List_node_base*)'
../../lib/libosg.so.3.0.1: undefined reference to `std::__detail::_List_node_base::_M_unhook()'
../../lib/libosgDB.so.3.0.1: undefined reference to `std::__detail::_List_node_base::swap(std::__detail::_List_node_base&, std::__detail::_List_node_base&)'
collect2: error: ld returned 1 exit status
make[2]: *** [bin/osgviewer] Error 1
make[1]: *** [applications/osgviewer/CMakeFiles/application_osgviewer.dir/all] Error 2
make: *** [all] Error 2
This is ld.so.conf
/usr/local/lib
/usr/i486-slackware-linux/lib
/usr/lib/seamonkey
/usr/lib
Do you know where the problem could be ?
Thank you.

CMAKE DSO linking

I'm totally new to cmake. After an svn update (but also to binutils and I suspect this is causing the problem), I get an error (I successfully compiled and used the program before)
Linking CXX executable gmsh
/usr/bin/ld: /usr/local/lib/liblapack.a(dgesvd.o): undefined reference to symbol '_gfortran_concat_string##GFORTRAN_1.0'
/usr/bin/ld: note: '_gfortran_concat_string##GFORTRAN_1.0' is defined in DSO /usr/lib/libgfortran.so.3 so try adding it to the linker command line
/usr/lib/libgfortran.so.3: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
make[2]: *** [gmsh] Error 1
make[1]: *** [CMakeFiles/gmsh.dir/all] Error 2
make: *** [all] Error 2
Maybe it's related to this Fedoraproject DSO Change?
I have an up-to-date archlinux (binutils-2.23-1).
I tried to edit lines in the ccmake . menu. After hitting [c] the original options are restored (so I cannot add /usr/lib/libgfortran.so.3 to the GMSH_EXTERNAL_LIBRARIES variable in order [g] generate the new Makefiles).
I also tried adding some options which were recommended in the cmake irc chat, but it eventually didn't work.
cmake . -DCMAKE_LINK_FLAGS=-Wl,--add-needed
or
cmake . -DCMAKE_LINK_FLAGS=-lgfortran
Resulting in the same error. What can I do?
Additional information: make VERBOSE=1 pastebin link
To add a library to the link command, you can use target_link_libraries. Apparently in this case you want:
target_link_libraries(gmsh ${LINK_LIBRARIES} gfortran)

'undefined reference' errors when compiling against library

I added a third party library to my code and is getting errors like this when running make. Please help me understand this error.
(.text+0x9b4): undefined reference to `snd_strerror'
/home/bet/Tent/tun/app/Common/hl/lib/libGHAL.a(gfxhal.o): In function `GFX_create_region':
/home/bet/Tent/tun/app/Common/hl/src/GHAL/gfxhal.c:1141: undefined reference to `my_key_handler'
/home/bet/Tent/tun/app/Common/hal/src/GHAL/gfxhal.c:1141: undefined reference to `create_window'
collect2: ld returned 1 exit status
make[2]: *** [all] Error 1
make[2]: Leaving directory `/home/bet/Tent/tun/app/Common/c_app'
make[1]: *** [ctv_all] Error 2
make[1]: Leaving directory `/home/bet/Tent/tun/app/Common'
Those are Linking errors, which tell you the linker cannot find definitions for the library you are using.
You will have to link the library to your project.
gcc <your files for compilation> -lLibName
Read this for better understanding.
I still get the error even if
readline library is installed and
-lreadline is added to gcc compiling command.
The root cause of my issue is the order of the libraries/code: -lreadline (and other libraries) should be put right before -o options.

Error Building Clang

I am trying to build Clang on Linux (Amazon's EC2). I am running the make as per the guide at:
http://clang.llvm.org/get_started.html
I am getting the following link error messages:
llvm[2]: Linking Debug+Asserts executable opt
/home/ec2-user/benchmark/build/tools/opt/Debug+Asserts/opt.o: In function `llvm::ParseIR(llvm::MemoryBuffer*, llvm::SMDiagnostic&, llvm::LLVMContext&)':
opt.cpp:(.text._ZN4llvm7ParseIREPNS_12MemoryBufferERNS_12SMDiagnosticERNS_11LLVMContextE[llvm::Pars eIR(llvm::MemoryBuffer*, llvm::SMDiagnostic&, llvm::LLVMContext&)]+0x5f): undefined reference to `llvm::ParseBitcodeFile(llvm::MemoryBuffer*, llvm::LLVMContext&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
collect2: ld returned 1 exit status
make[2]: *** [/home/ec2-user/benchmark/build/Debug+Asserts/bin/opt] Error 1
make[2]: Leaving directory `/home/ec2-user/benchmark/build/tools/opt'
make[1]: *** [opt/.makeall] Error 2
make[1]: Leaving directory `/home/ec2-user/benchmark/build/tools'
make: *** [all] Error 1
Does anyone know what this means?
Edit: I rebuilt the entire project from svn and now I am getting the following error:
COMPILE: clang_linux/asan-i386/i386: /home/ec2-user/benchmark/llvm/projects/compiler-rt/lib/asan/asan_rtl.cc
/home/ec2-user/benchmark/llvm/projects/compiler-rt/lib/asan/asan_rtl.cc:28:10: fatal error: 'new' file not found
#include <new>
^
1 error generated.
make[5]: *** [/home/ec2-user/benchmark/build/tools/clang/runtime/compiler-rt/clang_linux/asan-i386/i386/SubDir.lib__asan/asan_rtl.o] Error 1
make[5]: Leaving directory `/home/ec2-user/benchmark/llvm/projects/compiler-rt'
make[4]: *** [BuildRuntimeLibraries] Error 2
make[4]: Leaving directory `/home/ec2-user/benchmark/build/tools/clang/runtime/compiler-rt'
make[3]: *** [compiler-rt/.makeall] Error 2
make[3]: Leaving directory `/home/ec2-user/benchmark/build/tools/clang/runtime'
make[2]: *** [all] Error 1
make[2]: Leaving directory `/home/ec2-user/benchmark/build/tools/clang'
make[1]: *** [clang/.makeall] Error 2
make[1]: Leaving directory `/home/ec2-user/benchmark/build/tools'
make: *** [all] Error 1
I followed this and I was able to build it successfully in the first shot itself.
I guess, you are hitting issues with your C++ standard library headers. So you need to follow the Step #6 in the above mentioned link!
Start a fresh build and please ensure that you satisfy this prerequisite.

Resources