use of cURL library - c++

I want to write common code that work for both iPhone and android. For that I want to use cURL library that work fine for android but for iOS it gives me following error:
(null): "_curl_easy_cleanup", referenced from:
(null): "_curl_easy_init", referenced from:
(null): "_curl_easy_perform", referenced from:
(null): "_curl_easy_setopt", referenced from:
(null): "_curl_easy_strerror", referenced from:
(null): Linker command failed with exit code 1 (use -v to see invocation)
Above error indicate some linking error for libcurl.a. I am not able to find out proper solution. Please help.

Have you added libcurl.a to the linking process of your app's compilation in XCode? If this were GCC it would be by adding a flag like -lcurl but I am not too sure about XCode.
Try this:
XCode -> Click on your project -> Your Target -> Build Settings -> Linking -> other Linker flags - here add -lcurl
The path to the library might need to be added in Build Settings -> Search paths -> Library Search Paths

Related

linking Boost library to Xcode project

I'm trying to create a project that uses the Boost library. I'm on OS X 10.9.5 (I should update that) and using Xcode 6.2. I installed boost with homebrew brew install boost and it's located in /usr/local/Cellar/boost/1.59.0. I added the path the the /usr/local/Cellar/boost/1.59.0/include to the header search path in Xcode and it seems to recognize it because the autocomplete hinting works.
In the boost documentation it mentions that some of the Boost libraries must be built before they can be used. I assume homebrew took care of that because I have a bunch of .a and .dylib files in /usr/local/Cellar/boost/1.59.0/lib
I'm still new to C++ and the Xcode build process but it seems I still need to link the compiled libraries to my project. I tried adding the path /usr/local/Cellar/boost/1.59.0/lib to my project's library search paths but I'm not sure if that is correct.
Here is the error I get when I try to build my project.
Undefined symbols for architecture x86_64:
"boost::filesystem::detail::create_directory(boost::filesystem::path const&, boost::system::error_code*)", referenced from:
boost::filesystem::create_directory(boost::filesystem::path const&) in main.o
"boost::filesystem::detail::status(boost::filesystem::path const&, boost::system::error_code*)", referenced from:
boost::filesystem::exists(boost::filesystem::path const&) in main.o
"boost::system::system_category()", referenced from:
___cxx_global_var_init2 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)
Is there something else I need to configure to get this to work?
Adding the path is correct but you also need to specify the libraries you need. On the commandline you would use -l for that in Xcode you can add them to Other Linker Flags.
The libraries you need are boost_filesystem and boost_system.

how to compile C++ - libsndfile on iOS

ld: warning: ignoring file /Users/vibhavarirajadnya/MyDev/iOS-Projects/Music/POC/ReadWaveFile/ReadWaveFile/libsndfile.a, file was built for archive which is not the architecture being linked (i386): /Users/vibhavarirajadnya/MyDev/iOS-Projects/Music/POC/ReadWaveFile/ReadWaveFile/libsndfile.a
Undefined symbols for architecture i386:
"_sf_close", referenced from:
SndfileHandle::SNDFILE_ref::~SNDFILE_ref() in ReadWaveFile.o
"_sf_open", referenced from:
SndfileHandle::SndfileHandle(char const*, int, int, int, int) in ReadWaveFile.o
"_sf_strerror", referenced from:
SndfileHandle::strError() const in ReadWaveFile.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I tried compiling libsndfile file in 3 ways:
1. ./configure then make and make install through command prompt.
2. http://ofdsp.blogspot.in/2011/07/installing-libsndfile-with-xcode.html
3. http://en.efreedom.net/Question/1-11576168/Cross-Compile-Libsndfile-Arm-Raspberry-Pi
With the first option I am getting the error mentioned above. With the second, I am getting some 69 errors most of them related to FLAC. With the third option I am getting the same as 1. It also gives a msg in the command prompt:
Installation directories :
Library directory : ................... /Users/vibhavarirajadnya/Arm/lib
Program directory : ................... /Users/vibhavarirajadnya/Arm/bin
Pkgconfig directory : ................. /Users/vibhavarirajadnya/Arm/lib/pkgconfig
HTML docs directory : ................. /Users/vibhavarirajadnya/Arm/share/doc/libsndfile1-dev/html
But when I check in Finder, there is no such directory.
Can somebody tell me a step by step method to compile libsndfile and its dependencies for Mac iOSX?

Linker errors after changing source file type to Objective-C++

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?)

Error using RegexLiteKit to draw rout on mapview

