问题
I have a large existing Xcode project and now I want to add the armadillo library to it .
http://arma.sourceforge.net/
I have downloaded it (with macports) and got it working using Cmake (just as a C++ terminal app). I am not using Cmake for my large project (iPad app) so I have tried to link the library. I looked in the xcode-project file that I got working with cmake and added the same to my project.
Added: header search path: /opt/local/include Library search path: /opt/local/lib Other linker flags: -larmadillo
I also added the libarmadillo.3.4.0.dylib to "link library with binaries"
ld: warning: ld: warning: ignoring file /opt/local/lib/libarmadillo.3.4.0.dylib, file was built for unsupported file format ( 0xcf 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 1 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (armv7s): /opt/local/lib/libarmadillo.3.4.0.dylibld: warning: ignoring file /opt/local/lib/libarmadillo.dylib, file was built for unsupported file format ( 0xcf 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 1 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (armv7s): /opt/local/lib/libarmadillo.dylib
ignoring file /opt/local/lib/libz.dylib, file was built for unsupported file format ( 0xcf 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 1 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (armv7s): /opt/local/lib/libz.dylib
Undefined symbols for architecture armv7s:
"_deflateInit_", referenced from:
_compress_data in libTestFlight.a(tf_compression.o)
"_deflateEnd", referenced from:
_compress_data in libTestFlight.a(tf_compression.o)
"_deflate", referenced from:
_compress_data in libTestFlight.a(tf_compression.o)
ld: symbol(s) not found for architecture armv7s
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Any ideas how I can solve this?
回答1:
Try to add libz.lib to your build target:
Add libz to your Link Binary With Libraries Build Phase
- Select your Project in the Project Navigator
- Select the target you want to enable the SDK for
- Select the Build Phases tab
- Open the Link Binary With Libraries Phase
- Click the + to add a new library
- Find libz.dylib in the list and add it
- Repeat Steps 2 - 6 until all targets you want to use the SDK with have libz.dylib
Source: https://testflightapp.com/sdk/doc/1.1/
回答2:
I recently had a similar problem – Linking armadillo with Xcode.
I'll tell you how I fixed it. Two steps were necessary:
1) the xcode needs to "see" the file libarmadillo.dylib (mine, located at /usr/lib/) – it is Not the same as using libarmadillo.3.81.1.dylib directly.
In order to do that, create a link to the file on xcode libraries (mine, located at /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/lib/).
In summary:
$ sudo ln -s /usr/lib/libarmadillo.dylib /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/lib/libarmadillo.dylib
2) now I needed to "tell" the xcode to include this library on compile command.
For that:
- open your project (make sure you do that after create the link mentioned above)
- go to the
TARGETS(I have only one so...) - click on
Build Phasestab - find 'Link Binary With Libraries' and click on + (Add items)
- on the new opened window type
armadilloand by now you should be seeing the librarylibarmadillo.dylibin front of you, just add it!
P.S. Within the header files whose armadillo was used, I included it using the full path (in my case, #include "/usr/include/armadillo")
That is it, I wish I could have helped you out.
来源:https://stackoverflow.com/questions/14136776/linking-armadillo-with-xcode