Up vote 4 down vote favorite share g+ share fb share tw.
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 a custom header file, when I try to compile using g++ I get undefined symbols for architecture i386.
The programs compile fine in xCode however. Am I missing something obvious? Tried using g++ -m32 main.cpp... didn't know what else to try.
Okay, The old code compiled... Have narrowed it down to my constructors. Class Matrix{ public: int a; int deter; Matrix(); int det(); }; #include "matrix. H" Matrix::Matrix(){ a = 0; deter = 0; } int Matrix::det(){ return 0; } my error is Undefined symbols for architecture x86_64: "Matrix::Matrix()", referenced from: _main in ccBWK2wB.
O ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status my main code has #include "matrix. H" int main(){ Matrix m; return 0; } along with the usual c++ osx linker g++ terminal link|improve this question edited Apr 28 '11 at 23:31 asked Apr 28 '11 at 12:02maccard5717 100% accept rate.
6 Consider editing your question to include your code, header file, and command line invocations. – Bavarious Apr 28 '11 at 12:05 and of course, the corresponding output ;) – geekazoid Apr 28 '11 at 18:51 Just to be clear, which architecture are you trying to build for? Is it x86_64?
– Troubadour Apr 28 '11 at 23:47.
It looks like you’ve got three files: matrix. H, a header file that declares the Matrix class; matrix. Cpp, a source file that implements Matrix methods; main.
Cpp, a source file that defines 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.
Perfect. My problem was I wasn't including both of my source files in my command line. I didn't realise I had to do that.
Thanks! – maccard Apr 29 '11 at 11:10.
And you are missing a ; after the constructor declaration. – RedX Apr 28 '11 at 13:52 Constructor is defined. The code compiles in XCode.
And no, have a ; at the end of that line, that's just a type sorry. – maccard Apr 28 '11 at 18:46 and you're including Matrix. Cpp in the command line too, right?
– Ken Aspeslagh Apr 29 '11 at 1:37 No, I wasn't including matrix. Cpp in the command line. Thanks!
– maccard Apr 29 '11 at 11:11.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.