what is the true reason for the "Undefined symbols for architecture i386:" errors that occur?
It appears way too often with various libraries...
Regards
Mirza
Sometimes you need to link with frameworks that are included in the iOS sdk (QuartzCore or CoreData for example). When you're trying to use a class or object of that framework, and you haven't linked it, you're getting the undefined symbols error.
Related
i am using a framework that uses AFNetworking , found that it is stored in the vendor file and i also use AFNetowrking in my podfile in cocoa pods. Removing the AFNetworking functionality in either is not an option. How do i go about solving this?
You cannot have these linked at the same time in the same project and not have duplicate symbols. The meaning of duplicate symbols is that the same symbols are being declared/imported multiple times which is exactly what is happening here. The only way to fix this is to remove the framework in one of the two locations. Even if it were possible to fix this you wouldn't want to since there's a possibility the versions of the same framework could diverge leaving you with different APIs based on which version you were working with which would be an amazingly confusing headache.
Recompiling a C++ iPhone app with Xcode 4 I get this nasty linker error:
ld: bad codegen, pointer diff in __static_initialization_and_destruction_0(int, int)
to global weak symbol vmml::Vector2<float>::ZERO for architecture armv6
Anyone know what it means? How to make it go away would be nice too of course :)
The app compiled & linked without error in Xcode 3.
Edit: the solution is to set Symbols Hidden By Default to Yes in all the build settings of all targets in the project. Still none the wiser what the actual problem was.
The solution is to set Symbols Hidden By Default to Yes in all the build settings of all targets in the project. Still none the wiser what the actual problem was.
I had the same problem and also ended up adjusting the visibility settings. However, I was nervous just fiddling with symbol visibility and not understanding the problem, so I did a little more investigation.
If, like me, you're using Pete Goodliffe's script/package to build boost as a framework, the script sets default visibility to hidden (== yes). The visibility options change how symbols are marked by the compiler (default, hidden, internal). That information is used by the linker when making shared object elfs (shared libraries). It shouldn't apply here, so I suspect that this is a linker bug. Inside the boost library you have a weak symbol marked as hidden, and then in your project/another library, the same symbol marked as default. The linker is confused?
As for XCode 3 vs. 4, perhaps the default in 3 was to hide symbols?
In any case, changing default visibility to hidden should really have no effect with only static libs involved, so I feel a lot safer taking this route.
I've posted a few more details in a blog entry for those interested.
I ran into this problem while trying to include the boost libraries one of my projects. After finding this post, setting Symbols Hidden By Default to Yes also solved this issue for me. And I also had to make the same setting in each of the dependent projects to completely get rid of the error.
Just FYI - This only happened on my targets that were using the clang++ stack. GCC and LLVM+GCC targets do not seem to be affected.
Basically any symbols in a library you link to & your own code, need to use the same visibility level, i.e. if all the symbols in a library you include are hidden you need make sure the include files referencing the symbols in your project don't try and set it to visible. the safest way to do this is to have a constant level of default visibility across your project, for me it only became a problem with optimisations on.
Perhaps you are using a library that has hidden symbol information. If a symbol has not been exported from your library, and you attempt to use it externally, it results in a similar linker error. The correct solution would seem to be to find a way to make that symbol "visible" to the outside world via GCC macro definitions and/or modify the library itself to make sure that that particular symbol is truly "hidden" from the outside world --i.e. it isn't something that is ever used or exposed in a header file.
However, proceed with caution: according to Apple documentation, you should not hide some symbol information for a number of reasons; this one listed below seems to be the most alarming of the bunch:
If your symbol uses runtime type identification (RTTI) information, exceptions, or dynamic casts for an object that is defined in another library, your symbol must be visible if it expects to handle requests initiated by the other library. For example, if you define a catch handler for a type in the C++ standard library, and you want to catch exceptions of that type thrown by the C++ standard library, you must make sure that your typeinfo object is visible.
Source: http://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/CppRuntimeEnv/Articles/SymbolVisibility.html
Thus, if you want to catch an exception from the library you're linking against, hiding symbol information appears to be a bad choice. The correct solution would be to unhide the symbols of whatever library you're linking to. This can either be done by omitting the following GCC compiler flags:
-fvisibility=hidden --fvisibility-inlines-hidden
(the default visibility should be sufficient), or there are also compiler pragmas that allow you to do this. See: http://gcc.gnu.org/wiki/Visibility
I'm trying to update an app of mine to Xcode 4.2, and now it's giving me a bunch of errors in stl_vector.h, a library that is part of the built in libraries. Here is a picture of the error:
Any ideas what I'm doing wrong? I can't figure out how to fix this. I don't have permission to even edit the function that is throwing errors since it is built in.
A slight guess, since you don't give us enough information, but if OBJMaterial etc are Objective-C classes, you can't pass them by value, i.e. you always work with pointers.
GDB: Program received signal "SIGABRT"
I'm running a problem with a few things according to the Build log, please could you shed light on the possibilities that these errors could be caused by. All help is appreciated.
Summary of project:
I have two projects which i have taken some .h, .m and .a files from one project folder, dragged them into the other project, then going through
Menu > Project > Add to project I have imported them into the Static Library of the project.
Some lines of code I have blanked my details out for privacy.
Here are the errors I'm getting...
found branch-22 without store in _SOGLH
found branch-22 without store in TrackerInterface::InstantiateTracker()
ld: warning: ignoring file /Users/myname/Desktop/*projectname*/*It's_a_dot_A_file*.a, file was built for archive which is not the architecture being linked (armv7)
I'm relatively new to Xcode so I'm not confident with some of the terms so please bear that in mind.
King Regards,
R.
For the last error, it is quite self-explanatory: you are trying to include a library (.a) file that has been built for a different architecture.
Probably a library that has been built for OSX-32bits or OSX-64bits and that you are trying to use for iOS (which uses architectures armv6 & armv7).
Rebuild the library for the correct architecture (armv7) of if it is a third-party library, use the appropriate .a file for the appropriate architecture.
Has anyone come across this problem when building with cocos2d (OpenGL library for iPhone 2D games)?
"glui/GL/glui.h" file is not found
gluOrtho2D was not declared
GL_COLOR_BUFFER_BIT was not declared.
There seems to be very little info on GLUI for iPhone on the web. I am new to OpenGL, so appreciate the help! I have included OpenGLES CoreGraphics libraries, even tried adding linker flag "-framework GLUI" but to no avail.
Thanks!
I solved this problem by
removing cocos2d's external/Box2d/Testbed directory
adding GLUI.framework from /Library/Frameworks/GLUI.framework (and setting the framework search path)
It compiles successfully, but dies on launching in simulator with this error, which seems unrelated to the question above.
dyld: Symbol not found: _CFXMLNodeGetInfoPtr
Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security
Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.2.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation in /System/Library/Frameworks/Security.framework/Versions/A/Security
I was finally able to get this working by following a different tutorial. The Monocles tutorial is outdated since it uses cocos2d v.0.7.2.
There has been significant change to cocos2d v.0.8, which comes pre-packaged with an easy to use XCode Project Template, and in v.0.9, libraries filenames have been further improved with the CC prefix to avoid namespace collision. I would recommend this tutorial instead:
http://iphonedev.net/2009/07/12/cocos2d-example-box2d/
Also found this to be useful.
http://www.mycodestudio.com/blog/2009/12/06/cocos2dpt1/