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

undefined reference to Poco::DigestEngine #40

Open
BlankRain opened this issue Feb 1, 2020 · 5 comments
Open

undefined reference to Poco::DigestEngine #40

BlankRain opened this issue Feb 1, 2020 · 5 comments

Comments

@BlankRain
Copy link

first, git clone https://github.com/conan-io/examples.git
and then cd into libraries/poco/md5
run ./build.sh

got error like that:

+ cmake --build .
Scanning dependencies of target md5
[ 50%] Building CXX object CMakeFiles/md5.dir/md5.cpp.o
[100%] Linking CXX executable bin/md5
CMakeFiles/md5.dir/md5.cpp.o: In function `main':

md5.cpp:(.text.startup+0x9b): undefined reference to `Poco::DigestEngine::digestToHex[abi:cxx11](std::vector<unsigned char, std::allocator > const&)'
collect2: error: ld returned 1 exit status
CMakeFiles/md5.dir/build.make:83: recipe for target 'bin/md5' failed
make[2]: *** [bin/md5] Error 1
CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/md5.dir/all' failed
make[1]: *** [CMakeFiles/md5.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

@memsharded
Copy link
Member

Hi @BlankRain

First, we would need a bit more of information, typically the OS, conan versions, etc.

I would say that you are hitting the issue pointed in point 5 of Getting Started (https://docs.conan.io/en/latest/getting_started.html) as "important":

if you are using GCC compiler >= 5.1, Conan will set the compiler.libcxx to the old ABI for backwards compatibility.

Basically conan default profile is using libstdc++ (it is the most compatible one), but you have libstdc++11 as default in your system. Please change the default profile as recommended in the docs, and repeat.

Also, it is better if you run the commands, not use the build.sh scripts, which are there basically for CI purposes.

Please let me know if this helps.

@rootifera
Copy link

Hello,

I'm having the same . Instead of creating a new ticket I'll write here. I hope that's OK.

[ 50%] Linking CXX executable bin/md5
/usr/bin/ld: CMakeFiles/md5.dir/md5.cpp.o: in function `main':
md5.cpp:(.text.startup+0x88): undefined reference to `Poco::DigestEngine::digestToHex[abi:cxx11](std::vector<unsigned char, std::allocator<unsigned char> > const&)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/md5.dir/build.make:84: bin/md5] Error 1
make[1]: *** [CMakeFiles/Makefile2:73: CMakeFiles/md5.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

OS: Debian 10

Here's the profile details

[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=gcc
compiler.version=8
compiler.libcxx=libstdc++11
build_type=Release
[options]
[build_requires]
[env]

I'm fairly new at C++ and I just wanted to check the package manager options so I have an idea for later, but I'm pretty much got stuck at "getting started". Can you please advise?

Thanks!

@memsharded
Copy link
Member

Hi @rootifera

Did you run conan install and make sure that you removed the temporary build scripts from cmake, and then run cmake again to build the thing?

Is it possible that you are running in an older distro? (that might have the problem that you still have a libstdc++ standard library instead of the libstdc++11 one that typically your gcc 8 compiler would have. Please tell me, thanks!

@bill-luu
Copy link

bill-luu commented May 7, 2020

I had the same issues as the other two, using Elementary OS 5.0 Juno (Based on Ubuntu 18.04.2)

As suggested, I fixed it by editing ~/.conan/profiles/default and editing the line compilter.libcxx line to compiler.libcxx=libstdc++11

The entire file:

[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=gcc
compiler.version=7
compiler.libcxx=libstdc++11
build_type=Release
[options]
[build_requires]
[env]

@memsharded
Copy link
Member

HI @bill-luu

Glad that you fixed it. We will be fixing this for Conan 2.0 (now it will be breaking).
To summarize:

  • 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++

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

4 participants