The bridging header file says,
#define qnorm5 Rf_qnorm5
#define qnorm qnorm5
double qnorm5(double, double, double, int, int);
and the code (which compiles!) says
let myresult = qnorm (0.75,0,1,1,0)
but the linker complains
Undefined symbols for architecture x86_64:
"_qnorm", referenced from:
macOS_app_test.ViewController.sayButtonClicked(Any) -> () in ViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
From the output, the correct library is found and linked, but the linker does not look for the correct symbol. The symbol the linker should look for, is _Rf_qnorm5.
Apparently, I ought to have understood that the proper function name should be Rf_qnorm5.
Also, there was a problem with XCode actually finding the bridging header file. With both in place, the code works.
Related
I have a Swift test which uses some Objective-C code that I wrote:
class ParserServiceTest: QuickSpec {
override func spec() {
var x : MyClass? // this works
x = MyClass() // this does not
}
}
When I try to build the project I get the error message:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_MyClass", referenced from:
__TTSf4d___TTSf4g___TFC11MyProjectTests17ParserServiceTest4specfS0_FT_T_ in ParserServiceTest.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
You need to include the objective-c in your test target. In your targets list, select the "...Tests" target and then the "Build Phases" pane. Look at "Compile Sources" or "Link Binary With Libraries" (depending on whether your code comes from source or a library), and make sure all the files you need are there. Most things you need to do for your executable project, you also need to do for your test project.
In the File Inspector Utility panel (right-hand panel), you can also add target membership to individual files.
I'm trying to run an Xcode project developed by someone else and I keep getting the following error. Googling it suggests that I'm missing some dependency but if so I don't know which one. Supposedly the project already has all "Link Binary With Libraries" configured. I've tried different versions of Xcode and target devices and I get the same error. How can I narrow the problem down further?
Undefined symbols for architecture i386:
"___gl_pqSortExtractMin", referenced from:
___gl_computeInterior in sweep.o
"___gl_pqSortMinimum", referenced from:
___gl_computeInterior in sweep.o
"___gl_pqSortNewPriorityQ", referenced from:
_InitPriorityQ in sweep.o
"___gl_pqSortInsert", referenced from:
_InitPriorityQ in sweep.o
_CheckForIntersect in sweep.o
"___gl_pqSortInit", referenced from:
_InitPriorityQ in sweep.o
"___gl_pqSortDeletePriorityQ", referenced from:
_InitPriorityQ in sweep.o
_DonePriorityQ in sweep.o
_CheckForIntersect in sweep.o
"___gl_pqSortDelete", referenced from:
_CheckForRightSplice in sweep.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
That means that even if the compiler has the header file, when it actually linked them, it didn't find the real implementation of this code. So maybe you didn't linked your static library (only included the header file), or this static library hasn't been compiled for i386 architecture. So you can't make it work on simulator. You should check with lipo -info libMylib.a on what kind of architecture it has been compiled (armv6 - armv7 - armv7s, or whatever else)
Ok here what i have found:
This is the sweep file you are using.
http://oss.sgi.com/cgi-bin/cvsweb.cgi/projects/ogl-sample/main/gfx/lib/glu/libtess/sweep.c?annotate=1.2
Inside
static int CheckForRightSplice( GLUtesselator *tess, ActiveRegion *regUp )
there is
pqDelete( tess->pq, eUp->Org->pqHandle ); /* __gl_pqSortDelete */
By the way into the include file in sweep there is:
#include "priorityq.h"
So it let you compile because you have the header definition of the function, but you don't have the binary implementation. So you get linker error.
I dunno if you need to instal openGl in your mac ( i though it was already included), by the way i'm sure you don't have the (opengl/glu/libtess) libtess library, this is where there is the "priority.h" definition.
Here is the glu lib if found:
http://svn.netlabs.org/repos/gl2/opengl/glu/libtess/
So you should ask your friend if he has compiled himself the framework or not. Maybe you forget to add some link into your Xcode project, or the binary is missing from your mac, or not compiled into the i386 (even if i doubt of this). By the way i'm really not an openGl expert, but if you ask anyone into an openGl forum, they surely can help you.
I just marked all of my CocoaAsyncSocket code as non-ARC code, and it's given me these 3 errors:
Undefined symbols for architecture armv7:
"_kCFStreamNetworkServiceTypeVoIP", referenced from:
-[GCDAsyncSocket enableBackgroundingOnSocketWithCaveat:] in GCDAsyncSocket.o
"_kCFStreamNetworkServiceType", referenced from:
-[GCDAsyncSocket enableBackgroundingOnSocketWithCaveat:] in GCDAsyncSocket.o
"_kCFStreamPropertySSLSettings", referenced from:
-[GCDAsyncSocket maybeStartTLS] in GCDAsyncSocket.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Does anybody know what this means and how to fix it?
I think I found the solution to this, by looking in the code comments, but I now see that it's also what Mark Adams suggested above. I had the errors until I added the CFNetwork.framework under Targets->Build Phases->Link Binary With Libraries->Select CFNetwork.framework
It means that some code you are compiling is referencing the constants "kCFStreamNetworkServiceTypeVoIP", "kCFStreamNetworkServiceType", and "kCFStreamPropertySSLSettings", but that those constants weren't found when it tried to link your code with the libraries it uses.
Unfortunately there's a bunch of reasons this could be:
You could have misspelled them
They could be #ifdef'd out for that architecture
You might not be linking the correct librar(y, ies)
They could be marked as having 'hidden' visibility so that they can only be used in the declaring library
Probably other reasons
You can use 'nm' to poke at the exported symbols from the binary of a library, and 'otool -L' to check which libraries your binary is linking.
I had this same error when integrating LineaPro API into an app.
The fix i implemented was adding ExternalAccessory.framework to General -> Linked Framework and Libraries.
I already had CFNetwork.framework included.
Trying to build my program and getting the following error. Don't see anything obvious. All my import statements seem correct:
Undefined symbols:
"_OBJC_CLASS_$_DBAccess", referenced from:
objc-class-ref-to-DBAccess in LocationsViewController.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
This sort of problem usually means that the linker isn't finding the class (if your imports are wrong you only get a lexing warning).
Check to make sure that your project is properly linked to whatever uses DBAccess and that DBAccess.m/h is included in the output.
From what I have read this is supposed to be when the linker (not exactly sure how that works) can't find a symbol. the symbol in question is: SCNetworkReachabilityCreateWithAddress as can be seen from the full error message below.
the thing is that the correct
framework is added to my target.
xcode recognises the symbol OK, i.e.
there is no error message in the .m
file.
the .m file is added to the correct
target so I'm not at all sure what to
do.
Any ideas please?
"SCNetworkReachabilityCreateWithAddress", referenced from:
-[AppWelcomeVC viewDidLoad] in AppWelcomeVC.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Do you have #import <Availability.h> in your AppWelcomeVC class header, or added to your precompiled header (MyApp_Prefix.pch)?
What frameworks do you have in your project?
In the past when I've had this error removing the framework and readding it fixed the problem.
Permissions problems with the framework file itself can also cause this error.