Currently I am including an external library in my xcode project. I have included the libraries manually in my project, so I am able to get all the library function. There is no any compile time errors, but when I am running I am getting runtime error somewhat like mentioned bellow
Undefined symbols for architecture x86_64:
"_zip_error_to_str", referenced from:
Greeting::Greeting() in Myzipclass.o
"_zip_open", referenced from:
Greeting::Greeting() in Myzipclass.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've included libzip libraries in to my project.
More details: I haven't included any framework. Is it necessary to include framework? I am totally new in xcode. If it is necessary to include framework then can anyone tell me procedures to include? I mean, should it be inside the project?
Just concluded from the error info, See if static library libz.1.X.X.dylib have been added to xcode. Otherwise,
targets--->build phases----->link binary with libraries-----> add libz
Related
I downloaded the firebase c++ sdk, 10 jun 2016.
I added the sdk into my iOS project, set the -objc into the other linker flags. And i got a linker error
PLease advice.
The error log is as follows:
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_FIRApp", referenced from:
objc-class-ref in libapp.a(app_ios_efc96a6f6f98f7443dddf841f7396489.o)
"_OBJC_CLASS_$_FIROptions", referenced from:
objc-class-ref in libapp.a(app_ios_efc96a6f6f98f7443dddf841f7396489.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
(EDIT 1)
Framework search path:
$(PROJECT_DIR)/ios/Libs/Firebase
The firebase is in the folder and the includes and the .a libraries.
My problem when I got the same error was that I did not include the iOS SDK along with the C++ library. I did not realize that the C++ library DEPENDS on iOS SDK.
I thought that the the C++ library is a whole new code base that provides the potential for cross-platform development. However, you are still bound to only iOS or Android, but you can choose to code in C++ so you could reuse the C++ code in iOS and Android.
I've previously compiled OpenCV 3.0 successfully following this guide, which essentially consists of the following steps:
Download all the prerequisites (XCode, Command Line Tools, CMake and OpenCV source)
Build static libs by configuring CMake (via gui) with:
Uncheck BUILD_SHARED_LIBS
Uncheck BUILD_TESTS
Add an SDK path to CMAKE_OSX_SYSROOT (if it matters, I used /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk).
Add x86_64 to CMAKE_OSX_ARCHITECTURES (emphasis mine, this seems to be the issue, I'm sure I've followed this step)
Uncheck WITH_1394
Uncheck WITH_FFMPEG
Configure and generate via CMake, then make and sudo make install from the CLI.
All of the above alone works fine.
I'm now looking to compile OpenCV with the extra modules. According to their read-me it should be as simple as filling out OPENCV_EXTRA_MODULES_PATH to <opencv_contrib>/modules in CMake and then building as usual.
I followed the steps outlined above with the added parameter and building OpenCV succeeds, however, when trying to use one of the extra modules in a program (namely cv::ximgproc::createStructuredEdgeDetection, if it matters), I'm getting the following error when compiling:
Undefined symbols for architecture x86_64:
"cv::ximgproc::createStructuredEdgeDetection(cv::String const&, cv::Ptr<cv::ximgproc::RFFeatureGetter const>)", 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've included the header which should include the above:
#include <opencv2/ximgproc.hpp>
I'm compiling via XCode, where I've set an additional header search path of /usr/local/include and a library search path of /usr/local/lib for the project, am I missing something here?
Standard OpenCV functionality works fine.
What could be the issue and how would I go about solving it?
OpenCV contrib modules are built correctly.
You just need to add the contrib libs to your dependencies, in this case adding: -lopencv_ximgproc.
All available libs can be found under <OPENCV_DIR>/install/ folder.
E.g. in my 32bit vc12 static build are in<OPENCV_DIR>/install/x86/vc12/staticlib folder.
Recently I started working with Boost on Windows for a project. It needs to be cross-platform so I also installed it on Mac. Unfortunately; whenever I add it to the Xcode project it gives me a big slew of linker-errors and conversion-warnings.
Example of one of the linker-errors:
Undefined symbols for architecture x86_64:
"boost::system::system_category()", referenced from:
___cxx_global_var_init2 in main.o
boost::asio::error::get_system_category() in main.o
boost::system::error_code::error_code() in main.o "boost::system::generic_category()", referenced from:
___cxx_global_var_init in main.o
___cxx_global_var_init1 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)
Example of one of the conversion-warnings:
In file included from
/usr/local/Cellar/boost/1.57.0/include/boost/date_time/posix_time/posix_time_types.hpp:16:
/usr/local/Cellar/boost/1.57.0/include/boost/date_time/posix_time/posix_time_duration.hpp:24:21: warning: implicit conversion loses integer precision: 'long' to
'hour_type' (aka 'int') [-Wshorten-64-to-32]
time_duration(h,0,0)
I tried several installation methods and configuration methods but it still won't work.
These are my steps:
Compile Boost or get a compiled version of Boost.
Create an XCode project.
Enter this sample code in the main class.
Add the header and library paths to the Xcode project file.
Build.
Compile options I have tried:
Compiling from source using the official guide.
Compiling from source using a few scripts I found here on Stackoverflow.
Installing the brew package manager and downloading a package with binaries.
Configuration options I have tried:
Setting the header search path to /usr/local/Cellar/boost/1.57.0/include or equivalents and
setting the library search path to /usr/local/Cellar/boost/1.57.0/lib or the equivalents.
Setting just the header search path but not the library path.
Option 1 but recursive (causes more errors).
I would appreciate it a lot if someone could point me in the right direction. I think it's something Xcode related since all of the compiled versions give me the same errors.
I found the answer. After the header- and library paths are added to the projects search paths you need to go to "Build Phases". There you need to add the individual libraries you need to the "link libraries to binary" subsection. You can find the necessary files in the lib folder (in the boost folder).
You can choose for either the library files with .a extension or with the .mt.dylib extension. If you choose the .a extension files the library will be added to the compiled version of your program. If you choose the .mt.dylib files then the libraries will not be added to your compiled program. In this case you are assuming the dynamic library files are already present on the computer running the program.
I'm trying to receive information from an 0MQ Socket in C or C++, but therefore I have to include zmq.h. By downloading the 0MQ software from their website and including this file. Xcode gives the following error:
Undefined symbols for architecture x86_64:
"_zmq_init", 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)
When installing ZeroMQ using brew I get the same error. Is there anyone who know a workaround?
The problem here is that you aren't linking the ZMQ library correctly.
You need to build the library once you've downloaded it (they include all the make scripts you need). Once you have that, you will need to link them to the compiler. I'm not too familiar with XCode, but using gcc it would look something like this:
-L/path/to/zmq/library -lzmq
ZeroMQ is really beautiful though. I've used it on Linux/Windows. Hope you get it working!
It is well known that the current version of Qt doesn't allow to convert the project to xcode4 project http://bugreports.qt-project.org/browse/QTBUG-17247. Anyways, at least in theory, it should be possible to compile something in xcode by linking the proper Qt libraries (either dynamic or static), right?
I have taken one Qt 4.7.4 example: "Hello world" and copy/paste the source code into my main. I included the proper headers /QtSDK/Desktop/Qt/473/gcc/include/**. Then I added the three frameworks QtScript, QtCore, QtGui. The linker still gives me errors:
Undefined symbols for architecture x86_64:
"qInitResources_helloscript()", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
I also tried to link with all the libraries in /QtSDK/Desktop/Qt/473/gcc/include/ but still no luck. Also tried with other Qt creator examples, but I get all other sorts of linker errors.