g++ can't find lstdc++_s

Asked by nrh

I'd like to compile a hello world program in c++ before I start compiling real code, just so I know
I can use the toolchain correctly (I've been using it on C code for some time now).

When I run

arm-none-eabi-g++ hello.cpp -mthumb -mcpu=cortex-m0 -Os -ffunction-sections -fdata-sections -fno-exceptions --specs=nano.specs -Wl,--gc-sections -Wl,-Map=cpp.map -o cpp-CM0.axf -lc -lstdc++ -lc -lnosys

I get the following g++ output:

/home/nrhinnant/toolchain/gcc-arm-none-eabi-4_7-2013q1-20130313/build-native/target-libs/lib/gcc/arm-none-eabi/4.7.3/../../../../arm-none-eabi/bin/ld: cannot find -lstdc++_s
/home/nrhinnant/toolchain/gcc-arm-none-eabi-4_7-2013q1-20130313/build-native/target-libs/lib/gcc/arm-none-eabi/4.7.3/../../../../arm-none-eabi/bin/ld: cannot find -lc_s
/home/nrhinnant/toolchain/gcc-arm-none-eabi-4_7-2013q1-20130313/build-native/target-libs/lib/gcc/arm-none-eabi/4.7.3/../../../../arm-none-eabi/bin/ld: cannot find -lstdc++_s
/home/nrhinnant/toolchain/gcc-arm-none-eabi-4_7-2013q1-20130313/build-native/target-libs/lib/gcc/arm-none-eabi/4.7.3/../../../../arm-none-eabi/bin/ld: cannot find -lc_s
/home/nrhinnant/toolchain/gcc-arm-none-eabi-4_7-2013q1-20130313/build-native/target-libs/lib/gcc/arm-none-eabi/4.7.3/../../../../arm-none-eabi/bin/ld: cannot find -lc_s
collect2: error: ld returned 1 exit status

Do I need to pass a specific path to lstdc++_s? Is it a prebuilt library or do I need to enable it's creation when I build the toolchain? I'm cross-compiling onto the STM32F407VG.

Thank you very much for your time!

Question information

Language:
English Edit question
Status:
Answered
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
chengbin (can-finner) said :
#1

I don't understand it.
The exactly command line works for me with below hello.cc

#include <iostream>

int main(void)
{
  std::cout <"hello world" << std::endl;

  return 0;
}

Could you check directory TOOLCHAIN/arm-none-eabi/lib/armv6-m to see whether there are libraries like "libc_s.a/listdc++_s.a"?

Revision history for this message
nrh (nrh) said :
#2

So I went to check the directory you specified, and my toolchain is structured differently than yours apparently.

I have:

toolchain/

toolchain/gcc-arm-none-eabi-4_7-2013q1-20130313

toolchain/gcc-arm-none-eabi-4_7-2013q1-20130313/build-native
toolchain/gcc-arm-none-eabi-4_7-2013q1-20130313/install-native
toolchain/gcc-arm-none-eabi-4_7-2013q1-20130313/pkg
toolchain/gcc-arm-none-eabi-4_7-2013q1-20130313/src

So I can't really follow that path. I did a find on "libc_s.a" and "lstdc++_s.a" both of which came up with nothing. Seems strange, because the toolchain works fine for C programs...

Revision history for this message
nrh (nrh) said :
#3

Ah, our toolchains are structured differently because you are using the pre-built binaries, and I'm building from source.
So, this opens a new line of questioning. I perhaps am not building the c++ libraries correctly?

Revision history for this message
chengbin (can-finner) said :
#4

You can check the build dump to see whether there is any error.
The install-native is the resulting toolchain of your build, it can be renamed or moved to other places and used as well as the pre-built binary. You can also go into install-native to see whether there is the corresponding library mentioned.

Thanks.

Can you help with this problem?

Provide an answer of your own, or ask nrh for more information if necessary.

To post a message you must log in.