In one of my iphone projects I have used the RegexLiteKit for drawing rout in my mapview. While compiling the following failures are showing,
Undefined symbols for architecture i386:
"_uregex_start", referenced from:
_rkl_performRegexOp in RegexKitLite.o
_rkl_search in RegexKitLite.o
_rkl_findRanges in RegexKitLite.o
"_uregex_end", referenced from:
_rkl_performRegexOp in RegexKitLite.o
_rkl_search in RegexKitLite.o
_rkl_findRanges in RegexKitLite.o
"_uregex_setText", referenced from:
_rkl_clearCacheSlotSetTo in RegexKitLite.o
_rkl_setCacheSlotToString in RegexKitLite.o
"_uregex_find", referenced from:
_rkl_search in RegexKitLite.o
"_uregex_findNext", referenced from:
_rkl_search in RegexKitLite.o
_rkl_replaceAll in RegexKitLite.o
"_u_errorName", referenced from:
_rkl_NSExceptionForRegex in RegexKitLite.o
_rkl_userInfoDictionary in RegexKitLite.o
"_u_strlen", referenced from:
_rkl_userInfoDictionary in RegexKitLite.o
"_uregex_reset", referenced from:
_rkl_replaceAll in RegexKitLite.o
"_uregex_appendReplacement", referenced from:
_rkl_replaceAll in RegexKitLite.o
"_uregex_appendTail", referenced from:
_rkl_replaceAll in RegexKitLite.o
"_uregex_open", referenced from:
_rkl_getCachedRegex in RegexKitLite.o
"_uregex_groupCount", referenced from:
_rkl_getCachedRegex in RegexKitLite.o
"_uregex_close", referenced from:
_rkl_clearCacheSlotRegex in RegexKitLite.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Is there any way to make RegexLiteKit work? please help..
go to your target build settings
search for linker flags
double tap near other linker flags and add -licucore
done
Add libicucore framework to your project solve this issue and for reference go through this link http://www.mobisoftinfotech.com/blog/iphone/iphone-regular-expression-tutorial-regexkitlite-framework/
I have solve this issue by adding libicucore framework to my project.The way to add libicucore frame work Build Settings-> Linking->Other Linker Flags --> -licucore
You need to set linker flags below are steps to do same.
Go to Build Settings-> Linking->Other Linker Flags --> -licucore
Don't forget to add - above licucore
If you are not using arc for project then please add compiler flag -fno-objc-arc for RegexKitLite.m.
Next you must add Other linker flag by follow:
Build Settings > Linking > Other Linker Flags
Add:
-licucore
-ObjC
-lc++
Thanks,
For iOS 9.2 and Xcode 7, I solved the problem as follow
Click your project
Click target
Click "Build Phases" tab
Double click RegexKitLie.m
Enter -fno-objc-arc in opend box
Done and enjoy.

undefined symbols Undefined symbols for architecture x86_64: "_kCFAllocatorDefault"

I am trying to compile some stuff under mac os 10.7 in eclipse and the build dies on:
Undefined symbols for architecture x86_64:
"_kCFAllocatorDefault", referenced from:
___GLeeGetProcAddress in GLee.o
"_CFURLCreateWithFileSystemPath", referenced from:
___GLeeGetProcAddress in GLee.o
"_CFStringCreateWithCString", referenced from:
___GLeeGetProcAddress in GLee.o
"_CFBundleCreate", referenced from:
___GLeeGetProcAddress in GLee.o
"_CFBundleGetFunctionPointerForName", referenced from:
___GLeeGetProcAddress in GLee.o
"_CFRelease", referenced from:
___GLeeGetProcAddress in GLee.o
"_glGetString", referenced from:
___GLeeGetExtensions in GLee.o
_GLeeGetExtStrGL in GLee.o
_GLeeInit in GLee.o
(maybe you meant: _GLee_Lazy_glGetStringi, _GLeeFuncPtr_glGetStringi )
"___CFConstantStringClassReference", referenced from:
CFString in GLee.o
So I know the problem is with ld symbols. Now I tried going to project proprieties and adding -framework CoreFramework to parameters of g++ and gcc in eclipse but that didnt fix it.
Where are these symbols located and more importantly - how do I add them to my project?
I fixed this by adding a .dylib to linker. How to set it up?
Go to project proprieties
Go to C/C++ build --> settings
Choose Mac OS X C++ Linker --> Libraries
Here is where the tricky part is... I found out by "try-error" method, how this works:
Lets say you have a dylib file you want to add called "libMyLib.dylib" located in /opt/local/lib/MyLibrary
To part of the window where it says libraries add line
"MyLib"
To part of the window where it says Library search path add line
"/opt/local/lib/MyLibrary/"
=> eclipse will automatically do this:
1. add "lib" in front of the string
2. add ".dylib" after your string
There comes another problem with Mac... Lets say you use symbols from CoreFoundation framework. Mac OS frameworks are essentialy dylibs with header files ... If you are not sure you can always check by "file myFile"
The problem is that eclipse will never correctly pick up on those dylibs from MAC OS SDK and /System/Library/Frameworks/ cause they dont have the .dylib added to them. The trick is to simply go to where the dylib is located (eventhough it doesnt have a .dylib in its name) e.g.
cd /System/Library/Frameworks/CoreFoundation.framework
and then copy the file and add dylib (do NOT RENAME IT!!!)
file CoreFoundation
CoreFoundation (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
CoreFoundation (for architecture i386): Mach-O dynamically linked shared library i386
#copy the lib and name it to "eclipse friendly format"
cp CoreFoundation libCoreFoundation.dylib
You can use the -framework option
e.g. g++ -framework CoreFoundation ..........