-
Notifications
You must be signed in to change notification settings - Fork 15
Cannot find -lstdc++ #10
Comments
use |
@zakk0610 |
You can use g++ to compile a C++ source code with |
Here is the result, which compile with -v,
|
This could be a build problem. Maybe you don't have a libstdc++. This could be a multilib problem. Maybe you do have a libstdc++, but you don't have a V libstdc++. I would suggest trying the commands If you aren't calling any library functions with vector arguments, you may not need the V in -march option when linking. You could try linking without the V march and see if that works. |
Thank you for your answer. Here are the results what you suggest,
and
"riscv_aligned.cpp" file need RISC-V vector extension. |
You can use --with-arch=rv64gcv when configuring the toolchain, which will build libraries like libstdc++ with rv64gcv. If you don't specify --with-arch when configuring, then the default is rv64gc and libstdc++ will be built with that. Though it isn't clear to me why you need a vector libstdc++. Just because your program is compiled with vector support doesn't mean that you need a libstdc++ compiled with vector support. The ABI for non-vector code doesn't change when compiled with vector instructions. So you should be able to link your vector code with a non-vector libstdc++. Just drop the -march option when linking. |
Thanks a lot!! It works!! |
In our cpp file, we are using the "aligned_alloc" function.
the results are
Can we use 'sleep' and 'aligned_alloc' ?? |
An embedded elf toolchain provides a limited set of library functions. It is hard to support sleep when you don't have an OS. There is no one tracking all standards to ensure all possible library functions are added. An embedded elf C library just supports the most common functions. It looks like aligned_alloc is supported but posix_memalign isn't. If you want a full featured C library, you should use a linux toolchain instead of an embedded elf toolchain. But if you do use a linux toolchain, and a lot of C libary features, then the code will probably only run on qemu. spike+pk only supports a limited number of system calls. |
Thanks for your adivce. riscv64-unknow-liinux-gnu-g++ works, however, there exists linker problem.
I'm going to address the current problem by commenting out sleep first and replacing aligned_alloc with malloc. |
You probably need to pass an option to qemu to tell it where your sysroot is. qemu will then find ld.so and other shared libraries inside the sysroot. Checking riscv-gnu-toolchain, we pass a -L $RISC_V_SYSROOT option to qemu, where RISC_V_SYSROOT is an environment variable set by the Makefile to point at $prefix/sysroot. You also need to make sure that you do have the file inside your sysroot. Try using ls to make sure the file is there. If not, then there is something wrong with your compiler and/or C library. You can always try linking statically if you can't figure out how to make shared libraries work. |
I build LLVM & Clang and it works well with simple vector addition C code.
works well. However,
command doesn't work. The following error occurs.
Has anyone solved a problem like this? Does anyone know how to solve it?
The text was updated successfully, but these errors were encountered: