conan create failed with ld: symbol(s) not found for architecture x86_64

Created on 6 Dec 2017  路  24Comments  路  Source: conan-io/conan

Hi,
I'm trying to learn how to create package using conan and make this toy example armadillo.

Following the tutorial, by conan create demo/testing the package seems to be built and installed successfully however the test failed with

clang: warning: libstdc++ is deprecated; move to libc++ [-Wdeprecated]
Undefined symbols for architecture x86_64:
  "_ddot_", referenced from:
      void arma::syrk_vec<false, false, false>::apply<double, arma::Mat<double> >(arma::Mat<double>&, arma::Mat<double> const&, double, double) in example.cpp.o
  "_dgemm_", referenced from:
      void arma::gemm<false, true, false, false>::apply_blas_type<double, arma::Mat<double>, arma::Mat<double> >(arma::Mat<double>&, arma::Mat<double> const&, arma::Mat<double> const&, double, double) in example.cpp.o
  "_dgemv_", referenced from:
      void arma::glue_times::apply<double, false, true, false, arma::Mat<double>, arma::Mat<double> >(arma::Mat<double>&, arma::Mat<double> const&, arma::Mat<double> const&, double) in example.cpp.o
  "_dsyrk_", referenced from:
      void arma::syrk<false, false, false>::apply_blas_type<double, arma::Mat<double> >(arma::Mat<double>&, arma::Mat<double> const&, double, double) in example.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [bin/example] Error 1
make[1]: *** [CMakeFiles/example.dir/all] Error 2
make: *** [all] Error 2
ERROR: PROJECT: Error in build() method, line 12
    cmake.build()
    ConanException: Error 512 while executing cmake --build './' '--' '-j4'

I'm on a macOS 10.12.6 (16G1036) with conan 0.29.2. Can you give me some hints to solve this? Thank you!

question

Most helpful comment

@danimtb Thanks. I'm a bit new to C++ and conan though having a Python background. If I made anything stupid, please forgive me.馃檨

All 24 comments

I am not sure what is happening. I have found another package for Armadillo in bintray, it could have some hints: https://bintray.com/slidewavellc/conan-libs/Armadillo%3Aslidewave

You might want to check:

  • The default libcxx you have in your default profile (conan profile show default, and other commands or edit file to change it)
  • Use ``conan create user/testing ... -s compiler=apple-clang -s compiler.libcxx=libc++
  • Check what the build is doing regarding the stdlib, if it is being managed or not.

I'll try to come back later today and check deeper. Cheers!

Thanks for your reply. conan profile show default gives

Configuration for profile default:

[settings]
    os: Macos
    arch: x86_64
    compiler: apple-clang
    compiler.version: 9.0
    compiler.libcxx: libc++
    build_type: Release
[options]
[build_requires]
[env]
[scopes]
    dev=True

and I changed compiler.libcxx=libstdc++ to compiler.libcxx=libc++ and nothing changed though. The full log is here

 $ conan create demo/testing
armadillo/8.3@demo/testing: Exporting package recipe
armadillo/8.3@demo/testing: The stored package has not changed
armadillo/8.3@demo/testing: Installing package
Requirements
    armadillo/8.3@demo/testing from local
Packages
    armadillo/8.3@demo/testing:3cfade032d90e40671f831047a4b021865f8396f

