conan-io / examples

Conan 1.x examples
MIT License
124 stars 66 forks source link

I am a beginner, follow getting_started build md5 exsample failed #92

Closed zuowanbushiwo closed 3 years ago

zuowanbushiwo commented 3 years ago

Hi

packager@1c77a6378e1d:~/examples/libraries/poco/md5$ ./build.sh 
+ rm -rf build
+ mkdir build
+ pushd build
~/examples/libraries/poco/md5/build ~/examples/libraries/poco/md5
+ conan install .. --build=missing
Auto detecting your dev setup to initialize the default profile (/home/packager/.conan/profiles/default)
Found gcc 9
Found clang 11.0
gcc>=5, using the major as version

************************* WARNING: GCC OLD ABI COMPATIBILITY ***********************

Conan detected a GCC version > 5 but has adjusted the 'compiler.libcxx' setting to
'libstdc++' for backwards compatibility.
Your compiler is likely using the new CXX11 ABI by default (libstdc++11).

If you want Conan to use the new ABI for the default profile, run:

    $ conan profile update settings.compiler.libcxx=libstdc++11 default

Or edit '/home/packager/.conan/profiles/default' and set compiler.libcxx=libstdc++11

************************************************************************************

Default settings
    os=Linux
    os_build=Linux
    arch=x86_64
    arch_build=x86_64
    compiler=gcc
    compiler.version=9
    compiler.libcxx=libstdc++
    build_type=Release
*** You can change them in /home/packager/.conan/profiles/default ***
*** Or override with -s compiler='other' -s ...s***

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

poco/1.9.4: Not found in local cache, looking in remotes...
poco/1.9.4: Trying with 'conancenter'...
Downloading conanmanifest.txt completed [0.74k]                                          
Downloading conanfile.py completed [14.36k]                                              
Downloading conan_export.tgz completed [0.30k]                                           
Decompressing conan_export.tgz completed [0.00k]                                         
poco/1.9.4: Downloaded recipe revision 0
pcre/8.45: Not found in local cache, looking in remotes...
pcre/8.45: Trying with 'conancenter'...
Downloading conanmanifest.txt completed [0.17k]                                          
Downloading conanfile.py completed [8.53k]                                               
Downloading conan_export.tgz completed [0.24k]                                           
Decompressing conan_export.tgz completed [0.00k]                                         
pcre/8.45: Downloaded recipe revision 0
bzip2/1.0.8: Not found in local cache, looking in remotes...
bzip2/1.0.8: Trying with 'conancenter'...
Downloading conanmanifest.txt completed [0.25k]                                          
Downloading conanfile.py completed [3.80k]                                               
Downloading conan_export.tgz completed [0.24k]                                           
Decompressing conan_export.tgz completed [0.00k]                                         
bzip2/1.0.8: Downloaded recipe revision 0
zlib/1.2.11: Not found in local cache, looking in remotes...
zlib/1.2.11: Trying with 'conancenter'...
Downloading conanmanifest.txt completed [0.35k]                                          
Downloading conanfile.py completed [5.94k]                                               
Downloading conan_export.tgz completed [0.34k]                                           
Decompressing conan_export.tgz completed [0.00k]                                         
zlib/1.2.11: Downloaded recipe revision 0
expat/2.4.1: Not found in local cache, looking in remotes...
expat/2.4.1: Trying with 'conancenter'...
Downloading conanmanifest.txt completed [0.25k]                                          
Downloading conanfile.py completed [3.56k]                                               
Downloading conan_export.tgz completed [0.26k]                                           
Decompressing conan_export.tgz completed [0.00k]                                         
expat/2.4.1: Downloaded recipe revision 0
sqlite3/3.36.0: Not found in local cache, looking in remotes...
sqlite3/3.36.0: Trying with 'conancenter'...
Downloading conanmanifest.txt completed [0.17k]                                          
Downloading conanfile.py completed [8.50k]                                               
Downloading conan_export.tgz completed [0.24k]                                           
Decompressing conan_export.tgz completed [0.00k]                                         
sqlite3/3.36.0: Downloaded recipe revision 0
openssl/1.1.1k: Not found in local cache, looking in remotes...
openssl/1.1.1k: Trying with 'conancenter'...
Downloading conanmanifest.txt completed [0.26k]                                          
Downloading conanfile.py completed [39.30k]                                              
Downloading conan_export.tgz completed [0.25k]                                           
Decompressing conan_export.tgz completed [0.00k]                                         
openssl/1.1.1k: Downloaded recipe revision 0
conanfile.txt: Installing package
Requirements
    bzip2/1.0.8 from 'conancenter' - Downloaded
    expat/2.4.1 from 'conancenter' - Downloaded
    openssl/1.1.1k from 'conancenter' - Downloaded
    pcre/8.45 from 'conancenter' - Downloaded
    poco/1.9.4 from 'conancenter' - Downloaded
    sqlite3/3.36.0 from 'conancenter' - Downloaded
    zlib/1.2.11 from 'conancenter' - Downloaded
Packages
    bzip2/1.0.8:da606cf731e334010b0bf6e85a2a6f891b9f36b0 - Download
    expat/2.4.1:c215f67ac7fc6a34d9d0fb90b0450016be569d86 - Download
    openssl/1.1.1k:6af9cc7cb931c5ad942174fd7838eb655717c709 - Download
    pcre/8.45:87087120c448298530c012e627c1a0b8f062586d - Download
    poco/1.9.4:b82a00d81a86b06045a9d9b8b1b627c8f353a65e - Download
    sqlite3/3.36.0:c0cc1a2703aaeb2777d683089def26db57cf15e6 - Download
    zlib/1.2.11:6af9cc7cb931c5ad942174fd7838eb655717c709 - Download

Installing (downloading, building) binaries...
bzip2/1.0.8: Retrieving package da606cf731e334010b0bf6e85a2a6f891b9f36b0 from remote 'conancenter' 
Downloading conanmanifest.txt completed [0.32k]                                          
Downloading conaninfo.txt completed [0.43k]                                              
Downloading conan_package.tgz completed [97.19k]                                         
Decompressing conan_package.tgz completed [0.00k]                                        
bzip2/1.0.8: Package installed da606cf731e334010b0bf6e85a2a6f891b9f36b0
bzip2/1.0.8: Downloaded package revision 0
expat/2.4.1: Retrieving package c215f67ac7fc6a34d9d0fb90b0450016be569d86 from remote 'conancenter' 
Downloading conanmanifest.txt completed [0.32k]                                          
Downloading conaninfo.txt completed [0.42k]                                              
Downloading conan_package.tgz completed [114.09k]                                        
Decompressing conan_package.tgz completed [0.00k]                                        
expat/2.4.1: Package installed c215f67ac7fc6a34d9d0fb90b0450016be569d86
expat/2.4.1: Downloaded package revision 0
openssl/1.1.1k: Retrieving package 6af9cc7cb931c5ad942174fd7838eb655717c709 from remote 'conancenter' 
Downloading conanmanifest.txt completed [6.30k]                                          
Downloading conaninfo.txt completed [2.27k]                                              
Downloading conan_package.tgz completed [3908.40k]                                       
Decompressing conan_package.tgz completed [0.00k]                                        
openssl/1.1.1k: Package installed 6af9cc7cb931c5ad942174fd7838eb655717c709
openssl/1.1.1k: Downloaded package revision 0
sqlite3/3.36.0: Retrieving package c0cc1a2703aaeb2777d683089def26db57cf15e6 from remote 'conancenter' 
Downloading conanmanifest.txt completed [0.39k]                                          
Downloading conaninfo.txt completed [1.51k]                                              
Downloading conan_package.tgz completed [1527.19k]                                       
Decompressing conan_package.tgz completed [0.00k]                                        
sqlite3/3.36.0: Package installed c0cc1a2703aaeb2777d683089def26db57cf15e6
sqlite3/3.36.0: Downloaded package revision 0
zlib/1.2.11: Retrieving package 6af9cc7cb931c5ad942174fd7838eb655717c709 from remote 'conancenter' 
Downloading conanmanifest.txt completed [0.25k]                                          
Downloading conaninfo.txt completed [0.41k]                                              
Downloading conan_package.tgz completed [88.86k]                                         
Decompressing conan_package.tgz completed [0.00k]                                        
zlib/1.2.11: Package installed 6af9cc7cb931c5ad942174fd7838eb655717c709
zlib/1.2.11: Downloaded package revision 0
pcre/8.45: Retrieving package 87087120c448298530c012e627c1a0b8f062586d from remote 'conancenter' 
Downloading conanmanifest.txt completed [0.50k]                                          
Downloading conaninfo.txt completed [1.17k]                                              
Downloading conan_package.tgz completed [536.98k]                                        
Decompressing conan_package.tgz completed [0.00k]                                        
pcre/8.45: Package installed 87087120c448298530c012e627c1a0b8f062586d
pcre/8.45: Downloaded package revision 0
poco/1.9.4: Retrieving package b82a00d81a86b06045a9d9b8b1b627c8f353a65e from remote 'conancenter' 
Downloading conanmanifest.txt completed [48.75k]                                         
Downloading conaninfo.txt completed [4.60k]                                              
Downloading conan_package.tgz completed [4954.73k]                                       
Decompressing conan_package.tgz completed [0.00k]                                        
poco/1.9.4: Package installed b82a00d81a86b06045a9d9b8b1b627c8f353a65e
poco/1.9.4: Downloaded package revision 0
bzip2/1.0.8: Appending PATH environment variable: /home/packager/.conan/data/bzip2/1.0.8/_/_/package/da606cf731e334010b0bf6e85a2a6f891b9f36b0/bin
sqlite3/3.36.0: Appending PATH env var with : /home/packager/.conan/data/sqlite3/3.36.0/_/_/package/c0cc1a2703aaeb2777d683089def26db57cf15e6/bin
pcre/8.45: Appending PATH environment variable: /home/packager/.conan/data/pcre/8.45/_/_/package/87087120c448298530c012e627c1a0b8f062586d/bin
conanfile.txt: Generator txt created conanbuildinfo.txt
conanfile.txt: Generator cmake created conanbuildinfo.cmake
conanfile.txt: Aggregating env generators
conanfile.txt: Generated conaninfo.txt
conanfile.txt: Generated graphinfo
+ cmake .. -DCMAKE_BUILD_TYPE=Release
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Conan: Adjusting output directories
-- Conan: Using cmake global configuration
-- Conan: Adjusting default RPATHs Conan policies
-- Conan: Adjusting language standard
-- Current conanbuildinfo.cmake directory: /home/packager/examples/libraries/poco/md5/build
-- Conan: Compiler GCC>=5, checking major version 9
-- Conan: Checking correct version: 9
-- Configuring done
-- Generating done
-- Build files have been written to: /home/packager/examples/libraries/poco/md5/build
+ cmake --build .
Scanning dependencies of target md5
[ 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+0xad): 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:76: CMakeFiles/md5.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
packager@1c77a6378e1d:~/examples/libraries/poco/md5$ 
memsharded commented 3 years ago

