0

Hello I'm trying to cross-compile libbson to include it as lib to STM32CubeIDE to use it on STM32 ARM-core processor, but after trying to specify toolchain with command:

cmake -DENABLE_MONGOC=OFF -DCMAKE_TOOLCHAIN_FILE=~/arm_compiler/gcc-arm-none-eabi-10.3-2021.07/bin/arm-none-eabi-gcc ..

I get error below:

CMake Error at ~/arm_compiler/gcc-arm-none-eabi-10.3-2021.07/bin/arm-none-eabi-gcc:1: Parse error. Expected a command name, got unquoted argument with text "ELF". Call Stack (most recent call first): /usr/share/cmake-3.16/Modules/CMakeDetermineSystem.cmake:93 (include) CMakeLists.txt:55 (project)

Im begginer in this topic I based my knowledge on those links:

I downloaded toolchain from:

  • `arm-none-eabi-gcc` is a **compiler** (executable), but CMake toolchain file is a **CMake script**. Assigning a compiler to the `CMAKE_TOOLCHAIN_FILE` variable has a little sense. You could read about CMake toolchain in the [documentation](https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html). – Tsyvarev Oct 07 '21 at 11:31
  • Of course you were right. I added toolchain file. The generation of CMakeCache runs properly it finds requested compiler but than build fails with error: `arm-none-eabi/lib/libc.a(lib_a-exit.o): in function exit': exit.c:(.text.exit+0x2c): undefined reference to _exit' collect2: error: ld returned 1 exit status` – s_sliwinski Oct 08 '21 at 09:51
  • Have you tried to google for error message? Have you checked e.g. [that question](https://stackoverflow.com/questions/23054189/cmake-gnu-and-stm32-exit-link-error-when-testing-compiler) and its answers? – Tsyvarev Oct 08 '21 at 10:06
  • Yes I modified toolchain according to link you provided. Now i got another error while building lib: `In file included from Sandbox/bson2/mongo-c-driver/src/libbson/src/bson/bson-context-private.h:25, from Sandbox/bson2/mongo-c-driver/src/libbson/src/bson/bson-context.c:28: Sandbox/bson2/mongo-c-driver/src/libbson/src/bson/bson-context.c: In function 'bson_context_get_default': Sandbox/bson2/mongo-c-driver/src/libbson/../../src/common/common-thread-private.h:37:24: error: 'PTHREAD_ONCE_INIT' undeclared (first use in this function) 37 | #define BSON_ONCE_INIT PTHREAD_ONCE_INIT` – s_sliwinski Oct 08 '21 at 12:48
  • Looks like something wrong with PThreads (POSIX threads) library in your toolchain, compiler or in the project (`mongo-c-driver`). – Tsyvarev Oct 08 '21 at 13:14

0 Answers0