riscv-gnu-toolchain icon indicating copy to clipboard operation
riscv-gnu-toolchain copied to clipboard

[2025.02][Windows] Missing c++bits header files for some multilib in windows cause a compile error fatal error: bits/c++config.h: No such file or directory

Open fanghuaqi opened this issue 4 weeks ago • 0 comments

When using windows toolchain to compile cpp source code, you may face this following issue, this is caused by some folder in C:\path\to\NucleiStudio\toolchain\gcc\riscv64-unknown-elf\include\c++\14.2.1\riscv64-unknown-elf is missing.

Building file: ../application/main.cpp
Invoking: GNU RISC-V Cross C++ Compiler
riscv64-unknown-elf-g++ -march=rv32imafd_zba_zbb_zbs_zbc_zca_zcb_zcf_zcmp_zcmt_zilsd -mabi=ilp32d -mtune=nuclei-300-series -mcmodel=medlow -mno-save-restore -Os -ffunction-sections -fdata-sections -fno-common -g -D__IDE_RV_CORE=N300FD -DBOOT_HARTID=0 -DDOWNLOAD_MODE=DOWNLOAD_MODE_SRAM -DDOWNLOAD_MODE_STRING=\"SRAM\" -I"C:\Users\hqfang\NucleiStudio_workspace_202509\cpp\nuclei_sdk\NMSIS\Core\Include" -I"C:\Users\hqfang\NucleiStudio_workspace_202509\cpp\nuclei_sdk\SoC\evalsoc\Common\Include" -I"C:\Users\hqfang\NucleiStudio_workspace_202509\cpp\nuclei_sdk\SoC\evalsoc\Board\nuclei_fpga_eval\Include" -I"C:\Users\hqfang\NucleiStudio_workspace_202509\cpp\application" -isystem=/include/newlib-nano -std=gnu++11 -fabi-version=0 -MMD -MP -MF"application/main.d" -MT"application/main.o" -c -o "application/main.o" "../application/main.cpp"
In file included from C:/Software/NucleiStudio/toolchain/gcc/riscv64-unknown-elf/include/c++/14.2.1/iostream:38,
                 from ../application/main.cpp:2:
C:/Software/NucleiStudio/toolchain/gcc/riscv64-unknown-elf/include/c++/14.2.1/bits/requires_hosted.h:31:10: fatal error: bits/c++config.h: No such file or directory
   31 | #include <bits/c++config.h>
      |          ^~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [application/subdir.mk:20: application/main.o] Error 1
"make -j16 all" terminated with exit code 2. Build might be incomplete.

These folders are missing as described below:

rv32ima_zaamo_zalrsc_zca_zcb_zcmp_zba_zbb_zbs_xxldsp
rv32imaf_zaamo_zalrsc_zca_zcb_zcf_zcmp_zba_zbb_zbs_xxldsp
rv32imafd_zaamo_zalrsc_zca_zcb_zcd_zcf_zba_zbb_zbs_xxldsp
rv32imafd_zaamo_zalrsc_zca_zcb_zcf_zcmp_zba_zbb_zbs
rv32imafd_zaamo_zalrsc_zca_zcb_zcf_zcmp_zba_zbb_zbs_xxldsp

You can download this c++bits.zip and unzip it to NucleiStudio\toolchain\gcc\riscv64-unknown-elf\include\c++\14.2.1\riscv64-unknown-elf folder like this, then it will be fixed.

Image

And regarding compile some cpp source code, you need to use newlib full instead of newlib nano or small, change the library settings like this

C:/Software/NucleiStudio/toolchain/gcc/bin/../lib/gcc/riscv64-unknown-elf/14.2.1/../../../../riscv64-unknown-elf/lib/rv32imafd_zaamo_zalrsc_zca_zcb_zcf_zcmp_zba_zbb_zbs/ilp32d\libc_nano.a(libc_a-svfwprintf.o): in function `_svfwprintf_r':
(.text._svfwprintf_r+0x7a): undefined reference to `__ssputws_r'
C:/Software/NucleiStudio/toolchain/gcc/bin/../lib/gcc/riscv64-unknown-elf/14.2.1/../../../../riscv64-unknown-elf/bin/ld.exe: (.text._svfwprintf_r+0x38c): undefined reference to `__ssputws_r'
C:/Software/NucleiStudio/toolchain/gcc/bin/../lib/gcc/riscv64-unknown-elf/14.2.1/../../../../riscv64-unknown-elf/bin/ld.exe: (.text._svfwprintf_r+0x3a6): undefined reference to `__ssputws_r'
C:/Software/NucleiStudio/toolchain/gcc/bin/../lib/gcc/riscv64-unknown-elf/14.2.1/../../../../riscv64-unknown-elf/bin/ld.exe: (.text._svfwprintf_r+0x3da): undefined reference to `__ssputws_r'
C:/Software/NucleiStudio/toolchain/gcc/bin/../lib/gcc/riscv64-unknown-elf/14.2.1/../../../../riscv64-unknown-elf/bin/ld.exe: (.text._svfwprintf_r+0x404): undefined reference to `__ssputws_r'
C:/Software/NucleiStudio/toolchain/gcc/bin/../lib/gcc/riscv64-unknown-elf/14.2.1/../../../../riscv64-unknown-elf/bin/ld.exe: C:/Software/NucleiStudio/toolchain/gcc/bin/../lib/gcc/riscv64-unknown-elf/14.2.1/../../../../riscv64-unknown-elf/lib/rv32imafd_zaamo_zalrsc_zca_zcb_zcf_zcmp_zba_zbb_zbs/ilp32d\libc_nano.a(libc_a-svfwprintf.o):(.text._svfwprintf_r+0x422): more undefined references to `__ssputws_r' follow
collect2.exe: error: ld returned 1 exit status
make: *** [makefile:92: cpp.elf] Error 1
"make -j16 all" terminated with exit code 2. Build might be incomplete.
Image

fanghuaqi avatar Oct 29 '25 03:10 fanghuaqi