I am currently working on a c++ project using xcode 8, and I keep getting this error:
Undefined symbols for architecture x86_64:
"liblas::Reader::Reader(std::__1::basic_istream<char, std::__1::char_traits<char> >&)", referenced from:
_main in main.o
"liblas::Reader::~Reader()", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have compiled boost, liblas, etc. I have it included in my cmakelists.txt as well, and have the folder it is included in listed in 'Framework Search Paths' as well as 'Header Search Paths'. My compiler is the xcode 8 default of Apple LLVM 8.0. My deployment target is 10.11. The valid architectures are 'x86_64' and 'i386'.
Here is the code that attempts to use libLAS (file.las contains a hardcoded path to my las file). This code was pulled directly off the libLAS c++ tutorial here:
std::ifstream ifs;
ifs.open("file.las", std::ios::in | std::ios::binary);
liblas::ReaderFactory f;
liblas::Reader reader = f.CreateWithStream(ifs);
If I comment out the line liblas::Reader reader = f.CreateWithStream(ifs);, the code compiles fine, and produces a valid executable. With this line here, it throws the error. I need to be able to read LAS files with this project however, so I need to try to get the Reader to work.
So my questions are:
Is there a better way to debug this?
Is this an obvious error that I'm missing?
Is this an issue with the library? (libLAS)
What can I do to get this working?
Thanks to anyone in advance!
Related
I've been trying to build UETorch for OSX 10.12 using Xcode and have encountered the following error:
Undefined symbols for architecture x86_64:
"FlushRenderingCommands()", referenced from:
_CaptureScreenshot in Module.UETorch.cpp.o
InitCapture(UObject*, IntSize const*, FViewport**, APlayerController**, UWorld**, FSceneView**) in Module.UETorch.cpp.o
"FSlateApplication::CurrentApplication", referenced from:
_CaptureScreenshot in Module.UETorch.cpp.o
FSlateApplication::Get() in Module.UETorch.cpp.o
"FSlateApplication::TakeScreenshot(TSharedRef<SWidget, (ESPMode)0> const&, FIntRect const&, TArray<FColor, FDefaultAllocator>&, FIntVector&)", referenced from:
_CaptureScreenshot in Module.UETorch.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
It seems like the ld: symbol(s) not found... part is often fixed by using libstdc++ instead of libc++ and I have tried adding -stdlib=libstdc++ to "Other Linker Flags" as well as linking libstdc++.6.0.9.dylib in the Build Phases section but I am still getting the same error.
I don't have the reputation to comment hence adding it here, you get undefined symbols when you try to use the symbol/Call the function and the linker can not find its definition. So if the definition is from some library then add it during your linking stage.
You can check if the definition is present or not in the library by using nm command, e.g. "nm -D"
I'm using Eclipse and have been including the relevant libraries in the project folder as I build. Now that I'm a bit further in the course, I'm trying to
#include "vector.h"
but building gives 16 warnings that look like:
In file included from ../CS106B_Prog_Ass01_05.cpp:6:
Finished building: ../CS106B_Prog_Ass01_05.cpp
../vector.h:560:26: warning: range-based for loop is a C++11 extension [-Wc++11-extensions]
and the following error that prevents the project from building:
Undefined symbols for architecture x86_64:
"mainWrapper(int, char**)", referenced from:
_main in CS106B_Prog_Ass01_05.o
"__mainFlags", referenced from:
_main in CS106B_Prog_Ass01_05.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [CS106B_Prog_Ass01_05] Error 1
I would love to simply link to the library folder, but that results in a similar error even if I switch it to a different architecture. Has anyone had this problem?
I'm struggling with a Linker error in Xcode. I've created the amalgamated source, added the jsoncpp.cpp as a source file to my project, I've set the header search path to jsoncpp-master/dist and use
#include "json/json.h"
#include "json/json-forwards.h"
as described at https://github.com/open-source-parsers/jsoncpp. Still, I'm getting an undefined symbols error:
Undefined symbols for architecture x86_64:
"output(Json::Value)", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I found that it works if json/json.h, json/json-forward.h and jsoncpp.cpp are copied to the project directory. jsoncpp.cpp is added as a source file and json/json.h as a header. However, NO additional header search paths are set.
Trying to compile my C++ application using clang which works but I get the following linker error:
Undefined symbols for architecture x86_64:
"_DADiskCopyDescription", referenced from:
Security::getHddID() in Security.cpp.o
"_DADiskCreateFromBSDName", referenced from:
Security::getHddID() in Security.cpp.o
"_DASessionCreate", referenced from:
Security::getHddID() in Security.cpp.o
ld: symbol(s) not found for architecture x86_64
I've checked the official documentation for Disk Arbitration on the Apple website but that's awful, since it doesn't even tell you which library file to include, let alone what to link to.
I'm using CMake to set up my build chain.
You need to use -framework DiskArbitration in your linker arguments.
I have an OpenGL ES 2.0 application, and would like to use C++ code in a view controller implementation. However, after changing the file extension to mm (or even just adjust the source type without changing the filename), the following errors are encountered during linking:
Undefined symbols for architecture armv7:
"_GLKMatrix4Identity", referenced from:
GLKMatrix4MakeTranslation(float, float, float) in GameViewController.o
"_OBJC_METACLASS_$_GLKViewController", referenced from:
_OBJC_METACLASS_$_GameViewController in GameViewController.o
"_OBJC_CLASS_$_GLKViewController", referenced from:
_OBJC_CLASS_$_GameViewController in GameViewController.o
"_GLKMatrix3InvertAndTranspose", referenced from:
-[GameViewController update] in GameViewController.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Any suggestions are welcome.
I manually added the GLKit framework in build phases settings.
(Interesting question though - why didn't the app require it when no C++ source was involved -- how could it possibly compile and run?)