Visual Studio Code Help - fatal error C1083

So, I’m using Visual Studio Code currently, since I started with the updated “Section 1”. I’ve made it this far just fine. But now that we’re making our own headers I’m having problems building/compiling.

main.cpp(3): fatal error C1083: Cannot open include file: 'FBullCowGame.h': No such file or directory
The terminal process terminated with exit code: 1

I’ve tried keeping the .h in the same folder as main.cpp and I’ve tried putting it into a headers folder in the same workspace as the main.cpp. I’ve included the path in the c_cpp_properties.json file:

"includePath": [
                "${workspaceFolder}/**",
                "${workspaceFolder}/headers"
            ],

I can’t seem to get it to build correctly and now I’m stuck. I’ve been doing a bunch of googling trying to figure it out too.

Here’s my c_cpp_properties.json:

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "${workspaceFolder}/headers"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.17763.0",
            "compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.20.27508/bin/Hostx64/x64/cl.exe",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "msvc-x64"
        }
    ],
    "version": 4
}

Here’s my launch.json:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(Windows) Launch",
            "type": "cppvsdbg",
            "request": "launch",
            "program": "${workspaceFolder}/main.exe",
            "args": [],
            "stopAtEntry": true,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true
        }

Here’s settings.json:

{
    "files.associations": {
        "string": "cpp",
        "iostream": "cpp"
    }
}

Here’s tasks.json:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "msvc build",
            "type": "shell",
            "command": "cl.exe",
            "args": [
                "/EHsc",
                "/Zi",
                "/Fe:",
                "main.exe",
                "main.cpp"
            ],
            "group":  {
                "kind": "build",
                "isDefault": true
            },
            "presentation": {
                "reveal":"always"
            },
            "problemMatcher": "$msCompile"
        }
    ]
}

so I changed

#include "FBullCowGame.h"
to 
#include "headers/FBullCowGame.h"

and now I’m getting this error:

/debug
/out:main.exe
main.obj
main.obj : error LNK2019: unresolved external symbol "public: int __thiscall FBullCowGame::GetMaxTries(void)" (?GetMaxTries@FBullCowGame@@QAEHXZ) referenced in function "void __cdecl PlayGame(void)" (?PlayGame@@YAXXZ)
main.exe : fatal error LNK1120: 1 unresolved externals
The terminal process terminated with exit code: 1

I figured out that when I tried to build with CTL+SHIFT+B my tasks.json script didn’t include the FBullCowGame.cpp, so that wasn’t compiling when I went to build it. Here’s the full tasks.json that works now:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "msvc build",
            "type": "shell",
            "command": "cl.exe",
            "args": [
                "/EHsc",
                "/Zi",
                "/Fe:",
                "main.exe",
                "main.cpp",
                "FBullCowGame.cpp"
            ],
            "group":  {
                "kind": "build",
                "isDefault": true
            },
            "presentation": {
                "reveal":"always"
            },
            "problemMatcher": "$msCompile"
        }
    ]
}

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms