Getting Speex Lib to Compile in Xcode
I had to use AudioQueue to play Speex, and I had a very hard time importing the Speex library, and making it compile with Xcode. Therefore, I want to write down the steps I did to make it compile, just in case I need it in the future.
- Go to http://www.speex.org/downloads/, and get the latest stable version. When I did this, it was 1.2rc1.
- Once downloaded, you should see that it contains an “include” folder, and a “libspeex” folder. Drag and drop that into your Xcode project.
Clean and Build. You should see a lot of errors!
Go back to the downloaded Speex folder, and look for config.h.in. Removed the “.in”, and keep it as a “.h” file. Drag and drop the config.h into Xcode as well.
- Go to your project’s .pch file, and insert this:
- In config.h, make sure FLOATING_POINT and USE_SMALLFT are #define, instead of #undef
- In config.h, look for, SPEEX_EXTRA_VERSION, SPEEX_MAJOR_VERSION, SPEEX_MICRO_VERSION, SPEEX_MINOR_VERSION, and SPEEX_VERSION. Those should all have a prefix of #undef. Comment out those lines. These are redefined in arch.h.
You should see a lot of errors like this: “Lexical or Preprocessor Issue: speex/speex.h file not found”. For errors like this, instead of using
Make sure you are also using double quotes “” instead of < >
Remove the echo_diagnostic.m file.
Clean and build again. There are still plenty of errors. It should all be something like:
Go to config.h, and make sure EXPORT is #define instead of #undef
Parse Issue Unknown type name ‘EXPORT’
Now you should see just two more errors:
Linker command failed with exit code
error: unable to open executable …..
In your libspeex folder, you will see that testdenoise.c, testecho.c, testenc.c, testenc_uwb.c, testenc_wb.c, and testjitter.c all have a main function. Comment out the main functions, or delete those files. I deleted those files on my project.
While we’re at deleting stuff, we might as well delete Makefile.am and Makefile.in in “include” folder. Delete them again in the “include/speex” folder.
You should now be able to compile speex library in Xcode without errors.