I am trying to make a static library (.a file) and I have a main.cpp (Where I call the function), a library.cpp (The code of the library) and a header file which should work in theory (I watched and followed countless tutorials about how to do it) but it doesn't.
It gives me the error: identifier "Sus" is undefined (Where Sus the name of the function)
I tried changing the include path by following this answer: How to avoid errors in Vscode for putting header files in a separate directory than src but it doesn't help since the files are already in the same folder, I also tried including the specific path in the IncludePath but still no luck. I tried rewriting, reinstalling VSCode and even creating again the project but it doesn't work.
Here is my task.json:
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: cl.exe build active file",
"command": "cl.exe",
"args": [
"/Zi",
"/EHsc",
"/nologo",
"/Fe${fileDirname}\\${fileBasenameNoExtension}.exe",
"${file}",
"${workspaceFolder}/include/**"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$msCompile"
],
"group": "build",
"detail": "compiler: cl.exe"
}
]
}
And my c_cpp_propreties.json:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/include/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.19041.0",
"compilerPath": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "windows-msvc-x64"
}
],
"version": 4
}
Header File(Teroro.h):
#pragma once
class Teroro{
public:
static int Sus(int a, int b);
};
Library File(Teroro.cpp):
#include "Teroro.h"
int Sus(int a, int b)
{
return a+b+69;
}
And the Main File(Main.cpp):
#include "Teroro.h"
#include <iostream>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
cout<<Sus(a,b);
}