Failure to compile for arm64 devices - c++

Hello i am quite new to linux and i am trying to do some cross-compilation to run a flutter app on an external device.
Setup :
VM under virtual box : Ubuntu 22.04 LTS
External device : (imx8) with arm64
So i need to compile my app to match the arm64 architecture but i am having many errors that i have no idea how to fix and no idea where they come from :
Failed to cmake:
-- The CXX compiler identification is Clang 14.0.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: /usr/bin/clang++
-- Check for working CXX compiler: /usr/bin/clang++ - broken
-- Configuring incomplete, errors occurred!
See also "/home/tom/test_app/build/elinux/arm64/release/CMakeFiles/CMakeOutput.log".
See also "/home/tom/test_app/build/elinux/arm64/release/CMakeFiles/CMakeError.log".
CMake Error at /usr/share/cmake-3.22/Modules/CMakeTestCXXCompiler.cmake:62 (message):
The C++ compiler
"/usr/bin/clang++"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /home/tom/test_app/build/elinux/arm64/release/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_46f48/fast && /usr/bin/gmake -f CMakeFiles/cmTC_46f48.dir/build.make CMakeFiles/cmTC_46f48.dir/build
gmake[1]: Entering directory '/home/tom/test_app/build/elinux/arm64/release/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_46f48.dir/testCXXCompiler.cxx.o
/usr/bin/clang++ --target=aarch64-linux-gnu --sysroot=/opt/arm64-sysroot -MD -MT CMakeFiles/cmTC_46f48.dir/testCXXCompiler.cxx.o -MF
CMakeFiles/cmTC_46f48.dir/testCXXCompiler.cxx.o.d -o CMakeFiles/cmTC_46f48.dir/testCXXCompiler.cxx.o -c
/home/tom/test_app/build/elinux/arm64/release/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
Linking CXX executable cmTC_46f48
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_46f48.dir/link.txt --verbose=1
/usr/bin/clang++ --target=aarch64-linux-gnu --sysroot=/opt/arm64-sysroot CMakeFiles/cmTC_46f48.dir/testCXXCompiler.cxx.o -o cmTC_46f48
/usr/bin/aarch64-linux-gnu-ld: cannot find Scrt1.o: No such file or directory
/usr/bin/aarch64-linux-gnu-ld: cannot find crti.o: No such file or directory
/usr/bin/aarch64-linux-gnu-ld: cannot find crtbeginS.o: No such file or directory
/usr/bin/aarch64-linux-gnu-ld: cannot find -lstdc++: No such file or directory
/usr/bin/aarch64-linux-gnu-ld: cannot find -lm: No such file or directory
/usr/bin/aarch64-linux-gnu-ld: cannot find -lgcc_s: No such file or directory
/usr/bin/aarch64-linux-gnu-ld: cannot find -lgcc: No such file or directory
/usr/bin/aarch64-linux-gnu-ld: cannot find -lc: No such file or directory
/usr/bin/aarch64-linux-gnu-ld: cannot find -lgcc_s: No such file or directory
/usr/bin/aarch64-linux-gnu-ld: cannot find -lgcc: No such file or directory
/usr/bin/aarch64-linux-gnu-ld: cannot find crtendS.o: No such file or directory
/usr/bin/aarch64-linux-gnu-ld: cannot find crtn.o: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[1]: *** [CMakeFiles/cmTC_46f48.dir/build.make:100: cmTC_46f48] Error 1
gmake[1]: Leaving directory '/home/tom/test_app/build/elinux/arm64/release/CMakeFiles/CMakeTmp'
gmake: *** [Makefile:127: cmTC_46f48/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
For more specification, i am using the flutter-elinux package to cross-compile and i have raised an issue there, but i am not sure the issue comes from the package as i don't know anything about linux compilation.
I have installed manually the following packages :
sudo apt install cpp-aarch64-linux-gnu
sudo apt install binutils-aarch64-linux-gnu
Thanks in advance for any help i really need to get this working...
EDIT : i have tried another solution using a docker container and the image arm64v8/ubuntu:18.04.
I have created a systroot ubuntu18-arm64-sysroot on my host and i use it to compile my app in arm64 arch. I am having the following error only :
Failed to cmake:
-- The CXX compiler identification is unknown
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: /home/tom/ubuntu18-arm64-sysroot/usr/bin/clang++
-- Check for working CXX compiler: /home/tom/ubuntu18-arm64-sysroot/usr/bin/clang++ - broken
-- Configuring incomplete, errors occurred!
See also "/home/tom/test_app/build/elinux/arm64/debug/CMakeFiles/CMakeOutput.log".
See also "/home/tom/test_app/build/elinux/arm64/debug/CMakeFiles/CMakeError.log".
CMake Error at /usr/share/cmake-3.22/Modules/CMakeTestCXXCompiler.cmake:62 (message):
The C++ compiler
"/home/tom/ubuntu18-arm64-sysroot/usr/bin/clang++"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /home/tom/test_app/build/elinux/arm64/debug/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_848af/fast && /usr/bin/gmake -f
CMakeFiles/cmTC_848af.dir/build.make CMakeFiles/cmTC_848af.dir/build
gmake[1]: Entering directory '/home/tom/test_app/build/elinux/arm64/debug/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_848af.dir/testCXXCompiler.cxx.o
/home/tom/ubuntu18-arm64-sysroot/usr/bin/clang++ -o CMakeFiles/cmTC_848af.dir/testCXXCompiler.cxx.o -c
/home/tom/test_app/build/elinux/arm64/debug/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
aarch64-binfmt-P: Could not open '/lib/ld-linux-aarch64.so.1': No such file or directory
gmake[1]: *** [CMakeFiles/cmTC_848af.dir/build.make:78: CMakeFiles/cmTC_848af.dir/testCXXCompiler.cxx.o] Error 255
gmake[1]: Leaving directory '/home/tom/test_app/build/elinux/arm64/debug/CMakeFiles/CMakeTmp'
gmake: *** [Makefile:127: cmTC_848af/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)

Related

Conan Cross-build from Linux:x86_64 to Linux:armv7hf test_package build fails

I have a C++ library packaged with conan and it contains a test_package with a conanfile.py that uses the new conan 2.0 self.requries(self.tested_reference_str) and test_type = "explicit".
When not cross-building everything runs fine. I can build the library using conan build . and build and run the consumer test_package.
In case of cross-building, the main library can be built without issues. However, the build of the test_package fails with:
----Running------
> . "/work/tests/test_package/build/generators/conanbuild.sh" && cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="/work/tests/test_package/build/generators/conan_toolchain.cmake" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Release" "/work/tests/test_package/."
-----------------
-- Using Conan toolchain: /work/tests/test_package/build/generators/conan_toolchain.cmake
-- The CXX compiler identification is GNU 11.3.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: /opt/poky/4.0.5/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++
-- Check for working CXX compiler: /opt/poky/4.0.5/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++ - broken
CMake Error at /opt/poky/4.0.5/sysroots/x86_64-pokysdk-linux/usr/share/cmake-3.22/Modules/CMakeTestCXXCompiler.cmake:62 (message):
The C++ compiler
"/opt/poky/4.0.5/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /work/tests/test_package/build/Release/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_8ea64/fast && /usr/bin/gmake -f CMakeFiles/cmTC_8ea64.dir/build.make CMakeFiles/cmTC_8ea64.dir/build
gmake[1]: Entering directory '/work/tests/test_package/build/Release/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_8ea64.dir/testCXXCompiler.cxx.o
/opt/poky/4.0.5/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++ -O2 -pipe -g -feliminate-unused-debug-types -stdlib=libstdc++ -o CMakeFiles/cmTC_8ea64.dir/testCXXCompiler.cxx.o -c /work/tests/test_package/build/Release/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
arm-poky-linux-gnueabi-g++: error: unrecognized command-line option ‘-stdlib=libstdc++’
gmake[1]: *** [CMakeFiles/cmTC_8ea64.dir/build.make:78: CMakeFiles/cmTC_8ea64.dir/testCXXCompiler.cxx.o] Error 1
gmake[1]: Leaving directory '/work/tests/test_package/build/Release/CMakeFiles/CMakeTmp'
gmake: *** [Makefile:127: cmTC_8ea64/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
host profile:
[settings]
os=Linux
arch=armv7hf
compiler=clang
compiler.version=14
# Tried also with libc++
compiler.libcxx=libstdc++11
build_type=Release
build profile:
[settings]
os=Linux
arch=x86_64
compiler=gcc
compiler.version=11
# Without the following the error becomes:
# arm-poky-linux-gnueabi-g++: error: unrecognized command-line option ‘-stdlib=libc++’
compiler.libcxx=libstdc++11
build_type=Release
[env]
CC=gcc-11
CXX=g++-11
Any idea why cross compiling works for the library itself but the test_package fails?
Edit: I looked into conaninfo.txt, CMakeCache.txt, for both: the library generated files and the test_package generated files. Conan specifies the clang compiler in both cases (library build and test_package) but CMake uses anyway the GNU compiler for the test_package. It seems the CMAKE_CXX_COMPILER is not passed correctly to CMake in case of the test_package. A conan install inside the test_package folder also results in the wrong compiler (GNU) being used.

I have error in cmake make make install fmm

I want to install fast map matching fmm on windows (win7)
and cmake has an error: after command "cmake .."
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: /cygdrive/c/MinGW/bin/c++.exe
-- Check for working CXX compiler: /cygdrive/c/MinGW/bin/c++.exe - broken
CMake Error at /usr/share/cmake-3.20.0/Modules/CMakeTestCXXCompiler.cmake:59 (message):
The C++ compiler
"/cygdrive/c/MinGW/bin/c++.exe"
It's not able to compile a simple test program.
It fails with the following output:
Change Dir: /cygdrive/e/fmm/build/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/make.exe -f Makefile cmTC_c3891/fast && /usr/bin/make -f CMakeFiles/cmTC_c3891.dir/build.make CMakeFiles/cmTC_c3891.dir/build
make[1]: Entering directory `/cygdrive/e/fmm/build/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_c3891.dir/testCXXCompiler.cxx.o
/cygdrive/c/MinGW/bin/c++.exe -O3 -DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE -o CMakeFiles/cmTC_c3891.dir/testCXXCompiler.cxx.o -c /cygdrive/e/fmm/build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
c++.exe: error: /cygdrive/e/fmm/build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx: No such file or directory
c++.exe: fatal error: no input files
compilation terminated.
make[1]: *** [CMakeFiles/cmTC_c3891.dir/testCXXCompiler.cxx.o] Error 1
make[1]: Leaving directory `/cygdrive/e/fmm/build/CMakeFiles/CMakeTmp'
make: *** [cmTC_c3891/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:31 (project)
and because cmake not success, make -j8 has error
make -j8
make: *** No targets specified and no makefile found. Stop.
update:cmake has successed,the error is that i don't install enough librarys.
but i have error in make and make install
E:/anaconda/include/pyport.h:726:2: error: #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."
726 | #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."
| ^~~~~
In file included from /usr/include/cpl_progress.h:33,
from /usr/include/ogrsf_frmts.h:34,
from /cygdrive/e/fmm/src/core/geometry.hpp:14,
from /cygdrive/e/fmm/build/python/CMakeFiles/pyfmm.dir/fmmPYTHON_wrap.cxx:3392:
/usr/include/cpl_port.h:156:12: fatal error: direct.h: No such file or directory
156 | # include <direct.h>
i have tried to switch anaconda to the 64 bit ,it has the same error

CLion - can't run a program on apple m1

I ran clion a month ago and it worked perfectly. Now when I run a program I get:
/bin/sh: /Users/a/Library/Application Support/JetBrains/Toolbox/apps/CLion-ARM/ch-0/203.7717.62/CLion.app/Contents/bin/cmake/mac/bin/cmake: No such file or directory
make: *** [cmake_check_build_system] Error 127
Also, on clion startup, the cmake tool window shows me an error:
CMake Warning at /Users/a/Library/Application Support/JetBrains/Toolbox/apps/CLion/ch-1/211.7142.21/CLion.app/Contents/bin/cmake/mac/share/cmake-3.19/Modules/Platform/Darwin-Initialize.cmake:303 (message):
Ignoring CMAKE_OSX_SYSROOT value:
/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk
because the directory does not exist.
Call Stack (most recent call first):
/Users/a/Library/Application Support/JetBrains/Toolbox/apps/CLion/ch-1/211.7142.21/CLion.app/Contents/bin/cmake/mac/share/cmake-3.19/Modules/CMakeSystemSpecificInitialize.cmake:21 (include)
CMakeLists.txt:2 (project)
-- 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 /Users/a/Library/Application Support/JetBrains/Toolbox/apps/CLion/ch-1/211.7142.21/CLion.app/Contents/bin/cmake/mac/share/cmake-3.19/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/a/CLionProjects/untitled1/cmake-build-debug/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/make cmTC_e3f61/fast && /Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_e3f61.dir/build.make CMakeFiles/cmTC_e3f61.dir/build
Building C object CMakeFiles/cmTC_e3f61.dir/testCCompiler.c.o
/Library/Developer/CommandLineTools/usr/bin/cc -arch arm64 -o CMakeFiles/cmTC_e3f61.dir/testCCompiler.c.o -c /Users/a/CLionProjects/untitled1/cmake-build-debug/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_e3f61
"/Users/a/Library/Application Support/JetBrains/Toolbox/apps/CLion/ch-1/211.7142.21/CLion.app/Contents/bin/cmake/mac/bin/cmake" -E cmake_link_script CMakeFiles/cmTC_e3f61.dir/link.txt --verbose=1
/Library/Developer/CommandLineTools/usr/bin/cc -arch arm64 -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_e3f61.dir/testCCompiler.c.o -o cmTC_e3f61
ld: library not found for -lSystem
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [cmTC_e3f61] Error 1
make: *** [cmTC_e3f61/fast] Error 2
I have xcode command line tools installed. What should I do?
Erase cmake-build-... directory manually and reload a CMake project.

Test Cmake run finished with errors (CLION)

I have the following problem after changing path to one that is easier for the operating system. My MinGW configuration in CLion:
-- The C compiler identification is GNU 6.3.0
-- The CXX compiler identification is GNU 6.3.0
-- Check for working C compiler: C:/MinGW/bin/gcc.exe
-- Check for working C compiler: C:/MinGW/bin/gcc.exe -- broken
CMake Error at C:/Program Files/JetBrains/CLion 2018.2.5/bin/cmake/win/share/cmake-3.12/Modules/CMakeTestCCompiler.cmake:52 (message):
The C compiler
"C:/MinGW/bin/gcc.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/Michał/AppData/Local/Temp/cmake_check_environment/_build/CMakeFiles/CMakeTmp
Run Build Command:"C:/MinGW/bin/mingw32-make.exe" "cmTC_da460/fast"
C:/MinGW/bin/mingw32-make.exe -f CMakeFiles\cmTC_da460.dir\build.make CMakeFiles/cmTC_da460.dir/build
mingw32-make.exe[1]: Entering directory 'C:/Users/Micha│/AppData/Local/Temp/cmake_check_environment/_build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_da460.dir/testCCompiler.c.obj
C:\MinGW\bin\gcc.exe -o CMakeFiles\cmTC_da460.dir\testCCompiler.c.obj -c C:\Users\Michał\AppData\Local\Temp\cmake_check_environment\_build\CMakeFiles\CMakeTmp\testCCompiler.c
gcc.exe: error: C:\Users\Michał\AppData\Local\Temp\cmake_check_environment\_build\CMakeFiles\CMakeTmp\testCCompiler.c: No such file or directory
gcc.exe: fatal error: no input files
compilation terminated.
CMakeFiles\cmTC_da460.dir\build.make:64: recipe for target 'CMakeFiles/cmTC_da460.dir/testCCompiler.c.obj' failed
mingw32-make.exe[1]: *** [CMakeFiles/cmTC_da460.dir/testCCompiler.c.obj] Error 1
mingw32-make.exe[1]: Leaving directory 'C:/Users/Micha│/AppData/Local/Temp/cmake_check_environment/_build/CMakeFiles/CMakeTmp'
Makefile:120: recipe for target 'cmTC_da460/fast' failed
mingw32-make.exe: *** [cmTC_da460/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:1 (project)
-- Configuring incomplete, errors occurred!
See also "C:/Users/Michał/AppData/Local/Temp/cmake_check_environment/_build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Michał/AppData/Local/Temp/cmake_check_environment/_build/CMakeFiles/CMakeError.log".
Error code: 1
Here is a screenshot from my PC:

CMake "clang++ is not able compile a simple test program" (Fedora 20)

So I tried to install clang + cmake to compile a simple C++ program and I'm getting the following error:
-- The C compiler identification is GNU 4.8.3
-- The CXX compiler identification is Clang 3.5.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
-- Check for working CXX compiler: /usr/local/bin/clang++
-- Check for working CXX compiler: /usr/local/bin/clang++ -- broken
CMake Error at /usr/share/cmake/Modules/CMakeTestCXXCompiler.cmake:54 (message):
The C++ compiler "/usr/local/bin/clang++" is not able to compile a simple
test program.
It fails with the following output:
Change Dir: /home/jtcwang/tmp/CMake/CMake/CMakeFiles/CMakeTmp
Run Build Command:/usr/bin/gmake "cmTryCompileExec697180971/fast"
/usr/bin/gmake -f CMakeFiles/cmTryCompileExec697180971.dir/build.make
CMakeFiles/cmTryCompileExec697180971.dir/build
gmake[1]: Entering directory
`/home/jtcwang/tmp/CMake/CMake/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report
/home/jtcwang/tmp/CMake/CMake/CMakeFiles/CMakeTmp/CMakeFiles 1
Building CXX object
CMakeFiles/cmTryCompileExec697180971.dir/testCXXCompiler.cxx.o
/usr/local/bin/clang++ -o
CMakeFiles/cmTryCompileExec697180971.dir/testCXXCompiler.cxx.o -c
/home/jtcwang/tmp/CMake/CMake/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
Linking CXX executable cmTryCompileExec697180971
/usr/bin/cmake -E cmake_link_script
CMakeFiles/cmTryCompileExec697180971.dir/link.txt --verbose=1
/usr/local/bin/clang++
CMakeFiles/cmTryCompileExec697180971.dir/testCXXCompiler.cxx.o -o
cmTryCompileExec697180971 -rdynamic
/usr/bin/ld: cannot find -lstdc++
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
gmake[1]: Leaving directory
`/home/jtcwang/tmp/CMake/CMake/CMakeFiles/CMakeTmp'
gmake[1]: *** [cmTryCompileExec697180971] Error 1
gmake: *** [cmTryCompileExec697180971/fast] Error 2
It's not even compiling my program because it fails to compile a test program.
Looks like the important line is here:
/usr/bin/ld: cannot find -lstdc++
However, I have checked that libstdc++ is installed and up to date, so at this point I'm quite lost.
Other things I've tried:
Using prebuilt binaries instead of sudo yum install clang
remove and reinstall
Tried clang++ hello.cpp (hello world program). It says <iostreams> is not found. Is clang missing a standard library? EDIT: changing to <iostream> gives me the same linker error above.
I'm not familiar with the clang, cmake and C++ scene in general, so I'd appreciate any pointers. Thanks!
You need the development libraries and headers for C++ library, try
yum install libstdc++-devel
Your /home/gnu/bin/c++ seem to require additional flag to link things properly and CMake doesn't know about that.
To use /usr/bin/c++ as your compiler run cmake with -DCMAKE_CXX_COMPILER=/usr/bin/c++.
Also, CMAKE_PREFIX_PATH variable sets destination dir where your project' files should be installed. It has nothing to do with CMake installation prefix and CMake itself already know this.