conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
8.23k stars 980 forks source link

[question] Cross Building Mac (CLion) and Raspberry Pico #9337

Open jBernavaPrah opened 3 years ago

jBernavaPrah commented 3 years ago

Good morning,

What is the correct profile to use to compile from mac (CLion) to Raspberry PICO?

I have already read and reread the examples from cross building but I'm not able to compile! :(

Thanks a lot!!, JBP

PS: This is my current profile:

toolchain=/usr/local/bin/arm-none-eabi-gcc

[settings]
os_build=Macos
arch_build=x86_64

os=Linux
arch=armv6
compiler=apple-clang

compiler.version=12.0
compiler.libcxx=libc++
build_type=Release

[options]
[build_requires]
[env]
CONAN_CMAKE_FIND_ROOT_PATH=$toolchain
CONAN_CMAKE_SYSROOT=$toolchain

And the error that I receive is:

Configuration:
[settings]
arch=armv6
arch_build=x86_64
build_type=Release
compiler=apple-clang
compiler.libcxx=libc++
compiler.version=12.0
cppstd=20
os=Linux
os_build=Macos
[options]
[build_requires]
[env]
CONAN_CMAKE_FIND_ROOT_PATH=/usr/local/bin/arm-none-eabi-gcc
CONAN_CMAKE_SYSROOT=/usr/local/bin/arm-none-eabi-gcc
kissfft/131.1.0: WARN: Package binary is corrupted, removing: bf282559a8d301e96e6e78973b1a7d9d4cec6385
conanfile.txt: Installing package
Requirements
    kissfft/131.1.0 from 'conancenter' - Cache
Packages
    kissfft/131.1.0:bf282559a8d301e96e6e78973b1a7d9d4cec6385 - Build

Cross-build from 'Macos:x86_64' to 'Linux:armv6'
Installing (downloading, building) binaries...
kissfft/131.1.0: WARN: Build folder is dirty, removing it: /Users/jure.prah/.conan/data/kissfft/131.1.0/_/_/build/bf282559a8d301e96e6e78973b1a7d9d4cec6385
kissfft/131.1.0: Copying sources to build folder
kissfft/131.1.0: Building your package in /Users/jure.prah/.conan/data/kissfft/131.1.0/_/_/build/bf282559a8d301e96e6e78973b1a7d9d4cec6385
kissfft/131.1.0: Generator cmake created conanbuildinfo.cmake
kissfft/131.1.0: Calling build()
-- The C compiler identification is AppleClang 12.0.5.12050022
-- The CXX compiler identification is AppleClang 12.0.5.12050022
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - broken
CMake Error at /usr/local/Cellar/cmake/3.21.0/share/cmake/Modules/CMakeTestCCompiler.cmake:66 (message):
  The C compiler

    "/Library/Developer/CommandLineTools/usr/bin/cc"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /Users/jure.prah/.conan/data/kissfft/131.1.0/_/_/build/bf282559a8d301e96e6e78973b1a7d9d4cec6385/CMakeFiles/CMakeTmp

    Run Build Command(s):/usr/bin/make -f Makefile cmTC_e0584/fast && /Library/Developer/CommandLineTools/usr/bin/make  -f CMakeFiles/cmTC_e0584.dir/build.make CMakeFiles/cmTC_e0584.dir/build
    Building C object CMakeFiles/cmTC_e0584.dir/testCCompiler.c.o
    /Library/Developer/CommandLineTools/usr/bin/cc --sysroot=/usr/local/bin/arm-none-eabi-gcc    -MD -MT CMakeFiles/cmTC_e0584.dir/testCCompiler.c.o -MF CMakeFiles/cmTC_e0584.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_e0584.dir/testCCompiler.c.o -c /Users/jure.prah/.conan/data/kissfft/131.1.0/_/_/build/bf282559a8d301e96e6e78973b1a7d9d4cec6385/CMakeFiles/CMakeTmp/testCCompiler.c
    Linking C executable cmTC_e0584
    /usr/local/Cellar/cmake/3.21.0/bin/cmake -E cmake_link_script CMakeFiles/cmTC_e0584.dir/link.txt --verbose=1
    /Library/Developer/CommandLineTools/usr/bin/cc --sysroot=/usr/local/bin/arm-none-eabi-gcc CMakeFiles/cmTC_e0584.dir/testCCompiler.c.o -o cmTC_e0584 
    ld: library not found for -lSystem
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make[1]: *** [cmTC_e0584] Error 1
    make: *** [cmTC_e0584/fast] Error 2

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:2 (project)

