Having to manually link .cpp files on VS Code?

Now that I have two CPP files. I have to run the code by typing in “cl main.cpp FBullCowGame.cpp” every time or it gives me linker issues when I try to run the program

if I just do “cl main.cpp” and then run it, this is what happens

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

is there a way I can link every cpp without typing in them all in every time in the terminal
I included the header in both CPP’s I thought the compiler would link them for me

As stated in Discord, use a build task in VSCode.

I forgot about setting up debugging when I made this will probably re-do it soon unless Ben beats me with the redo of section 1.

Alternatively use a proper build system.

1 Like

When I click ctrl + shift + b It shows “C/C++: cl.exe build acttive file”

but the “Detect Tasks” prompt does not appear.

Did you launch code through the dev command prompt and do you have the latest version of the C/C++ extension?

I downloaded the C/C++ extension two days ago so I am assuming it is the latest but I can check.

I launched the code using the “cl” command in the terminal. I don’t know what you mean by that.

Yes, it’s the current version of C/C++

version 0.22.1

It’s showcased in the video. VS Code is launched through the developer command prompt by typing “code”.

Edit: actually I just tested it and it still shows up regardless could you show me what you have?

Yes, I opened VScode through the developer command prompt. Sorry for the confusion.

this is what I’m seeing

Solved on Discord

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

Privacy & Terms