I\'ve recently moved over to a mac, and am struggling using the command line compilers. I\'m using g++ to compile, and this builds a single source file fine. if I try to add
It looks like you’ve got three files:
Matrix
class;Matrix
methods;main()
and uses the Matrix
class.In order to produce an executable with all symbols, you need to compile both .cpp files and link them together.
An easy way to do this is to specify them both in your g++
or clang++
invocation. For instance:
clang++ matrix.cpp main.cpp -o programName
or, if you prefer to use g++
— which Apple haven’t updated in a while, and it looks like they won’t in the foreseeable future:
g++ matrix.cpp main.cpp -o programName