Hi @zuowanbushiwo

It seems you are ignoring the warning about compiler.libcxx=libstdc++:

You have instructions there of something that you can try:

$ conan profile update settings.compiler.libcxx=libstdc++11 default

Please try that.

zuowanbushiwo commented 3 years ago

@memsharded Thanks!
When I run that commad for the first time, I get the following error:

packager@4572e3152c19:~/examples/libraries/poco/md5$ conan profile update settings.compiler.libcxx=libstdc++11 default
ERROR: Profile not found: default

When I used ./build.sh to compile, the above link error occurred again, then use the following command conan profile update settings.compiler.libcxx=libstdc++11 default This time there is no error, and then I will use . /build.sh again , then the program runs success.

I have one other question: These packages downloaded by build md5 example:

     bzip2/1.0.8
     expat/2.4.1
     openssl/1.1.1k
     pcre/8.45
     poco/1.9.4
     sqlite3/3.36.0
     zlib/1.2.11

my other projects can be found through find_package(OpenSSL REQUIRED) or PKG_CHECK_MODULES(ZLIB zlib REQUIRED) called by those method?

best regards

memsharded commented 3 years ago

It is because the default profile doesn't exist until it is required the first time. You can force its creation with conan profile new default --detect.

my other projects can be found through find_package(OpenSSL REQUIRED) or PKG_CHECK_MODULES(ZLIB zlib REQUIRED) called by those method?

That depends on the generator that you use. The getting started uses the cmake generator that requires to add the include(....../conanbuildinfo.cmake), and then use the CONAN_LIBS variable or CONAN_PKG::xxxx variables.

If you use the new CMakeDeps generator, for example, Conan will generate for you xxx-config.cmake scripts, and then you can use with find_package(xxxx REQUIRED) (need to be used together with CMakeToolchain and CMake from https://docs.conan.io/en/latest/reference/conanfile/tools.html)

zuowanbushiwo commented 3 years ago

@memsharded Thanks , Can you give me some guidance on this issue https://github.com/conan-io/cmake-conan/issues/356 ? I need some complicated profiles, conanfile.txt and connanfile.y to solve this error? Do you know any examples you can refer to? best regards

memsharded commented 3 years ago

My advice for this would be to avoid using cmake-conan integration until you gain some experience and understand better conan.

If this issue was responded correctly and it works, we can close it and follow conversation in the other one, thanks!