I’m using m1 air mac.
I made 1012.cpp file in "0x09" folder. But I mistyped "cpp" as "Cpp". There was a problem when I compiled this with vscode.
here error message:
cd "/Users/7bella/Desktop/sourcecode/vscode_c/barkingDog/0x09/"
&& clang++ -std=c++17 1012.Cpp -o 1012 && "/Users/7bella/Desktop/sourcecode/vscode_c/barkin
gDog/0x09/"1012
ld: warning: ignoring file 1012.Cpp, building for macOS-arm64 but attempting to link with file built for unknown-unsupported file format ( 0x23 0x69 0x6E 0x63 0x6C 0x75 0x64 0x65 0x20 0x3C 0x62 0x69 0x74 0x73 0x2F 0x73 )
Undefined symbols for architecture arm64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I changed file name to 1012.cpp but still same error.
The error message says, file name is 1012.Cpp even though I changed file name to 1012.cpp
If I change the file name to ex) 1012_1.cpp or change folder name to ex) 0x0A, the error doesn’t occur.
how to fix this problem while keeping the file name 1012.cpp
please help me
if i change the file name to 1012_1.cpp, it works correctly.
here is my task.json file:
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: clang++ 활성 파일 빌드",
"command": "/usr/bin/clang++",
"args": [
"-std=c++17",
"-fcolor-diagnostics",
"-fansi-escape-codes",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "컴파일러: /usr/bin/clang++"
}
]
}
2
Answers
The issue might be that the file extension hasn’t been updated properly.
Try this command:
mv 1012.Cpp 1012.cpp
It would be useful if you share the task.json, anyways, take a look at the file and check if your command option looks similar to this:
"command": "/usr/bin/clang++"
Here you have an example task.json file: