linker error while osg build osgviewer - linker

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.

Related

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

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.

Linking SDL2 with CMake inside of CLion in Linux

I've been effortlessly trying to link SDL2 library to my CLion project. I've downloaded the FindSDL2 script, but I'm still getting undefined reference to an SDL function.
Here's my CMakeLists.txt
cmake_minimum_required(VERSION 3.12)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${project_SOURCE_DIR}/cmake")
project(SDL_Test C)
set(CMAKE_C_STANDARD 99)
find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIR})
add_executable(SDL_Test main.c)
target_link_libraries(SDL_Test ${SDL2_LIBRARY})
After trying to invoke SDL_Init(SDL_INIT_VIDEO) function I'm getting an undefined reference error:
[50%] Building C object CMakeFiles/SDL_Test.dir/main.c.o
[100%] Linking C executable SDL_Test
/bin/ld: CMakeFiles/SDL_Test.dir/main.c.o: in function `main':
/home/bartek/CLionProjects/SDL_Test/main.c:5: undefined reference to `SDL_Init'
collect2: error: ld returned 1 exit status
make[3]: *** [CMakeFiles/SDL_Test.dir/build.make:84: SDL_Test] Error 1
make[2]: *** [CMakeFiles/Makefile2:73: CMakeFiles/SDL_Test.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:85: CMakeFiles/SDL_Test.dir/rule] Error 2
make: *** [Makefile:118: SDL_Test] Error 2

Cannot open output file : Is a directory collect2: ld returned 1 exit status

I am using CLion code editor.
I have such structure of project:
This is the content of CMakeLists.txt:
cmake_minimum_required(VERSION 3.4)
project(FirstAgent)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.c)
add_executable(FirstAgent ${SOURCE_FILES})
target_link_libraries(FirstAgent simgrid)
But when I run my program in the code editor the error occur:
/usr/bin/ld: cannot open output file FirstAgent: Is a directory
collect2: error: ld returned 1 exit status
make[3]: *** [FirstAgent] Error 1
make[2]: *** [CMakeFiles/FirstAgent.dir/all] Error 2
make[1]: *** [CMakeFiles/FirstAgent.dir/rule] Error 2
make: *** [FirstAgent] Error 2
How can I avoid it?
You can try setting an output directory, so that the binaries are stored elsewhere:
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)

MacPorts linker (ld) not found

I'm trying to compile cgminer on Mac, and the compilation cannot complete, citing "ld: library not found for -lrt"
Exact terminal output:
CCLD cgminer
ld: library not found for -lrt
collect2: ld returned 1 exit status
make[1]: *** [cgminer] Error 1
make: *** [install-recursive] Error 1
Any solution for how to install the linker library via command line?

'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.

Resources