Using G++ to compile multiple .cpp and .h files

前端 未结 11 996
耶瑟儿~
耶瑟儿~ 2020-11-22 09:43

I\'ve just inherited some C++ code that was written poorly with one cpp file which contained the main and a bunch of other functions. There are also .h files th

11条回答
  •  生来不讨喜
    2020-11-22 10:12

    As rebenvp said I used:

    g++ *.cpp -o output
    

    And then do this for output:

    ./output
    

    But a better solution is to use make file. Read here to know more about make files.

    Also make sure that you have added the required .h files in the .cpp files.

提交回复
热议问题