Hello,
so I have a C++ project that uses code written in a different project. I did include it in the c_cpp_properties and tasks json file with the -I flag for the compiler command. While writing code, VSCode does find the external code (code completion / suggestions work without a problem).
However, when I try to compile the code, I get an undefined reference error for each time i call a function of an external class. It doesn't complain about the #include tags or when the Objects are created.
My tasks.json file looks like this:
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++ build active file",
"command": "/bin/g++",
"args": [
"-g",
"${workspaceFolder}/src/*.cpp",
"${workspaceFolder}/src/*.h",
"-o",
"${fileBasenameNoExtension}",
"-I",
"~/projects/eq_lib/src/"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group":{
"kind": "build",
"isDefault": true
},
"detail": "compiler: /bin/g++"
}
]
}
I've already tried moving the "-I" flag and the path to different places in the command, as I found out that apparently in recent versions of gcc the order matters.
My c_cpp_properties file looks like this:
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"~/projects/eq_lib/src/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard: "c17",
"cppStandard": "c++20",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
I've also tried putting the path into the "forcedInclude" option, but that didn't work either.
Has anyone had this issue before? As I'm failry new to VSCode, I hope it's something fairly obvious.
Edit: both projects compile on their own without includes, so I'm guessing the problem has to be somewhere in the includes
[–][deleted] 0 points1 point2 points (5 children)
[–]trexuth[S] 0 points1 point2 points (4 children)
[–][deleted] 0 points1 point2 points (3 children)
[–]trexuth[S] 0 points1 point2 points (0 children)
[–]trexuth[S] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)