after configuring the CPP development environment with Visual studio code, you want to reference other files in the main function, but always report Undefined symbols for architecture x86Secret64: error
under Mac. The code is as follows:
a.h file
int func();
a.cpp file
-sharpinclude <iostream>
-sharpinclude "a.h"
using namespace std;
int func(){
return 0;
}
main.cpp file
-sharpinclude <iostream>
-sharpinclude "a.h"
using namespace std;
int main()
{
int b = func();
cout << b << endl;
}
Press F5 to start debugging output:
> Executing task: gPP /Users/stanhu/Desktop/Git/Foundation/CPP_Learn/main.cpp -o /Users/stanhu/Desktop/Git/Foundation/CPP_Learn/main.out -g -Wall -fcolor-diagnostics -std=cPP11 <
Undefined symbols for architecture x86_64:
"func()", referenced from:
_main in main-d53c96.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The terminal process terminated with exit code: 1
how to solve this problem. In addition, how to properly reference the h file of a third party?