Below error occurs while I was writing two functions xxxx as part of uni work. The IDE I'm using is Visual Studio Code.
The problem was that when I tried to compile a single file in the folder code/myIO, it threw an error:
(I've replaced the folder's path with ($). I promise the problem wasn't there)
cd ($) && clang++ r.cpp -o ($)/r -D LOCAL -Wall -O2 -fsanitize=undefined
Undefined symbols for architecture arm64:
"_Tp::INT", referenced from:
split(char const*, _Tp*) in r-ebf422.o
"_Tp::fmt", referenced from:
split(char const*, _Tp*) in r-ebf422.o
"_Tp::str", referenced from:
split(char const*, _Tp*) in r-ebf422.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
What's more, when I tried to link some files, similar error happened.
clang++ -shared -o libmystdio.so myscanf.o myprintf.o
Undefined symbols for architecture arm64:
"_Tp::INT", referenced from:
split(char const*, _Tp*) in myscanf.o
split(char const*, _Tp*) in myprintf.o
"_Tp::fmt", referenced from:
split(char const*, _Tp*) in myscanf.o
split(char const*, _Tp*) in myprintf.o
"_Tp::str", referenced from:
split(char const*, _Tp*) in myscanf.o
split(char const*, _Tp*) in myprintf.o
"_Tp::LONG", referenced from:
split(char const*, _Tp*) in myscanf.o
split(char const*, _Tp*) in myprintf.o
"_Tp::LONGLONG", referenced from:
split(char const*, _Tp*) in myscanf.o
split(char const*, _Tp*) in myprintf.o
"_out_buf", referenced from:
myprintf(char const*, ...) in myprintf.o
"_out_idx", referenced from:
myprintf(char const*, ...) in myprintf.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [libmystdio.so] Error 1
In case you wonder what I've written, please click here. However it's not finished,I doubt you would be interested...(I made a few comments and most of them are in Chinese, for my groupmates to read)
And, files in folder code aren't affected. They can be compiled and run normally.Only those in folder code/myIO went wrong.
Here's my clang++ version:
clang++ -v
Apple clang version 12.0.5 (clang-1205.0.22.11)
Target: arm64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
Thanks for your help in advance!