Actually, I have the source code of speex library. Its written in c. I want to compile it for the arm architecture so that i can add it and work with my iPad project. When i am compiling the source in my mac its compiling it for the i386 architecture that cannot be used with the arm architecture.
How can i compile the source for arm architecture?
Please help me.
The easiest way to do this is to create a new "library" project, add the speex source, and get it to compile. This library project is an iOS library of course. Once you can get it to compile, you can then add that project to your primary project, and it will work in both the Simulator and the device.
When you add library projects to a main project, you have to set a dependency in the target, and add a path to the headers - but you can find many Q&A discussions on how to do this on SO.
The most difficult part of this is probably getting the config.h file (whatever) that the .configure script builds. You can probably take the one that was generated and most likely it will work just fine.
EDIT: BTW, Speex is outdated - there is a replacement Opus - see the Speex site
Related
I am struggling with a problem while using Gitlab CI/CD.
I am using for my project two of my external frameworks. The project builds without errors but when running the pipeline I'm getting an error that says
This Copy Files build phase contains a reference to a missing file 'xxxxxx.framework'.
My project looks like bellow
This is en error I'm getting:
When I add framework file not the framework project then CI/CD will pass BUT then I'm getting the error when trying to archive project
Building for iOS, but the linked framework 'xxxxxx.framework' was built for iOS Simulator.
I don't know how to solve those problems to get everything work.
Thanks for any kind of help.
Regards
In case anyone is having this problem and is cloning a git repository that has submodules, be sure include the submodules when cloning.
Most probably what you will need out of these 2 options is to use the x.framework one. The error
Building for iOS, but the linked framework 'xxxxxx.framework' was built for iOS Simulator.
as it says, comes from the fact that the framework is only built for iOS Simulator.
Why is that?
Well, the iOS Simulator runs on x86_64 architecture (as OS X does), while iOS runs on arm architecture. So you'll have to compile the frameworks for both architectures. Fortunately, there is a way to do this, and basically what you need to achieve is to create a fat binary of the framework.
There is a script here from Sundeep Gupta https://gist.github.com/sundeepgupta/3ad9c6106e2cd9f51c68cf9f475191fa which can be used to compile the frameworks for both, iOS Simulator and iOS target architectures. There are also several different resources on the internet which explain what steps you need to make in order to create fat binaries.
I am completely new to the iOS/iPhone/XCode world, so if you guess is between something rather complex and something so simple that everyone should know, I'd go with the simple answer. :-)
Okay, so I have inherited an iPhone project that we had outsourced to another company. My only objective right now is to be able to build the dang thing. I set up XCode 4.2 and installed the proper SDKs. I loaded up the project and everything seems good to this point. However, when I build, I get errors from what I believe to be the linking stage of the build. I'm not entirely sure because the statuses change quickly when building. The error I get is the following:
From what I have been able to find online, it seems that one of the libraries I am using was not compiled for the i386 platform. To start, this doesn't make sense to me because the libraries that I am using (where these errors are coming from) are currently included as sub-projects and produce .a files which I thought were arch-independent (am I wrong here??). Also, I can't find anywhere in the project where I've instructed XCode to build to an i386 architecture. This is what I've done so far:
Made sure that the file in which these errors arose was included into the "Compile Sources" section of the Build Phase tab (the .m file)
Set my architectures to armv6 and armv7 and set the Build Active Architecture Only to no. (See images below)
Main Project Config
Sub-Project Config
Event when I build using the release configuration, I still get this error and I'm not sure why. Everything that I am looking at in my build config seems to indicate that I should be building everything in an arm architecture.
You are getting errors because you messed with the architecture settings. You should not fix those towards ARM code but allow i386 as well.
Right now, one of more of your (sub)-projects build ARM code only, resulting into a linker error once you try to build a simulator version. That is happening because your Architecture settings are not as they should be.
Note your setting for Any iOS SDK, that one is incorrect as it builds only ARM code. Remove those settings entirely by using the backspace key on your keyboard after selecting that specific setting (single-click).
And this is how it should be:
$(ARCHS_STANDARD_32_BIT) resolves to ARMV7 when building device specific code and i386 when building simulator specific code. Including ARMV6 code as per my screenshot is only needed if you plan to serve the results to older iOS devices (iPhone 3G and below).
Once those settings are active in all (sub)-projects, everything should work smoothly.
For creating a universal library out of a project, useful if you plan to distribute a static library to other developers, use LIPO.
Example:
lipo input_library_1.a input_library_2.a -create -ouput output_library.a
Lets say input_library_1 was i386 specific (simulator) and input_library_2 was ARM specific (device), this will join them into a universal version usable for both simulator and device.
It seems like you have been trying to link to static library built for devices(armv6 or armv7). When your building for the simulator the architecture will be i386. So you getting all these nasty linking errors. Solution is to include the library compiled for simulator as well in your project.
I'd like to use the excellent stringencoders library in an iOS application. It's a fairly typical c library, with a configure script generated by autoconf and a makefile.
What I'd like to do is compile arm7 and i386 versions on Mac OSX and then use lipo to make a fat binary.
I'm having trouble figuring out how to persuade the build tools to create my platform-specific binaries. There's a few articles out there and even a few scripts but most of them are targeted at XCode 4.2 and don't work with 4.3.
It looks like it should be possible to create a fairly generic build script that can play nicely with configure and make but I'm at a loss as to where to even start.
Have you successfully done anything like this? I'd love some pointers!
BTW: 'import all the sourcecode into your project' is NOT a viable solution. That way lies madness.
Thanks.
I've ported a handful of open source C libraries to iOS (see iOS Ports). I've found the most reliable way to port a library is to build a new Xcode project with a build target for a static iOS Library. It is important to note that Apple will not allow your iOS Application to contain dynamic libraries if you plan to distribute your app on the iTunes App store, so you will be unable to use FAT libraries.
These are the steps I usually follow when porting libraries to iOS which usually built with the GNU Autotools:
Run ./configure with appropriate flags on OS X.
Verify that the library builds correctly on OS X using make.
Create a new Xcode project using the iOS Static Library template.
Add the config.h from the previous configure run to the Xcode project.
Read the automake file (Makefile.am), and add the referenced sources in the automaker targets to the Xcode target for the static library.
Copy the CPP flags (i.e. -DHAVE_CONFIG_H) from the automake file to the build settings in Xcode.
Compile in Xcode and start running down errors (usually by adding missing header include paths or missing source files).
The directory structure I usually use is the following:
project/
project/ported-project.xcodeproj
project/project-x.x.x.tar.gz
project/project-x.x.x
project/project -> project-x.x.x
I know this is not exactly what you asked for in your question, however it is rough outline of the steps I've used for years for porting libraries. The benefit of creating an actual Xcode to compile the ported library is that it makes it easier to integrate the library into multiple Xcode iOS applications.
If you need clarification or more detailed instructions, let me know and I"ll try to write up more extensive instructions and update my answer.
Is it plausible to add the source files (i.e. .c files) to your project directly?
Objective C is a superset of C so i am surprised that the code did not work directly out of the box in XCode 4. Are you missing out something there ? just suggesting
Generate your project files using gyp: http://code.google.com/p/gyp/
I use it to share libraries between win/osx/ios and linux (pi).
I am trying to port an existing project to iPhone which needs Boost.Thread library, the project compiles without error but there are link errors:
"boost::thread::start_thread()", referenced from:
boost::thread::thread<(anonymous namespace)::ReadThread::Function>((anonymous namespace)::ReadThread::Function, boost::disable_if<boost::is_convertible<(anonymous namespace)::ReadThread::Function&, boost::detail::thread_move_t<(anonymous namespace)::ReadThread::Function> >, boost::thread::dummy*>::type)in ChessEngine.o
How can I add the required thread libs to the Xcode project?
p.s. the boost lib is in: /usr/local/lib/libboost_thread-mt.a
EDIT (library found, but got architecture error):
Following Linking to Boost.Signals using Xcode, after adding /usr/local/lib in Library Search Path and -lboost_thread-mt in Other Linker Flags, the library is found. However, there are new errors and warnings:
ld: warning: in /usr/local/lib/libboost_thread-mt.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
How can I have the lib working for iOS (4.0 or later)? Thanks!
I did some more searching and found this downloadable script that will build a multi-architecture iphone ready version of boost. Also check out this blog post about using it.
It sounds like you are trying to link in a library for an architecture (armv6,7) when you probably have the current target set as a device (i386 - the simulator). If thats correct I'd say you have downloaded the library built for the device. To run in the simulator you need the version of the library built for your computer (I386).
The easiest way to handle any external library is for the developer of it to produce a armv6/armv7/i386 static framework. Then it's a piece of cake to use. If it's as much trouble as this sounds like, I'd be looking elsewhere for the functionality :-)
I have searched for hours however I still have no clue what is wrong with my configuration.
My project uses a self-written libray (myLib). This library is compiled to work only for simulator and it works perfectly there.
What do have to change so it compiles for my iPhone Device as well?
This is my current warning:
ld: warning: in /.../myLib.a, file is not of required architecture
This is my configuration (of myLib.a)
I found a lot of articles explaining the reason for this error however I could not find a solution:
The simulator runs on an x86
architecture, while the device uses an
ARM architecture.
What do I have to change to get my library working on my iPhone?
Thanks
Edit:
What I did so far:
Cleaned both projects
Set library to 'Device' (3.1)
Built the library
Dragged the .a file of my library into my application
Result:
This works in simulator but setting the active sdk to device still raises a file is not of required architecture error.
I also tried mahboudz ( thanks for your support) link.
It explains howto built the project using a shell script.
However XCode keeps complaining that the library file is of the wrong architecture and the build fails.
This has to be a really stupid beginners mistake.
You need to add both .a files,the one built for the device (build/$config-iphoneos)and the one built for the sim (build/$config-iphonesimulator) to the new project. Make sure you name them differently before dropping them in. This is how admob and similar offering ship their static libs.
You need to compile your library for Intel so the Simulator can use it (which I gather you have done already), and then compile it for ARM, so it can run on the iPhone. Then you have to merge the two libraries. There are different ways to accomplish that, or make it more automatic.
Here are some links to help you:
http://blog.stormyprods.com/2008/11/using-static-libraries-with-iphone-sdk.html
http://www.clintharris.net/2009/iphone-app-shared-libraries/
I've met the same problem too. But seems you don't need to drag two .a files into the app project to solve this problem. This is what I did:
Drag the static library project into app project's framework group
"Get Info" for the target in app project
Set the direct dependency of static library
Make clean all unnecessary builds(for example the simulator build) in the static library project
Build in the app project