I am having a small problem when using the upnpx library.
I have downloaded the library and opened the upnpdemo workspace. I created in the same workspace a new project to try to create a simple app with this library. I set the parameters like a demo project, but XCode returns 21 errors:
Apple Mach-O Linker Error
Undefined symbols for architecture i386:
"std::string::find(char const*, unsigned long) const", referenced from:
In your new project's build settings, set the C++ Language Dialect and C++ Standard Library to Compiler Default for both of them.
If you build upnpx.a with
**C++ Language Dialect** GNU++11[-std=gnu++11]
**C++ Standard Library** libc++ (LLVM C++ standard library with C++11 support)
In your project you must
iOS Deployment Target 7.0 or above
If you get upnpx.a from web, you can try to lower the Deployment target, 6.
And DO NOT FORGET
**Other Linker Flags**: -lstdc++
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.
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've built a 32 bit library that is a requirement to my project. Here's its lipo info:
LP:lib hcabral$ lipo -info Release-iphoneos/librmservices_iphone.a
input file Release-iphoneos/librmservices_iphone.a is not a fat file
Non-fat file: Release-iphoneos/librmservices_iphone.a is architecture: armv7
I link the library in my project, it shows up in "Link Binary with binaries", etc., and yet I get this error:
Undefined symbols for architecture armv7:
"std::_List_node_base::hook(std::_List_node_base*)", referenced from:
xpath::YaccParser::getObjectPointer(uft::Value*&, bool) in librmservices_iphone.a(xpath_yacc.o)
xpath::YaccParser::performLexicalAnalysis(uft::Value*&) in librmservices_iphone.a(xpath_yacc.o)
"std::_Rb_tree_rebalance_for_erase(std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)", referenced from:
xpath::Context::removeDynamicContext(uft::Value const&) in librmservices_iphone.a(xpath_context.o)
"_kCFProxyPasswordKey", referenced from:
DLProxySettingsController::getSystemProxySettings() in librmservices_iphone.a(DLProxySettingsController.o)
"_kCFNetworkProxiesHTTPProxy", referenced from:
(...)
All the projects I limited to armv7 and no solution. Any ideas?
So, I have a project A that is pure Objective-C, but it depends on a Project B that is C/C++ and Objective-C, and happens to be 32-bit code only.
Up until Mavericks and Xcode 5.1.1, I built Project B for all platforms (Release and Debug for iOS and i386) in order to debug, run tests and eventually deploy. Project B has its own set of linker flags and options that make it very special.
In project A, I would link the binaries of Project B (libProjectB.a) and it has always worked.
However, during this last iteration, Project A build process complained about missing symbols for armv7, which confused me, because project B is compiled ONLY in armv7 and i386.
The only way I manage to remove 30+ linking errors, was by linking the following frameworks:
libstdc++.6.0.9.dylib
CoreText.framework
CFNetwork.framework
Foundation.framework
I hope these don't look like random frameworks to you, but I found out by adding one by one, based on the type of linking error. For example, I added the CFNetwork only after opening the C++ code and noticing that the symbols would be part of it.
Anyway, again, I don't know why it happened yet, but it happened by using Yosemite and Xcode 6.1. Hope this can shed a light on someone.
I'm trying to create a library of a group of files .cpp and .hpp in xcode.
All files run right in the simulator and in the device without library.
And I have created the library and I have run it in the simulator (architecture x86) and run quite well.
When I tried to run the app with the library in the device I get an error like I would have forgotten any files:
Undefined symbols for architecture armv7:
"ssm::partialSortGreater(int, std::__1::vector<float, std::__1::allocator<float> > const&, std::__1::vector<int, std::__1::allocator<int> >&)", referenced from:
but It's running in the simulator with the same files, it's mental :S
thanks :)
Update:
BuildSettings:
Library and App
Update 2:
Moreover if I Archive the app and I install it with iTunnes, works!!! in the device :S Very weird
A few things to check in this instance:
Make sure the library is not set to "Build active architecture only" and make sure that it has ARMv7 set as a valid architecture.
Also, make sure that the main project has your library listed in the Build phases under Target Dependancies and Link Binary with Libraries.
If your library is not building the proper architecture or if your main project is not dependent on it's changes and not currently being linked against the static library your main project will not know that the static library exists.
I'm very new to xcode and c++ programming so please let me know if I'm going about this all wrong. Basically, I want to create a C++ project that requires a library to deal with making and receiving json calls. (this will eventually be integrating as the 'engine' of an iOs and android app.) I want to use xcode to create this and I tried installing libjson but couldn't get it to recognize. I then tried using JsonCpp and followed the instruction.
1) I downloaded the tar.gz
2) I downloaded the scons python program and in the jsoncpp folder and ran the appropriate command (something like 'python scons.py platform=linux-gcc check')
This created a .a and a .dylib file
Next, i tried to move the files into the project and link it in xcode from 'Link Binary With Libraries' portion of the Build Phases tab in the project settings.
I linked up the code to my file with an include statement:
#include "lib/jsoncpp/json.h"
This led to the following error:
Undefined symbols for architecture x86_64:
"Json::Reader::parse(std::__1::basic_string, std::__1::allocator > const&, Json::Value&, bool)", referenced from:
jsonParser::parseLogin(std::__1::basic_string, std::__1::allocator >&, std::__1::basic_string, std::__1::allocator >&) in jsonParser.o
ld: symbol(s) not found for architecture x86_64
(null): "Json::Reader::parse(std::__1::basic_string, std::__1::allocator > const&, Json::Value&, bool)", referenced from:
All I am trying to do is set up this library but It has been keeping me from working on my code for the past day looking for a solution.
For the libjson library, I tried following the directions here but with similar issues:
Cannot Install libjson in c++ Embedding in XCode 4 Project
Does anyone have any advice on steps I can take to set this up? Thank you for your time.
In the project navigator (left side of XCode), click above your project. Then:
Build Phases -> Link binary with libraries
Here is where you add all libraries and/or frameworks that will be linked to your application. Leave this page open, then drag and drop the libraries inside the libraries area... that's it! no secret!
If it doesn't work. You are probably with a wrong library. Try lipo -info library to check if the library architeture is the same you are trying to use (x86_64 in this case).
If it still doesn't work. You are probably with C++ incompatibility. Any mixing of libstdc++ and libc++ in builds will cause trouble. All C++11 code built with clang should set an environment variable: CXX=clang++ -std=c++11 -stdlib=libc++, or add CXX="clang++ -std=c++11 -stdlib=libc++" as an argument to configure.). If you compiled libjson via command line, check it again. But, for libJSON, it's much easier if you open a new XCode Project and add the files to the project instead of compile it via command line.
In the end, I tried just copying the entire source project into my xcode project and building it. it ended up solving the issue.
This is How I solved the issue:
download libjson from sourceforge
unzip it.
-
move the _internal folder, libjson.h, and JSONOptions.h into the
xcode project folder
add those files to your xcode project
remove the test suite files from this project as you don't need them
build your main to test it and you should be good to go.