c++coderunner

CodeRunner and multiple file projects


So far, I have used CodeRunner to compile a single C++ file. I can't figure out how to compile two files together using CodeRunner's run settings. I am running CodeRunner 2.0.1 on Yosemite. I need to know how to adjust CodeRunner's run settings to get this to work. The files are in the same directory.

When I try something like adding the compiler flag -o filename file2.cpp when compiling file1.cpp, I get the error: bash: ./file1: No such file or directory. I need to know how to include other files with the compilation of file1.cpp.


Solution

  • CodeRunner does it automatically for you, provided you are still using the default C++ compile script provided with the app and you have placed both file1.cpp and file2.cpp in the same folder. Generally it is not necessary to use compiler flags as you would with Clang on the command line to specify multiple file compilation (which is the compiler invoked by default by CodeRunner).

    CodeRunner analyses your include statements and puts together the compile command which is then used by Clang. If for some reason the automatic compilation does not work, you can disable this behavior by using the compiler flag -cr-noautoinclude and supplying each cpp file as a separate compiler flag.

    The resulting executable that is produced will take its name from the ___FILEBASENAME___ variable of the file that has the main() entry point function.