I got a error ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1
You haven't told g++
to compile and link in StackFrame.cpp
.
Where you have
$ g++ main.cpp -o main
you should have
$ g++ main.cpp StackFrame.cpp -o main -lstdc++
The addition of -lstdc++
might not be required with newer versions of g++.
C++ compilation error: ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
You didn't link with the test.o
.
g++ -c test.cpp -o test.o
g++ mainTest.cpp test.o -o mainTest
or you can do them both at once:
g++ maintest.cpp test.cpp -o mainTest
GCC: Getting ld: symbol(s) not found for architecture x86_64 error on OS X 10.11.5
Your code works fine for me using clang.
What is your command for compilation?
Try
g++ test1.cpp -o test
That works for me.
C++ XCODE ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
The problem was caused by using templates in the header .hpp and implementation .cpp files. After moving the implementation .cpp code into the header and removing the .cpp file it worked. This post helped me fix/understand the issue: c++ template and header files.
Related Topics
How to Convert a Tchar Array to Std::String
Should Function Declarations Include Parameter Names
C++ Arrays as Function Arguments
Has a Std::Byte Pointer the Same Aliasing Implications as Char*
Neatest Way to Loop Over a Range of Integers
Why Is My Class Non Default-Constructible
Convert Byte Array into Bitset
How to Set Background Color of Window After I Have Registered It
Optimizing a Branch for a Known More-Common Path
Why Is Operator""S Hidden in a Namespace
C++11 Struct Initialization Compilation Error
Can a Lambda Capturing Nothing Access Global Variables
Msvc Equivalent of _Attribute_ ((Warn_Unused_Result))
How to Add Playable(Such as Wav,Wmv) Header with Pcm Data/Buffer in iOS
Macro and Member Function Conflict
Gdb - List Source of Current Function Without Typing Its Name