armadillo/8.3@demo/testing: WARN: Forced build from source
armadillo/8.3@demo/testing: Building your package in /Users/user/.conan/data/armadillo/8.3/demo/testing/build/3cfade032d90e40671f831047a4b021865f8396f
armadillo/8.3@demo/testing: Copying sources to build folder
armadillo/8.3@demo/testing: Generator cmake created conanbuildinfo.cmake
armadillo/8.3@demo/testing: Calling build()
-- The CXX compiler identification is AppleClang 9.0.0.9000038
-- The C compiler identification is AppleClang 9.0.0.9000038
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring Armadillo 8.300.0
-- CMAKE_SYSTEM_NAME          = Darwin
-- CMAKE_CXX_COMPILER_ID      = Clang
-- CMAKE_CXX_COMPILER_VERSION = 9.0.0.9000038
-- CMAKE_COMPILER_IS_GNUCXX   =
-- BUILD_SHARED_LIBS          = ON
-- DETECT_HDF5                = ON
-- MacOS X detected. Added '-framework Accelerate' to compiler flags
-- Clang compiler on MacOS X detected. Added '-stdlib=libc++' to compiler flags
-- Found PkgConfig: /usr/local/bin/pkg-config (found version "0.29.2")
-- Checking for module 'hdf5'
--   No package 'hdf5' found
-- HDF5_FOUND =
-- ARPACK_FOUND = NO
-- Looking for SuperLU version 5
-- Could not find SuperLU
-- SuperLU_FOUND = NO
--
-- *** Armadillo wrapper library will use the following libraries:
-- *** ARMA_LIBS = -framework Accelerate
--
-- Copying /Users/user/.conan/data/armadillo/8.3/demo/testing/build/3cfade032d90e40671f831047a4b021865f8396f/armadillo-8.300.0/include/ to /Users/user/.conan/data/armadillo/8.3/demo/testing/build/3cfade032d90e40671f831047a4b021865f8396f/tmp/include/
-- Generating /Users/user/.conan/data/armadillo/8.3/demo/testing/build/3cfade032d90e40671f831047a4b021865f8396f/tmp/include/config.hpp
-- Generating /Users/user/.conan/data/armadillo/8.3/demo/testing/build/3cfade032d90e40671f831047a4b021865f8396f/armadillo-8.300.0/examples/Makefile
-- CMAKE_CXX_FLAGS           =  -stdlib=libc++
-- CMAKE_SHARED_LINKER_FLAGS =
-- CMAKE_REQUIRED_INCLUDES   =
--
-- CMAKE_INSTALL_PREFIX     = /Users/user/.conan/data/armadillo/8.3/demo/testing/package/3cfade032d90e40671f831047a4b021865f8396f
-- CMAKE_INSTALL_LIBDIR     = lib
-- CMAKE_INSTALL_INCLUDEDIR = include
-- CMAKE_INSTALL_DATADIR    = share
-- CMAKE_INSTALL_BINDIR     = bin
-- Generating '/Users/user/.conan/data/armadillo/8.3/demo/testing/build/3cfade032d90e40671f831047a4b021865f8396f/ArmadilloConfig.cmake'
-- Generating '/Users/user/.conan/data/armadillo/8.3/demo/testing/build/3cfade032d90e40671f831047a4b021865f8396f/ArmadilloConfigVersion.cmake'
-- Generating '/Users/user/.conan/data/armadillo/8.3/demo/testing/build/3cfade032d90e40671f831047a4b021865f8396f/InstallFiles/ArmadilloConfig.cmake'
-- Generating '/Users/user/.conan/data/armadillo/8.3/demo/testing/build/3cfade032d90e40671f831047a4b021865f8396f/InstallFiles/ArmadilloConfigVersion.cmake'
-- Copying /Users/user/.conan/data/armadillo/8.3/demo/testing/build/3cfade032d90e40671f831047a4b021865f8396f/armadillo-8.300.0/misc/ to /Users/user/.conan/data/armadillo/8.3/demo/testing/build/3cfade032d90e40671f831047a4b021865f8396f/tmp/misc/
-- Generating '/Users/user/.conan/data/armadillo/8.3/demo/testing/build/3cfade032d90e40671f831047a4b021865f8396f/tmp/misc/armadillo.pc'
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    CONAN_COMPILER
    CONAN_COMPILER_VERSION
    CONAN_EXPORTED
    CONAN_LIBCXX


