a.cpp:
#include <iostream>
int main()
{
std::cout << "hello world" << std::endl;
return 0;
}
cmd输入:
arm-none-eabi-g++ -specs=nosys.specs a.cpp
cmd输出:
/usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld: /usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/lib/thumb/nofp/libstdc++.a(random.o): in function `std::(anonymous namespace)::__libc_getentropy(void*)':
/build/arm-none-eabi-gcc/src/gcc-12.2.0/libstdc++-v3/src/c++11/random.cc:179: undefined reference to `getentropy'
/usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld: /usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/lib/thumb/nofp/libstdc++.a(random.o): in function `std::random_device::_M_init(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/build/arm-none-eabi-gcc/src/gcc-12.2.0/libstdc++-v3/src/c++11/random.cc:452: undefined reference to `getentropy'
/usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld: /usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/lib/thumb/nofp/libc.a(lib_a-arc4random.o): in function `_rs_stir':
/build/arm-none-eabi-newlib/src/build-newlib/arm-none-eabi/thumb/nofp/newlib/libc/stdlib/../../../../../../../newlib-4.2.0.20211231/newlib/libc/stdlib/arc4random.c:89: undefined reference to `getentropy'
collect2: error: ld returned 1 exit status
我不知道为什么arm-none-eabi-g++编译失败,如果我使用arm-none-eabi-gcc编译C语言,它可以成功编译。是否有一些参数丢失导致编译失败?
1条答案
按热度按时间62lalag41#
我看了一下官方的GCC错误列表,其中提到了这个问题,但它被标记为已解决。GCC Bug Description