c++ - Clang linking error on Mac OSX -
I have a very basic C ++ program that I read on Mac OSX 10.9.3 Main.cpp MyClass.cpp To compile it, I type As a result, I get: Then I Then go to You will not compile Don ' G ++ < / Code> can not be compiled using.
#included "MyClass.hpp" int main () {MyClass :: MyClass obj = MyClass :: MyClass (); Return 0; }
using the namespace "MyClass.hpp "Include my class; my class() { }; Zero method () {};
g ++
g ++ main.cpp -o out
Undefined symbols for architecture x86_64: "MyClass :: MyClass ()", referenced from: _main in main- 2750ac.o ld: symbol (s) not found for architecture x86_64 clags: error: failed with linker command failure code 1 (use -v to view invitation)
g ++ main.cpp -o and get it:
Apple LLVM RAN 5.1 (Clang-503.0.40) (based on LLBS 3.4 SSN) Goal: x86_64-apple-darwin13.2.0 Thread Model: POSIX "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin / Clang "-cc1 -triple x86_64- macosx10.9.0 -emit-obj -mrelax-all-Disable free-disable-LLVM-verifier-main-filename-map.cpp -mrelocation model pickup of apple -pic level 2 -mdisable -FP-elim -masm-verbose -munwind-table -target-cpu core2 -target-linker-version 236.3 -v-source-directories / applications / xcode.app / cantons ts / developer / toolchains / xcodedefault.xctoolchain / usr / Bin /../ lib / knit / 5.1 -stdlib = libc ++ -fdeprecated- macro -fdebug -s Calculus-directory / users / sten / document / information / ateliers C ++ / ateliers / drawing -ferror limit 19 -fmessage-length 120-stack-protector 1 -mstackrealign -fblocks -fobjc -order = macosx-10.9.0 -fencode Extended-block-sign -fcxx-exception -fexceptions -fdiagnostics show-option -fcolor-diagnosis -vectorize -slp -o /var/folders/58/ch14y2yx05v7vy1yvrsmy_3m0000gn/T/main-4d20fb.o-xc++ issue / main Cpp clinging -c1 version 5.1 LLVM 3.4svn Default target x86_64- Darwin13.2.0 ignored nonexistent directory based on apple "/ usr / include / c ++ / v1" #include "..." Search starts here: #include & Lt; ... & gt; Search starts here: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1 / usr / local / /Applications/Xcode.app/Contents/Developer / includes toolchains / XcodeDefault.xctoolchain / usr / bin /../ lib / ring / 5.1 / include /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include / usr / include / system / Library End of search list / framework (framework directory) / library / framework (framework directory). "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.9.0 -o out / var / folders / 58 / Chl4y2yx05v7vylyvrsmy_3m0000gn / T / main -4 d20fb.o -lc ++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.1/lib/darwin/libclang_rt.osx.a undefined symbols "MyClass :: MyClass ()", refers: _main main -4 d20fb.o ld: symbol (s) found for architecture x86_64 Clank: architecture x86_64 error: linker command to exit code 1 ( Failed with the use of -v for
MyClass.cpp Try it:
g ++ main.cpp MyClass.cpp -o out
Comments
Post a Comment