0

i was trying a simple main that calls a test function with a header file. and when running this message pops out

main.cpp:(.text+0xe): undefined reference to test(char)'
collect2: error: ld returned 1 exit status

Found out that in order to make this work i had to change the "${file}" with "${workspaceFolder}" in args of the tasks.json file. The first issue is that i don't have a tasks.json file, so i used the configure default build task that made it, but then, when i try to change the ${file} with ctrl space there are no option for other folders, even trying to manually insert workspaceFolder does not work`

3
  • I'm pretty sure, that the default task/launch configuration does not allow splitting up the code to multiple source files. I would recomment using a build system like CMake. (cmake.org/cmake/help/latest/guide/tutorial/… ) ( I do personally like the CMake-Integration in VS Code )
    – arch
    Commented Mar 30 at 19:47
  • "try to change the ${file} with ctrl space there are no option for other folders" Well yeah, ctrl+space isn't always going to magically suggest the right thing. Type the path manually. Commented Mar 30 at 19:55
  • 2
    @arch tasks.json just runs whatever shell command you throw at it, of course it can compile multiple files. (CMake could beneficial long-term, but it's not strictly necessary.) What doesn't support multifile programs is the "code runner" extension. Commented Mar 30 at 19:56

0

Browse other questions tagged or ask your own question.