my 'main' source file is a cpp file. I've been using this fine with chibios along with some cpp libraries for some time (the makefile knows theyre cpp). I want to perform some string manipulation and so need the string library so I import the following:
Linking build/ch.elf lto-wrapper.exe: warning: Options to Xassembler do not match: -alms=./build/lst/crt1.lst, -alms=./build/lst/hal.lst, dropping all -Xassembler and -Wa options. c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\zinvi\AppData\Local\Temp\ch.elf.WOywVb.ltrans0.ltrans.o: in function `main': c:\chibistudio\tools\gnu tools arm embedded\10.3 2021.07\arm-none-eabi\include\c++\10.3.1\bits/basic_string.tcc:225: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_copy_chars(char*, char const*, char const*)' c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\zinvi\AppData\Local\Temp\ch.elf.WOywVb.ltrans0.ltrans.o: in function `_GLOBAL__sub_I__Z15ApplicationInitv': c:\chibistudio\tools\gnu tools arm embedded\10.3 2021.07\arm-none-eabi\include\c++\10.3.1/iostream:74: undefined reference to `std::ios_base::Init::Init()' c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\zinvi\AppData\Local\Temp\ch.elf.WOywVb.ltrans0.ltrans.o:c:\chibistudio\tools\gnu tools arm embedded\10.3 2021.07\arm-none-eabi\include\c++\10.3.1/iostream:74: undefined reference to `__dso_handle' c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\zinvi\AppData\Local\Temp\ch.elf.WOywVb.ltrans0.ltrans.o:c:\chibistudio\tools\gnu tools arm embedded\10.3 2021.07\arm-none-eabi\include\c++\10.3.1/iostream:74: undefined reference to `std::ios_base::Init::~Init()' c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m/nofp\libg.a(lib_a-fini.o): in function `__libc_fini_array': fini.c:(.text.__libc_fini_array+0x20): undefined reference to `_fini' c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m/nofp\libg.a(lib_a-abort.o): in function `abort': abort.c:(.text.abort+0xa): undefined reference to `_exit' c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m/nofp\libg.a(lib_a-signalr.o): in function `_kill_r': signalr.c:(.text._kill_r+0x12): undefined reference to `_kill' c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m/nofp\libg.a(lib_a-signalr.o): in function `_getpid_r': signalr.c:(.text._getpid_r+0x0): undefined reference to `_getpid' c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: build/ch.elf: hidden symbol `__dso_handle' isn't defined c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: final link failed: bad value collect2.exe: error: ld returned 1 exit status make: *** [../../../os/common/startup/ARMCMx/compilers/GCC/mk/rules.mk:217: build/ch.elf] Error 1 "make -j8 all" terminated with exit code 2. Build might be incomplete.
I tried adding the path 'C:\ChibiStudio\tools\GNU Tools ARM Embedded\10.3 2021.07' in both the C and C++ CDT user setting entries in the project preprocesser include paths (in project properties). This didnt fix anything. I'm not exactly an expert on the C build process and toolchain details, why wont these libraries be imported/linked correctly and how do I fix this?
Linking build/ch.elf lto-wrapper.exe: warning: Options to Xassembler do not match: -alms=./build/lst/crt1.lst, -alms=./build/lst/hal.lst, dropping all -Xassembler and -Wa options. c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\zinvi\AppData\Local\Temp\ch.elf.34hhZP.ltrans0.ltrans.o: in function `_GLOBAL__sub_I__Z15ApplicationInitv': c:\chibistudio\tools\gnu tools arm embedded\10.3 2021.07\arm-none-eabi\include\c++\10.3.1/iostream:74: undefined reference to `__dso_handle' c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m/nofp\libstdc++.a(system_error.o): in function `_GLOBAL__sub_I__ZSt20__throw_system_errori': system_error.cc:(.text.startup._GLOBAL__sub_I__ZSt20__throw_system_errori+0x1c): undefined reference to `__dso_handle' c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m/nofp\libstdc++.a(cxx11-ios_failure.o): in function `(anonymous namespace)::__io_category_instance()': cxx11-ios_failure.cc:(.text._ZN12_GLOBAL__N_122__io_category_instanceEv+0x38): undefined reference to `__dso_handle' c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m/nofp\libg.a(lib_a-abort.o): in function `abort': abort.c:(.text.abort+0xa): undefined reference to `_exit' c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m/nofp\libg.a(lib_a-fstatr.o): in function `_fstat_r': fstatr.c:(.text._fstat_r+0x12): undefined reference to `_fstat' c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m/nofp\libg.a(lib_a-sbrkr.o): in function `_sbrk_r': sbrkr.c:(.text._sbrk_r+0xc): undefined reference to `_sbrk' c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m/nofp\libg.a(lib_a-signalr.o): in function `_kill_r': signalr.c:(.text._kill_r+0x12): undefined reference to `_kill' c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m/nofp\libg.a(lib_a-signalr.o): in function `_getpid_r': signalr.c:(.text._getpid_r+0x0): undefined reference to `_getpid' c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m/nofp\libg.a(lib_a-writer.o): in function `_write_r': writer.c:(.text._write_r+0x14): undefined reference to `_write' c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m/nofp\libg.a(lib_a-closer.o): in function `_close_r': closer.c:(.text._close_r+0xc): undefined reference to `_close' c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m/nofp\libg.a(lib_a-fini.o): in function `__libc_fini_array': fini.c:(.text.__libc_fini_array+0x20): undefined reference to `_fini' c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m/nofp\libg.a(lib_a-isattyr.o): in function `_isatty_r': isattyr.c:(.text._isatty_r+0xc): undefined reference to `_isatty' c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m/nofp\libg.a(lib_a-lseekr.o): in function `_lseek_r': lseekr.c:(.text._lseek_r+0x14): undefined reference to `_lseek' c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m/nofp\libg.a(lib_a-readr.o): in function `_read_r': readr.c:(.text._read_r+0x14): undefined reference to `_read' c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: build/ch.elf: hidden symbol `__dso_handle' isn't defined c:/chibistudio/tools/gnu tools arm embedded/10.3 2021.07/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: final link failed: bad value collect2.exe: error: ld returned 1 exit status make: *** [../../../os/common/startup/ARMCMx/compilers/GCC/mk/rules.mk:217: build/ch.elf] Error 1 "make -j8 all" terminated with exit code 2. Build might be incomplete.
Did i add it incorrectly (I realised TRGT isnt an actual path but what should be there instead)? how i do get the project to compile with g++ and not gcc.
Thanks for the advice thus far and to clear things up for my understanding. You're recommending I use an alternate to library like 'newlib' in the link you sent to act as a substitute for the string.h and stdlib.h etc. libraries. because these libraries rely on 'unimplemented system calls'? Is there anyway to use these original libraries as also I soon want to add libraries like 'Eigen' for C++ and do not want to run into similar linking issues?
Are there any docs on how ChibiOS build process works so I can improve my understanding of the entire thing?
What version of GCC compiler are you using? it is already using newlib, my suggestion is to provide those unimplemented functions in your own project in order to silence those linker errors, the linker I sent is the documentation for those functions.
The build process is nothing peculiar, it is enclosed in that rules.mk file and it is shared among all projects. You can enable the "verbose" option in your makefile and you will see exactly all commands during build including the final link phase.