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

[bug] linker can't find downloaded libraries #8417

Closed
NoSpooksAllowed opened this issue Jan 31, 2021 · 7 comments
Closed

[bug] linker can't find downloaded libraries #8417

NoSpooksAllowed opened this issue Jan 31, 2021 · 7 comments

Comments

@NoSpooksAllowed
Copy link

NoSpooksAllowed commented Jan 31, 2021

Hello, I just tried to build test example from getting started page in conan, but for some reason linker does not see downloaded libraries, even that according to conan they were downloaded

Environment Details (include every applicable attribute)

  • Operating System+version: Ubuntu 20.10
  • Compiler+version: g++ 10.2.0
  • Conan version: 1.33.0
  • Python version: 3.8.6

Steps to reproduce (Include if Applicable)

Just exact same steps from this example https://docs.conan.io/en/latest/getting_started.html

Logs (Executed commands with output) (Include/Attach if Applicable)

user@user:~/Documents/cpp/conan-test/build$ cmake --build .
gmake[1]: Entering directory '/home/user/Documents/cpp/conan-test/build'
gmake[2]: Entering directory '/home/user/Documents/cpp/conan-test/build'
Scanning dependencies of target md5
gmake[2]: Leaving directory '/home/user/Documents/cpp/conan-test/build'
gmake[2]: Entering directory '/home/user/Documents/cpp/conan-test/build'
[ 50%] Building CXX object CMakeFiles/md5.dir/md5.cpp.o
[100%] Linking CXX executable bin/md5
/usr/bin/ld: CMakeFiles/md5.dir/md5.cpp.o: in function main': md5.cpp:(.text.startup+0xb5): undefined reference to Poco::DigestEngine::digestToHex[abi:cxx11](std::vector<unsigned char, std::allocator > const&)'
collect2: error: ld returned 1 exit status
gmake[2]: *** [CMakeFiles/md5.dir/build.make:84: bin/md5] Error 1
gmake[2]: Leaving directory '/home/user111/Documents/cpp/conan-test/build'
gmake[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/md5.dir/all] Error 2
gmake[1]: Leaving directory '/home/user111/Documents/cpp/conan-test/build'
gmake: *** [Makefile:84: all] Error 2

@solvingj
Copy link
Contributor

solvingj commented Feb 1, 2021

Can you post the generated conanbuildinfo.cmake file?

Also, can you post the section from your CMakeLists.txt where you do include() on it, just to confirm you're including it correctly?

@NoSpooksAllowed
Copy link
Author

conanbuildinfo.cmake

https://pastebin.com/bYNAK3DL

CMakeLists.txt

https://pastebin.com/TqXh2N7L

@solvingj
Copy link
Contributor

solvingj commented Feb 1, 2021

Everything looks good in these files.

Line 43 of conanbuildinfo.cmake is here:

set(CONAN_LIB_DIRS_POCO "/home/user111/.conan/data/poco/1.9.4/_/_/package/05430cbc4154f78d465015e2e36dc71b2d92c2d8/lib")

Line 49 is here:

set(CONAN_LIBS_POCO PocoZip PocoNetSSL PocoDataSQLite PocoRedis PocoUtil PocoMongoDB PocoXML PocoCrypto PocoEncodings PocoNet PocoData PocoJSON PocoFoundation)

So, in theory, there should be a PocoCrypto library file (.a or .so) in the lib directory shown. Lets verify that.

Then, there's this line from CMakeLists.txt:

target_link_libraries(md5 ${CONAN_LIBS})

In theory, Cmake should be generating a Makefile with the corresponding path and passing it to the linker with -l ...

It would be helpful to see the actual linker command or the flags. You can tell CMake and make to be more verbose using this CMake variable (and then re-running your cmake command):
https://cmake.org/cmake/help/latest/variable/CMAKE_VERBOSE_MAKEFILE.html

Alternatively, you can just look into the CMakeFiles directory for flags.make which makes it very easy to find exactly what flags will be sent to the compiler and linker.

We need to figure out where the ball is being dropped exactly.

@NoSpooksAllowed
Copy link
Author

Well, I checked a folder, and all these libraries in there.

Here is more verbose output:

https://pastebin.com/5VQYZqt7

@solvingj
Copy link
Contributor

solvingj commented Feb 2, 2021

Ok, so now we have it narrowed to this line:

/usr/bin/c++         -rdynamic CMakeFiles/md5.dir/md5.cpp.o  -o bin/md5   -L/home/user111/.conan/data/poco/1.9.4/_/_/package/05430cbc4154f78d465015e2e36dc71b2d92c2d8/lib  -L/home/user111/.conan/data/pcre/8.41/_/_/package/d7ce5e9581d2c53c1703b35527fc2b00e0fc00f8/lib  -L/home/user111/.conan/data/expat/2.2.10/_/_/package/19729b9559f3ae196cad45cb2b97468ccb75dcd1/lib  -L/home/user111/.conan/data/sqlite3/3.33.0/_/_/package/0afebc877508f94e1a69d4ab9e6230d79a6ac293/lib  -L/home/user111/.conan/data/openssl/1.1.1h/_/_/package/19729b9559f3ae196cad45cb2b97468ccb75dcd1/lib  -L/home/user111/.conan/data/bzip2/1.0.8/_/_/package/91a8b22c2c5a149bc617cfc06cdd21bf23b12567/lib  -L/home/user111/.conan/data/zlib/1.2.11/_/_/package/19729b9559f3ae196cad45cb2b97468ccb75dcd1/lib  -Wl,-rpath,/home/user111/.conan/data/poco/1.9.4/_/_/package/05430cbc4154f78d465015e2e36dc71b2d92c2d8/lib:/home/user111/.conan/data/pcre/8.41/_/_/package/d7ce5e9581d2c53c1703b35527fc2b00e0fc00f8/lib:/home/user111/.conan/data/expat/2.2.10/_/_/package/19729b9559f3ae196cad45cb2b97468ccb75dcd1/lib:/home/user111/.conan/data/sqlite3/3.33.0/_/_/package/0afebc877508f94e1a69d4ab9e6230d79a6ac293/lib:/home/user111/.conan/data/openssl/1.1.1h/_/_/package/19729b9559f3ae196cad45cb2b97468ccb75dcd1/lib:/home/user111/.conan/data/bzip2/1.0.8/_/_/package/91a8b22c2c5a149bc617cfc06cdd21bf23b12567/lib:/home/user111/.conan/data/zlib/1.2.11/_/_/package/19729b9559f3ae196cad45cb2b97468ccb75dcd1/lib -lPocoNetSSL -lPocoZip -lPocoUtil -lPocoMongoDB -lPocoDataSQLite -lPocoRedis -lPocoCrypto -lPocoEncodings -lPocoNet -lPocoJSON -lPocoXML -lPocoData -lPocoFoundation -lpcreposix -lpcre -lpcre16 -lpcre32 -lexpat -lsqlite3 -lssl -lcrypto -lbz2 -lz -lrt -ldl -lpthread 

/usr/bin/ld: CMakeFiles/md5.dir/md5.cpp.o: in function `main':
md5.cpp:(.text+0x9d): undefined reference to `Poco::DigestEngine::digestToHex[abi:cxx11](std::vector<unsigned char, std::allocator<unsigned char> > const&)'

@solvingj
Copy link
Contributor

solvingj commented Feb 2, 2021

Seems this is duplicate issue:

conan-io/examples#40

It seems you need to add this line to your profile:

compiler.libcxx=libstdc++11

Quote from @memsharded regarding the background:

Conan by default uses compiler.libcxx=libstdc++ for wider compatibility in all distros and gcc versions
If you are running a modern distro and gcc >= 5 you need to change it to libstdc++11
But if you are running an older distro (even with gcc >= 5) or gcc < 5, then you need to keep the libstdc++

@NoSpooksAllowed
Copy link
Author

NoSpooksAllowed commented Feb 2, 2021

It's working now. Thank you so much!

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