Qt link library (C++ mix with objective C) error - objective-c

I am using Qt to build UI Application,
The Qt application supposed to link to a static library (.a file)
The library is written by C++ and Objective C (*.mm) files.
I setup the Qt project file and linked the static library, but Qt Creator always gets linking error, and error is related with the function implement on *.mm which locates in the static library.
Question:
The Qt application how to link the library?
that's pure C++ application (Qt application) link to static library with C++ and ObjectiveC mixed (.a file).
update: link error
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_QTCaptureDevice", referenced from:
objc-class-ref in libmyapi.a(myTestFunction_mac.o)
"_QTMediaTypeVideo", referenced from:
myTestFunction() in myapi.a(myTestFunction_mac.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: *** [myApp.app/Contents/MacOS/myApp] Error 1
14:38:06: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project myApp (kit: Desktop Qt 5.1.0 clang 64bit)
Qt5.1 with clang, support C++11
static library myapi.a, built by Xcode4.6 without error. Only one file is myTestFunction_mac, using QTKit framework.
myApp links myapi.a, but the myTestFunction_mac.mm implantation file has linking error.

You need to add QTKit framework to your app target.
Xcode 4
Click on the project in the browser pane to the left.
Click on the target under Targets.
Click on the Summary tab.
Expand Linked Frameworks and Libraries if not expanded.
Click on the + icon and type QTKit into the search box and add QTkit.
Xcode 3
Right click on the project.
Select Add-->Existing Frameworks.
Add QTkit.

Related

How to solve "Undefined symbols for architecture x86_64:"?

I've done hours and hours of searching and still no luck (read a lot of stackoverflow as well).
I am trying to implement FDTake via Cocoapods. When I try and run it I get the following:
undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_FDTakeController", referenced from:
objc-class-ref in VendeViewController.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 know there is many similar questions around SO but all their solutions don't seem to work for me.
From the logs I can assume that you would be using a static library which is not build for simulator(architecture x86_64).
The library is only compiled for device and it needs to be complied and build for simulator also. Then the two static files (one abc.a for device and one abc.a for simulator) needs to be fat file i.e these files should be merged together using lipo command on terminal to create a fat file. Now when you use this fat file it will work both for simulator as well as device.
But the important thing is that you should have the source to compile and build the static libraries for simulator and device. After which you merge these to create a fat file which will work on all the defined architectures.
In case you are using third party static library (SDK) then you need to contact the respected party.

ObjC Lbrary Usage: Undefined symbols for architecture armv7

I have XCode library I wrote which I use inside Unity3D application.
The library works and now I need to make a change in the implementation, not the interface.
The problem is that in the XCode project created from Unity3D, when I use my library .a file I get this error (I've remove the specific class names).
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_ABNUnityativeController", referenced from:
_OBJC_CLASS_$_ABUnityNativeController in libABSDK_Unity_NativeController_iOS.a(ABUnityNativeController.o)
"_OBJC_METACLASS_$_ABNativeController", referenced from:
_OBJC_METACLASS_$_ABUnityNativeController in libABSDK_Unity_NativeController_iOS.a(ABUnityNativeController.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I'm pretty sure the problem is how I compile my library.
I find that my project settings were bad.
When I choose the main project (I also have sub XCode project in it) inside Build Phases -> Link Binary With Libraries I had to add my sub-project which was listed under Workspace directory.

IOS6 build link error

I build my app link with a static lib,found the errors follow
Undefined symbols for architecture armv7:
"std::_List_node_base::hook(std::_List_node_base*)", referenced from:
std::list<TSendBuf, std::allocator<TSendBuf> >::_M_insert(std::_List_iterator<TSendBuf>, TSendBuf const&) in libCardAnalyLib1.a(SendRecvThread.o)
"std::_List_node_base::unhook()", referenced from:
std::list<TSendBuf, std::allocator<TSendBuf> >::_M_erase(std::_List_iterator<TSendBuf>) in libCardAnalyLib1.a(SendRecvThread.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Can anyone tell me what is this error? thank you.
And there is C++ code in the app and the lib.
my demo app can not link the lib, shows this error, and the TSendBuf is
typedef struct {
unsigned char szBuf[1200];//1000 fah char
} TSendBuf;
You probably need to add libstdc++.dylib to the list of frameworks/binaries your application links to.
You can do that from target settings / "Build Phases" tab / "Link binary with Libraries" section
Library and app possibly do not match in link-settings.
Check specifically for the the C++ Standard Library setting, under Apple LLVM compiler within the Xcode Build Settings of both, your library and your app. Those need to match.
Supposed that the library in question is nothing you are building yourself, and if that library was built some time ago (pre Xcode 4.5/LLVM 4.1), then the "correct" setting for your app would be libstdc++ (GNU C++ standard library).

Linker error when trying to use SmartfoxServer-framework with a Kobold-2D project

When trying to use the SmartfoxServer-framework inside a Kobold2d project we are getting the following error:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_CCAsyncObject", referenced from:
objc-class-ref in libcocos2d-extensions-ios.a(CCTextureCache+CCBigImageExtensions.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1
This happends due to the fact, that we have to include the -ObjC linker flag to have the categories loaded, which are defined in the SmartfoxServer-framework. I already read about the need to force-link a static library which contains categories here, but the SmartFoxServer-Framework isn't a static library.
Is there a way to force load a framework, so it includes all the categories without using the -ObjC linker flag? Or is there a convenient way to convert a framework to a static library? Any help is greatly appreciated!
Unless you are using CCBigImage, you can deselect the CCTextureCache+CCBigImageExtensions.h and .m files from the target.
Open the Kobold2D-Libraries project and browse to the group /Extensions/CCBigImage. From the menu choose View -> Utilities -> File Inspector. Select each file and uncheck the target checkbox in File Inspector. Now this particular class won't be compiled anymore and the error is gone.
The problem seems to be that this category uses a private class that's defined only in the implementation file. Unfortunately force loading the entire cocos2d-iphone-extensions project is not a solution because this brings up other errors.

Xcode 4 error SDK authorize.net

When trying to compile with Xcode, I am getting the following error:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_AuthNet", referenced from:
objc-class-ref in ConnectionManager.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I am using SDK authorize.net
please help!!
You haven't linked the library to your application. Select the project from the navigator sidebar, select your target, then go to the Build Phases section. Under Link Binary With Libraries, add the AuthNet library.
Sounds like you are not including the libraries correctly.
Make sure that you followed each of these instructions:
Set your Library Search Paths with the path that contains the "Authorize.Net SDK"
library. (ex. "$(SRCROOT)/ANMobilePaymentLib").
Set your Other Linker Flags with "-lxml2" to allow for xml parsing.
Set your Header Search Paths with the path that contains "libxml2" header
files. (ex. "/usr/include/libxml2" with recursive checked).