-- Build files have been written to: /Users/user/.conan/data/armadillo/8.3/demo/testing/build/3cfade032d90e40671f831047a4b021865f8396f
Scanning dependencies of target armadillo
[ 50%] Building CXX object CMakeFiles/armadillo.dir/src/wrapper.cpp.o
[100%] Linking CXX shared library libarmadillo.dylib
[100%] Built target armadillo
armadillo/8.3@demo/testing: Package '3cfade032d90e40671f831047a4b021865f8396f' built
armadillo/8.3@demo/testing: Build folder /Users/user/.conan/data/armadillo/8.3/demo/testing/build/3cfade032d90e40671f831047a4b021865f8396f
armadillo/8.3@demo/testing: Generated conaninfo.txt
armadillo/8.3@demo/testing: Generated conanbuildinfo.txt
armadillo/8.3@demo/testing: Generating the package
armadillo/8.3@demo/testing: Package folder /Users/user/.conan/data/armadillo/8.3/demo/testing/package/3cfade032d90e40671f831047a4b021865f8396f
armadillo/8.3@demo/testing: Calling package()
armadillo/8.3@demo/testing package(): Copied 1 '' files: armadillo
armadillo/8.3@demo/testing package(): Copied 3 '.dylib' files: libarmadillo.8.30.0.dylib, libarmadillo.8.dylib, libarmadillo.dylib
armadillo/8.3@demo/testing package(): Copied 512 '.hpp' files
armadillo/8.3@demo/testing: Package '3cfade032d90e40671f831047a4b021865f8396f' created
armadillo/8.3@demo/testing: Testing with 'test_package'
armadillo/8.3@demo/testing test package: Installing dependencies
armadillo/8.3@demo/testing: Already installed!
armadillo/8.3@demo/testing test package: Generator cmake created conanbuildinfo.cmake
armadillo/8.3@demo/testing test package: Generator txt created conanbuildinfo.txt
armadillo/8.3@demo/testing test package: Generated conaninfo.txt
armadillo/8.3@demo/testing test package imports(): Copied 3 '.dylib' files: libarmadillo.8.30.0.dylib, libarmadillo.8.dylib, libarmadillo.dylib
armadillo/8.3@demo/testing test package: Running build()
-- The CXX compiler identification is AppleClang 9.0.0.9000038
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/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: called by CMake conan helper
-- Conan: Using cmake global configuration
-- Conan: Adjusting default RPATHs Conan policies
-- Conan C++ stdlib: libc++
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/user/git/new/test_package/build/4d701b41d780850296d00891ed33cda800fce7c3
Scanning dependencies of target example
[ 50%] Building CXX object CMakeFiles/example.dir/example.cpp.o
[100%] Linking CXX executable bin/example
Undefined symbols for architecture x86_64:
  "_ddot_", referenced from:
      void arma::syrk_vec<false, false, false>::apply<double, arma::Mat<double> >(arma::Mat<double>&, arma::Mat<double> const&, double, double) in example.cpp.o
  "_dgemm_", referenced from:
      void arma::gemm<false, true, false, false>::apply_blas_type<double, arma::Mat<double>, arma::Mat<double> >(arma::Mat<double>&, arma::Mat<double> const&, arma::Mat<double> const&, double, double) in example.cpp.o
  "_dgemv_", referenced from:
      void arma::glue_times::apply<double, false, true, false, arma::Mat<double>, arma::Mat<double> >(arma::Mat<double>&, arma::Mat<double> const&, arma::Mat<double> const&, double) in example.cpp.o
  "_dsyrk_", referenced from:
      void arma::syrk<false, false, false>::apply_blas_type<double, arma::Mat<double> >(arma::Mat<double>&, arma::Mat<double> const&, double, double) in example.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [bin/example] Error 1
make[1]: *** [CMakeFiles/example.dir/all] Error 2
make: *** [all] Error 2
ERROR: PROJECT: Error in build() method, line 12
    cmake.build()
    ConanException: Error 512 while executing cmake --build './' '--' '-j4'

The link.txt contains /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -stdlib=libc++ -O3 -DNDEBUG -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/example.dir/example.cpp.o -o bin/example -L/Users/user/.conan/data/armadillo/8.3/demo/testing/package/3cfade032d90e40671f831047a4b021865f8396f/lib -larmadillo

and if I manually run g++ -o example example.cpp -L/Users/user/.conan/data/armadillo/8.3/demo/testing/package/3cfade032d90e40671f831047a4b021865f8396f/lib -larmadillo in test_package, everything seems fine.

Are you including the conanbuildinfo.cmake and calling conan_basic_setup() in the CMakeLists.txt from the test_package directory?

I think I did. Since the file is auto generated ...

project(PackageTest CXX)
cmake_minimum_required(VERSION 2.8.12)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

add_executable(example example.cpp)
target_link_libraries(example ${CONAN_LIBS})

# CTest is a testing tool that can be used to test your project.
# enable_testing()
# add_test(NAME example
#          WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
#          COMMAND example)

Yes, sorry, now I see the conan traces. Now the error is purely a linker error because of some missing symbol. Googling, can it be a missing dependency to other library like this lapack or something? http://www.netlib.org/lapack/explore-html/d1/d54/group__double__blas__level3_gaeda3cbd99c8fb834a60a6412878226e1.html

Maybe @danimtb can help us with this. He has been working in related libraries.

@lasote But if I manually run the g++ as I posted previously, everything just fine.

@lasote I'm sorry I've made a mistake that I've a global installed version. Manually running the command gave the same error. However, manually adding the blas to target_link_libraries in the CMakeLists.txt of the test_package demo solve the problem. Thank you very much.

However, when I use the global version armadillo, simply g++ -o example example.cpp -larmadillo works as given in section 6 here. Why do we add blas when using conan?

Hi @Yevgnen!

I have found this in armadillo's CMakeLists.tx that might be related to the problem you are reporting.

Maybe you armadillo installation was compiled without that ARMA_USE_WRAPPER flag

Hi @danimtb !

You found it! Thanks for you information. But I think the global version and the conan should have the same flags since I don't change any of them...馃槄

But I think the global version and the conan should have the same flags since I don't change any of them...馃槄

I don't understand, the armadillo recipe is yours, right? probably the script building the "global" armadillo sets the flag and your recipe doesn't. Add it to the recipe and the behavior will be the same.

Is that mean conan won't care about the CMakeList.txt of the package?

@Yevgnen I am trying to replicate your problem. I will come back to you in a moment, just let me check

@danimtb Thanks. I'm a bit new to C++ and conan though having a Python background. If I made anything stupid, please forgive me.馃檨

@Yevgnen no problem! we are here to help. I meant that you can pass a definition (in your recipe) to the original CMakelists to adjust the needed behavior.

I got a bit confused...

set(ARMA_USE_WRAPPER true) seems to be the default behavior and the global version thus need not the blas or lapack link option as g++ -o example example.cpp -larmadillo actually works . So I the conan version should behavior the same...

ok @Yevgnen here is the thing:

Armadillo library optionally depends on BLAS and LAPACK libraries which are NOT packaged inside Armadillo, so the Conan Package you are referencing does not have BLAS nor LAPACK libraries.

Armadillo can work without LAPACK and BLAS, but you need to commet some defined variables(At least in Windows -I am testing this in a Windows machine-)

You said you had a global installation or armadillo, so in that case when you manually compile the test in test_package you may be linking with your global installation of Armadillo which already has the LAPACK and BLAS dependencies resolved.

HINT: Armadillo examples in windows need LAPACK and BLAS dlls that are actually packed inside the armadillo repo

I will try to set ARMA_USE_LAPACK, ARMA_USE_BLAS, ARMA_USE_ARPACK, ARMA_USE_SUPERLU to false via CMake and see if we can compile the tests without the need to link to BLAS and LAPACK

So ARMA_USE_LAPACK, ARMA_USE_BLAS, ARMA_USE_ARPACK, ARMA_USE_SUPERLU variables are set to false in the CMakeLists.txt

No sure what's happening here...

OK, I have found the trick.

Armadillo has ARMA_USE_LAPACK,ARMA_USE_BLAS set to True by default here.

As the commet says, you have to comment those lines to not use LAPACK or BLAS libraries. I thought CMake was setting those flags to true or false, but it does not seem so.

I will make you a PR with the changes :)

@Yevgnen check the PR. It should be working now!

@danimtb Sorry for late reply. I tried to test the PR, but got

Armadillo/8.300.0@demo/testing: Exporting package recipe
Armadillo/8.300.0@demo/testing: A new conanfile.py version was exported
Armadillo/8.300.0@demo/testing: Folder: /Users/user/.conan/data/Armadillo/8.300.0/demo/testing/export
ERROR: /Users/user/.conan/data/7z_installer/1.0/conan/stable/export/conanfile.py: Error while initializing settings. Invalid setting 'Macos' is not a valid 'settings.os' value.
Possible values are ['Windows']
Read "http://docs.conan.io/en/latest/faq/troubleshooting.html#error-invalid-setting"

Is the 7z_installer in only support windows?

Yes, you are right! I will update the PR to make this only in windows and set 7z_installer as optional dependency

Hi @Yevgnen,
I sent you the fix for 7z_installer issue in the PR. Did you have the time to test it again?

@danimtb Sorry for late reply. Please see my comment there.

Was this page helpful?
0 / 5 - 0 ratings