GCC Linaro cross compile fails on linker step on a Windows host

一个人想着一个人 提交于 2021-01-29 09:26:33

问题


I want to build an ARM application(just a simple main function) on Windows host using GCC Linaro toolchains version 7.4.1. Compilation is OK, my .o files are created but on linking step I get the following errors(tested on different computers and result is same)

Errors start from locale.o file... But that /home/tcwg-builds/.. directory is not related to my computer paths...

Building target: arm_cpp Invoking: Cross G++ Linker arm-eabi-g++ -o "arm_cpp" ./src/arm_cpp.o
c:/users/yunus/desktop/linarotoolchain/gcc_linaro_7/bin/../lib/gcc/arm-eabi/7.4.1/../../../../arm-eabi/lib\libstdc++.a(locale.o): In function get_locale_cache_mutex': /home/tcwg-buildslave/workspace/tcwg-make-release_0/snapshots/gcc.git~linaro-7.4-2019.02/libstdc++-v3/src/c++98/locale.cc:36: undefined reference to__sync_synchronize' c:/users/yunus/desktop/linarotoolchain/gcc_linaro_7/bin/../lib/gcc/arm-eabi/7.4.1/../../../../arm-eabi/lib\libstdc++.a(locale_init.o): In function (anonymous namespace)::get_locale_mutex()': /home/tcwg-buildslave/workspace/tcwg-make-release_0/snapshots/gcc.git~linaro-7.4-2019.02/libstdc++-v3/src/c++98/locale_init.cc:66: undefined reference to__sync_synchronize' c:/users/yunus/desktop/linarotoolchain/gcc_linaro_7/bin/../lib/gcc/arm-eabi/7.4.1/../../../../arm-eabi/lib\libstdc++.a(cxx11-ios_failure.o): In function (anonymous namespace)::__io_category_instance()': /home/tcwg-buildslave/workspace/tcwg-make-release_0/snapshots/gcc.git~linaro-7.4-2019.02/libstdc++-v3/src/c++11/cxx11-ios_failure.cc:73: undefined reference to__sync_synchronize' collect2.exe: error: ld returned 1 exit status make: *** [arm_cpp] Error 1 "make all" terminated with exit code 2. Build might be incomplete.


回答1:


Well, I really searched this problem for days but now I immeditely find the answer, from this thread: https://lists.linaro.org/pipermail/linaro-toolchain/2018-January/006356.html

It is stated that:

This error happens because the arm-eabi compiler defaults to an old version of the architecture (v4 or v5t). Adding -mcpu=cortex-a9 for instance should avoid the problem because the compiler will be able to generate synchronization primitives inline.

With this linking option I succesfully get result image without errors



来源:https://stackoverflow.com/questions/57837286/gcc-linaro-cross-compile-fails-on-linker-step-on-a-windows-host

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!