-- Configuring incomplete, errors occurred!
See also "/Users/jure.prah/.conan/data/kissfft/131.1.0/_/_/build/bf282559a8d301e96e6e78973b1a7d9d4cec6385/CMakeFiles/CMakeOutput.log".
See also "/Users/jure.prah/.conan/data/kissfft/131.1.0/_/_/build/bf282559a8d301e96e6e78973b1a7d9d4cec6385/CMakeFiles/CMakeError.log".
kissfft/131.1.0: 
kissfft/131.1.0: ERROR: Package 'bf282559a8d301e96e6e78973b1a7d9d4cec6385' build failed
kissfft/131.1.0: WARN: Build folder /Users/jure.prah/.conan/data/kissfft/131.1.0/_/_/build/bf282559a8d301e96e6e78973b1a7d9d4cec6385
ERROR: kissfft/131.1.0: Error in build() method, line 64
        cmake = self._configure_cmake()
while calling '_configure_cmake', line 59
        cmake.configure()
        ConanException: Error 1 while executing cd '/Users/jure.prah/.conan/data/kissfft/131.1.0/_/_/build/bf282559a8d301e96e6e78973b1a7d9d4cec6385' && cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_SYSTEM_NAME="Linux" -DCONAN_CMAKE_FIND_ROOT_PATH="/usr/local/bin/arm-none-eabi-gcc" -DCMAKE_SYSROOT="/usr/local/bin/arm-none-eabi-gcc" -DCONAN_IN_LOCAL_CACHE="ON" -DCONAN_COMPILER="apple-clang" -DCONAN_COMPILER_VERSION="12.0" -DBUILD_SHARED_LIBS="OFF" -DCMAKE_INSTALL_PREFIX="/Users/jure.prah/.conan/data/kissfft/131.1.0/_/_/package/bf282559a8d301e96e6e78973b1a7d9d4cec6385" -DCMAKE_INSTALL_BINDIR="bin" -DCMAKE_INSTALL_SBINDIR="bin" -DCMAKE_INSTALL_LIBEXECDIR="bin" -DCMAKE_INSTALL_LIBDIR="lib" -DCMAKE_INSTALL_INCLUDEDIR="include" -DCMAKE_INSTALL_OLDINCLUDEDIR="include" -DCMAKE_INSTALL_DATAROOTDIR="share" -DCONAN_CMAKE_POSITION_INDEPENDENT_CODE="ON" -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" -DKISSFFT_PKGCONFIG="False" -DKISSFFT_STATIC="True" -DKISSFFT_TEST="False" -DKISSFFT_TOOLS="False" -DKISSFFT_DATATYPE="float" -DKISSFFT_OPENMP="False" -DKISSFFT_USE_ALLOCA="False" -Wno-dev '/Users/jure.prah/.conan/data/kissfft/131.1.0/_/_/build/bf282559a8d301e96e6e78973b1a7d9d4cec6385'
memsharded commented 3 years ago

Hi @jBernavaPrah

It would be great to do it with a known recipe, to be able to reproduce on our side. This "hello world" example, can be easily created with conan new command.

A couple of notes. Depending on the stability constraints, it might be better to use modern Conan features:

jBernavaPrah commented 3 years ago

Thanks for your information. Unfortunately, I don't have enough knowledge to create a working recept.

But I can give you a working project for Raspberry pico (super simple) that compiles and work with standard Mac - Clion settings. This project uses the "SDK C++" from Raspberry Pico.

From my limited knowledge of C++ and compilers, what I think is missing to Conan (based on my project) is all configurations that pico_sdk_init.cmake (included by pico_sdk_import.cmake) automatically add to the compiler.

Therefore I think I have two possibilities:

  1. Tell to conan to use also pico_sdk_import.cmake. I have already tried adding on the profile file on the [conf] section the tools.cmake.cmaketoolchain:user_toolchain=$path/pico_sdk_import.cmake but the output of thee command conan install . --build=missing is not changing.
  2. Download only the sources, include them in projects and leave the "pico SDK" to compile it. This, in your opinion, is possible with Conan?