VS Code will not build c++ programs with multiple .ccp source files

前端 未结 7 1925
后悔当初
后悔当初 2020-11-29 07:58

Note that I\'m using VS Code on Ubuntu 17.10 and using the GCC Compiler.

I\'m having trouble building a simple program which makes use of additional .ccp files. I\'m

7条回答
  •  一整个雨季
    2020-11-29 08:04

    If you have multiple files and one depends on a cpp file for another, you need to tell g++ to compile it as well, so the linker can find it. The simplest way would be:

    $ g++ Cat.cpp main.cpp -o Classes
    

    As a side note, you should probably compile with warnings, minimally -Wall, likely -Wextra, and possibly -Wpedantic, so you know if something you're doing is problematic.

提交回复
热议问题