Closed JuJin1324 closed 4 years ago
I'm using macOS 10.14.6(Mojave) / CLion 2019.3 / This compiler is in Downloads directory.
Looks like your code includes a Mac OS X SDK header file. This header file is designed to be used only with code that runs on macOS. Hence, the header file has a check for the target architecture, and throws the error because these toolchains are cross-compilers -- the host is macOS, but the target is ARM/Linux, not macOS.
I found out the solution. Mac users using cmake have to add this below. I put arm-linux compiler to /usr/local. Someone who doesn't put arm compiler to /usr/local, modify the first set(ARM_LINUX_TOOLCHAIN_DIR [your arm compiler path])
set(ARM_LINUX_TOOLCHAIN_DIR /usr/local/arm-unknown-linux-gnueabi)
set(CMAKE_C_COMPILER ${ARM_LINUX_TOOLCHAIN_DIR}/bin/arm-unknown-linux-gnueabi-gcc)
set(CMAKE_LINKER ${ARM_LINUX_TOOLCHAIN_DIR}/bin/arm-unknown-linux-gnueabi-ld)
set(CMAKE_NM ${ARM_LINUX_TOOLCHAIN_DIR}/bin/arm-unknown-linux-gnueabi-nm)
set(CMAKE_OBJCOPY ${ARM_LINUX_TOOLCHAIN_DIR}/bin/arm-unknown-linux-gnueabi-objcopy)
set(CMAKE_OBJDUMP ${ARM_LINUX_TOOLCHAIN_DIR}/bin/arm-unknown-linux-gnueabi-objdump)
set(CMAKE_RANLIB ${ARM_LINUX_TOOLCHAIN_DIR}/bin/arm-unknown-linux-gnueabi-ranlib)
include_directories(${ARM_LINUX_TOOLCHAIN_DIR}/arm-unknown-linux-gnueabi/sysroot/usr/include)
When I'm using this in CLion and cmake, it occurred below.
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:784:2: error: #error Unsupported architecture
How can I use this compiler... please.. I need this..