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.
Related
I have installed dlib using Homebrew.
brew install dlib
Did this:
Add /usr/local/Cellar/dlib/19.16/include to Header Search Paths
Add /usr/local/Cellar/dlib/19.16/lib to Library Search Paths
Add -ldlib to Other Linker Flags
Add Accelerate.framework and change status to "Required" in Link Binary With Libraries
But when I include dlib's .h files have error:
Undefined symbols for architecture x86_64:
"_USER_ERROR__missing_dlib_all_source_cpp_file__OR__inconsistent_use_of_DEBUG_or_ENABLE_ASSERTS_preprocessor_directives_", referenced from:
_dlib_check_consistent_assert_usage 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)
P.S. Yes, i used -v, but it's no effects
At first I am trying to use glad.h in my project. Xcode 7.2.1. gives me the error :
glad.h:26:2: OpenGL header already included, remove this include, glad already provides it.
These are the headers in my main.cpp :
#include "glad/glad.h"
#include <iostream>
#include "GLFW/glfw3.h"
I add GLFW_INCLUDE_NONE to packaging - preprocessor definitions and LLVM - preprocessor macros(similar to preprocessor definitions in Visual Studio I guess?). Then the errors turn to:
Undefined symbols for architecture x86_64:
"_glfwCreateWindow", referenced from:
_main in main.o
"_glfwGetPrimaryMonitor", 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)
If I remove the code #include "glad/glad.h”, the errors remain the same.
Any help is appreciated.
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!
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 am trying to use Protobuf 2.6 with Xcode version 6.3. I've added the libprotobuf-lite.a to my Demo application and added the path to the Header files in the Header Search Paths., but I am getting this error.
Undefined symbols for architecture i386:
"google::protobuf::io::StringOutputStream::StringOutputStream(std::string*)",
referenced from:
attributes::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream*)
in attributes.pb.o ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see
invocation)