Code: Select all
#include <string.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
and make use of the string data type and strncmp function:
Code: Select all
string test = "blah";
if(strncmp("GT",(char*)buffer,2) == 0){
cmd = 1;
Upon building I get the following errors:
Code: Select all
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.
16:07:13 Build Failed. 17 errors, 5 warnings. (took 3s.187ms)
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?