Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linking of "crud-test" fails on Linux #19

Open
mouse07410 opened this issue Mar 20, 2022 · 2 comments
Open

Linking of "crud-test" fails on Linux #19

mouse07410 opened this issue Mar 20, 2022 · 2 comments

Comments

@mouse07410
Copy link

mouse07410 commented Mar 20, 2022

Ubuntu-20.04 and Centos-8.

$ cmake .. -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=/opt/local
-- The C compiler identification is GNU 8.5.0
-- The CXX compiler identification is GNU 8.5.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found SQLite3: /usr/include (found version "3.26.0") 
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ur20980/src/oatpp-example-crud/build
$ make -j all
[ 12%] Building CXX object CMakeFiles/crud-lib.dir/src/service/UserService.cpp.o
[ 25%] Building CXX object CMakeFiles/crud-lib.dir/src/ErrorHandler.cpp.o
[ 37%] Linking CXX shared library libcrud-lib.so
[ 37%] Built target crud-lib
[ 50%] Building CXX object CMakeFiles/crud-test.dir/test/tests.cpp.o
[ 62%] Building CXX object CMakeFiles/crud-test.dir/test/UserControllerTest.cpp.o
[ 75%] Building CXX object CMakeFiles/crud-exe.dir/src/App.cpp.o
[ 87%] Linking CXX executable crud-test
/usr/bin/ld: CMakeFiles/crud-test.dir/test/tests.cpp.o: undefined reference to symbol '_ZN5oatpp4test8UnitTest3runEi'
/opt/local/lib64/oatpp-1.3.0/liboatpp-test.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/crud-test.dir/build.make:118: crud-test] Error 1
make[1]: *** [CMakeFiles/Makefile2:113: CMakeFiles/crud-test.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[100%] Linking CXX executable crud-exe
[100%] Built target crud-exe
make: *** [Makefile:101: all] Error 2

Fix (or a workaround for Linux, need guards for other OSes) is passing the following linker flag:

 export LDFLAGS="-Wl,--copy-dt-needed-entries"

I suggest adding the above to the CMakeLists.txt file, and/or to the README.md where you describe how to build it from the source.

Here's the author of this fix: https://zhangboyi.gitlab.io/post/2020-09-14-resolve-dso-missing-from-command-line-error/ and https://stackoverflow.com/questions/19901934/libpthread-so-0-error-adding-symbols-dso-missing-from-command-line

@mouse07410
Copy link
Author

I'd appreciate some reaction to this report. Ideally - incorporating the proposed fix. Minimally - just acknowledge.

@lganzzzo
Copy link
Member

Hello @mouse07410 ,

Thanks for the issue and for detailed description!

I'll try to reproduce the issue and after that we can apply the fix.

Regards,
Leonid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants