I'm trying to use a library, specifically SOIL (Simple OpenGL Image Library) in Xcode 4.2.1. Under Build Phases -> Link Library with Libraries I add all the .h and .c files that came with the SOIL zip archive.
When I build the project, I get the following error message for every .h and .c file added:
warning: skipping file '/Users/saw/XcodeProjects/Assignment01 copy/Assignment01/image_DXT.c'
(unexpected file type 'sourcecode.c.c' in Frameworks & Libraries build phase)
and a linker error:
"_SOIL_load_OGL_texture", referenced from: Init() in main.o Symbol(s)
not found for architecture x86_64 Clang: error: linker command failed
with exit code 1 (use -v to see invocation)
.h and .c files aren't libraries. Add the .c files to the compile phase and just #import the .h files where needed.
To verify linking I have done the following:
Create a new Mac Cocoa application.
Add 10 files from the SOIL src
folder: SOIL.c, image_DXT.h, stbi_DDS_aug.h, SOIL.h, image_helper.c,
stb_image_aug.c, stbi_DDS_aug_c.h, image_DXT.c, image_helper.h, and
stb_image_aug.h.
Tell Xcode to copy them to my project.
Add one line
to my app delegate's applicationDidFinishLaunching: method:
SOIL_load_OGL_texture( "img_test.png", SOIL_LOAD_AUTO,
SOIL_CREATE_NEW_ID, 0 );.
Build the target for running.
Although there are a variety of compiler warnings about data conversion, these steps produce an executable with no linker errors.
Try adding -framework to your framework's name in the "Other Linker Flags" such as:
-framework SOIL
Related
I'm trying to build a .a file to include in a unity3d asset in order to let people build for iOS.
I get the following error when I try to build a game. (The error is a lot longer than this but it seems to be an issue with std::vector )
Building .a file for iOS. Undefined symbols for architecture armv7s: "std::__1::__vector_base_common:: ..."
I saw here Someon has the same error and the solution is .. "add the -lc++ linker flag to your target's Build Settings"
I've tried this fix in the poroject from which I build the .a file from. When I try to build the library I get this error
Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: -dynamic not specified the following flags are invalid: -ObjC
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lC++
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lC++ is not an object file (not allowed in a library)
Note: I'm very inexperienced with osx and xcode.
I am too much of this Static Libary thing in Xcode 4.X
Following are the steps that I usually do..
1)For making a static libary , I open Xcode , new , static libary , and then by adding some classes in the project .. then build phases ->copy headers -> add all headers here one by one,and then i build up the project
when run on ios simulator -> static libary does not created ..(red color)
when run on ios device - > static library gets created..
2) for using the library..
I make a new Project , then i "add files to project" and also "copy if needed" the following 2 files..
.a file (i.e.static library)
folder consisting the headers of library files
Now when I try to import a header file in my project , there is no "suggestion" appear ...but still i write and it does not give an error "header file not found"...
but when I run the project it gives the error like:
ld: warning: ignoring file
/Users/Subodh/Library/Developer/Xcode/DerivedData/LibraryImporting_test-cbchzzjdcehzvfgwmzbvifrnrwgk/Build/Products/Debug-iphoneos/libLibraryImporting_test.a,
file was built for archive which is not the architecture being linked
(i386):
/Users/Subodh/Library/Developer/Xcode/DerivedData/LibraryImporting_test-cbchzzjdcehzvfgwmzbvifrnrwgk/Build/Products/Debug-iphoneos/libLibraryImporting_test.a
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_LibraryImporting_test", referenced from:
objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Plz guide me....point out if get wrong at some step....help plz
it will be better if someone mentions all the steps as i have done in making a library and using it in a project...it will be a great help
The key to the issue is this part of the error message:
file was built for archive which is not the architecture being linked
(i386)
You have imported the library built for the iPhone Device (ARM) by the look of it, and you are trying to use it in the iPhone Simulator which is i386.
What I would recommend is using an Xcode Workspace where the static library project is one of the projects and the iPhone app is another project. This way Xcode will build the library, as required, for Debug/Release and Device/Simulator.
I'm trying to link the Box2D C++ library to my Xcode 4.4 project through the libBox.2.1.0.dylib file. Here's what i did:
Went to the "Targets", selected my application, and added my .dylib file in the "Link Binary With Libraries" section
Created a new "Copy Files" build phase and set it to "Executables" (so the .dylib file is right next to the internal executable in the .app bundle)
Successfully compiled my project with no errors whatsoever
Ran project and got the following runtime-error:
dyld: Library not loaded: libBox2D.2.1.0.dylib
Referenced from: /Users/****/Documents/Xcode Projects/ProjectName/DerivedData/ProjectName/Build/Products/Debug/ProjectName.app/Contents/MacOS/ProjectName
Reason: image not found
I followed all the steps from this link here, but I still get the runtime-error for some reason. I am I missing something important in my setup?
I created a command line application. Then I realized it would be handy to be able to use code in other projects, so I added a new target - a cocoa library.
It seems to compile and a .a file is generated.
Now in another project I want to use this library. So first I added the first project to this new project as a reference.
In build settings I set "Always search user paths" to YES, then keyed in the path to the above project in user header paths.
In build phases, "Link Binary with libraries" , I added the .a file.
Now in my new project code sense seems to work. But when I try to build, I get an error : ndefined symbols for architecture x86_64:
"_OBJC_CLASS_$_RIImageSplitter", referenced from:
objc-class-ref 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)
What did I do wrong? :S I am a beginner.
Didn't add file to compile sources of target. =S
Check this:
Did you drag the static library to your project navigator?
Did you add in Target/Build Phases/ Target Dependencies?
Did you add the Header Search Path for the headers of the static library?
Good Luck!
I've been having trouble compiling my own OpenCV iOS project. I started with a simple command-line app target and I've now added an iOS app target. The problem is that my iOS target produces the following linker error:
ld: library not found for -lcv
collect2: ld returned 1 exit status
Command
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-g++-4.2
failed with exit code 1
I'm not sure where the flag, -lcv is coming from, as I haven't set it as any of the settings in my project's "Build Settings". I've downloaded a demo OpenCV iPhone project that compiles perfectly fine, and I've tried to copy the build settings from this project but I can't see what's different!
Thanks very much for any help.
Try adding in the project settings the path exact of the library since : /User/.....
important: only ONE ""