Linking a new library in X-code

Hi,

Apologies if this is covered elsewhere, but I’ve been trying to link in libsndfile:
sndfile.h and libsndfile.a

I just dragged them from where I had compiled libsndfile (which works in simple C++ X-code project.)

But I;m trying to now load a soundfile in openFrameworks. It seems I may not be linking right as I get a
:Undefined symbols
_sf_open

error when adding the line:
infile = sf_open(inputFilename.c_str(), SFM_READ, &sfinfo);

However, it’s fine with the code above that defines the file types etc:

SNDFILE *infile; // define input and output sound files
SF_INFO sfinfo ; // struct to hold info about sound file
int readcount ; // counts number of samples read from sound file

inputFilename = “example.aif”;// input file name placed in bin

sfinfo.format = 0;

//then this line adds the problem:
//infile = sf_open(inputFilename.c_str(), SFM_READ, &sfinfo);

So, what’s wrong about the above - and is there a proper way to link a library?

thanks,
Andrew

hi Venetian,
it seems, that the library is not linked properly (the .a file). have you checked in the sidebar in the target (unfold it and take look in the “Link Binary With Libraries” section) if it is going to be linked?
another possibility could that it is wrong arch, but i doubt that, because you compiled it yourself on your machine.
more basic question: where do you include the libsndfile.h? for me it worked in the testApp.h.
can you post some details from the compiler log?

I could be the wrong arch as you need to compile libsndfile for 10.4 and not just your current arch if you are using 10.5 or 10.6, or change the XCode project to be only 10.5 for example. Please post all the errors you are getting as they will indicate what is going on. Also, you can use/check out my static compiled libsndfile from the ofxSoundPlayer in my recent post if you can’t get yours to run.

Hi,

Thanks for the replies. Libsndfile.a is in the toolbar menu under
targets->openframeworks->Link binary With Library

I have included sndfile.h as an extra file under src.

I’ve included the errors below. At the end, there is text referring to the arch and cpu type. Would that explain anything?

Building target “openFrameworks” of project “openFrameworks” with configuration “Release” — (1 error, 1 warning)
cd /Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/my_Open_Frameworks/libsndfileExample
/usr/bin/g+±4.0 -o /Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/my_Open_Frameworks/libsndfileExample/build/openFrameworks.build/Release/openFrameworks.build/Objects-normal/ppc/openFrameworks -L/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/my_Open_Frameworks/libsndfileExample/bin -L/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/my_Open_Frameworks/libsndfileExample/…/…/…/libs/freeimage/lib -L/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/my_Open_Frameworks/libsndfileExample/…/…/…/libs/fmodex/lib -L/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/my_Open_Frameworks/libsndfileExample/…/…/…/libs/freetype/lib -L/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/my_Open_Frameworks/libsndfileExample/…/…/…/libs/GLee/lib -L/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/my_Open_Frameworks/libsndfileExample/…/…/…/libs/poco/lib -L/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/my_Open_Frameworks/libsndfileExample/…/…/…/libs/rtAudio/lib -L/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/my_Open_Frameworks/libsndfileExample/…/…/…/…/C_libraries/Libsndfile/lib -L/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/my_Open_Frameworks/libsndfileExample/…/…/…/…/C_libraries/Libsndfile/lib -F/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/my_Open_Frameworks/libsndfileExample/bin -filelist /Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/my_Open_Frameworks/libsndfileExample/build/openFrameworks.build/Release/openFrameworks.build/Objects-normal/ppc/openFrameworks.LinkFileList /Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/my_Open_Frameworks/libsndfileExample/…/…/…/libs/freeimage/lib/freeimage.a -lfmodex /Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/my_Open_Frameworks/libsndfileExample/…/…/…/libs/freetype/lib/freetype.a /Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/my_Open_Frameworks/libsndfileExample/…/…/…/libs/GLee/lib/GLee.a /Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/my_Open_Frameworks/libsndfileExample/…/…/…/libs/rtAudio/lib/rtAudio.a -framework AGL -framework ApplicationServices -framework AudioToolbox -framework Carbon -framework CoreAudio -framework CoreFoundation -framework CoreServices -framework GLUT -framework OpenGL -framework QuickTime -lCppUnit -lPocoFoundation -lPocoNet -lPocoUtil -lPocoXML -lsndfile -arch ppc -Wl,-Y,1455 -mmacosx-version-min=10.4 -Wl,-dead_strip -isysroot /Developer/SDKs/MacOSX10.4u.sdk
/usr/bin/ld: warning /Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/my_Open_Frameworks/libsndfileExample/…/…/…/…/C_libraries/Libsndfile/lib/libsndfile.dylib cputype (7, architecture i386) does not match cputype (18) for specified -arch flag: ppc (file not loaded)
/usr/bin/ld: Undefined symbols:
_sf_open
/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/my_Open_Frameworks/libsndfileExample/build/openFrameworks.build/Release/openFrameworks.build/Objects-normal/ppc/testApp.o reference to undefined _sf_open
collect2: ld returned 1 exit status
/usr/bin/ld: warning /Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/my_Open_Frameworks/libsndfileExample/…/…/…/…/C_libraries/Libsndfile/lib/libsndfile.dylib cputype (7, architecture i386) does not match cputype (18) for specified -arch flag: ppc (file not loaded)
/usr/bin/ld: Undefined symbols:
_sf_open
/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/my_Open_Frameworks/libsndfileExample/build/openFrameworks.build/Release/openFrameworks.build/Objects-normal/ppc/testApp.o reference to undefined _sf_open
collect2: ld returned 1 exit status
Build failed (1 error, 1 warning)

Thanks,
Andrew

yes the problem is that you sndfile.a is built just for intel (i386) - where as the Release configuration of an OF xcode project is trying to build a universal binary ( i386 and ppc ). The error occurs because xcode can’t find the ppc part of the sndfile.a when trying to make a universal app.

if you change your build mode of the OF project to Debug then xcode will build just for i386 and then you won’t have the errors.

otherwise you need to rebuild the sndfile.a and make sure that architecture ( in project settings ) is set to ppc i386 ( the default is architecture of machine ) .

Unfortunately you can’t build libsndfile as a universal binary on one machine. I’ve explained this in my ofxSoundPlayer post…

Basically you can’t make a fat elf…hehe…on a single architecture as explained here:

http://www.mega-nerd.com/erikd/Blog/Cod-…-sx-ub.html
http://www.dezert-rose.com/humor/christ-…-iielf.html

Hmm - but I have a universal libsndfile which I made for a universal aubio lib.
Here it is attached.

I might have built it by hand.

I can find the original libsndfile and post it later but for now you can include this folder and have fftw, libsamplerate and aubio as well.

:slight_smile:

http://www.openframeworks.cc/files/aubioFullOSXUni.zip

Theo

Hi,

I tried both adding sndfile.h and aubioOSX.a

and also just adding the whole folder.

Both return me the following error:

CompileC build/openFrameworks.build/Release/openFrameworks.build/Objects-normal/i386/ofArduino.o /Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/my_Open_Frameworks/aubioAudioExample/…/…/…/libs/openFrameworks/communication/ofArduino.cpp normal i386 c++ com.apple.compilers.gcc.4_0
cd /Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/my_Open_Frameworks/aubioAudioExample
/usr/bin/gcc-4.0 -x c++ -arch i386 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -Os -fmessage-length=0 -Wno-deprecated-declarations -Wno-invalid-offsetof -mmacosx-version-min=10.4 -I/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/my_Open_Frameworks/aubioAudioExample/build/openFrameworks.build/Release/openFrameworks.build/openFrameworks.hmap -mdynamic-no-pic -F/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/my_Open_Frameworks/aubioAudioExample/bin -I/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/my_Open_Frameworks/aubioAudioExample/bin/include -I…/…/…/libs/poco/include -I/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/my_Open_Frameworks/aubioAudioExample/build/openFrameworks.build/Release/openFrameworks.build/DerivedSources -D__MACOSX_CORE__ -lpthread -isysroot /Developer/SDKs/MacOSX10.4u.sdk -include /Library/Caches/com.apple.Xcode.501/SharedPrecompiledHeaders/Carbon-hdkeuzsuyxqtgsbvbbcacmumqjpa/Carbon.h -c /Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/my_Open_Frameworks/aubioAudioExample/…/…/…/libs/openFrameworks/communication/ofArduino.cpp -o /Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/my_Open_Frameworks/aubioAudioExample/build/openFrameworks.build/Release/openFrameworks.build/Objects-normal/i386/ofArduino.o
i686-apple-darwin8-gcc-4.0.1: -lpthread: linker input file unused because linking not done

What should I be doing to include these correctly?

Andrew

Is your build set to use the 10.4 SDK ?
Try also doing a Clean All from the build menu.
You should drag and drop that whole folder into your sidebar and make sure reference is “relative to project”

Theo

Some good news. Starting again, I’ve managed to add aubio library to a new project and there are no compile errors. However, what is the correct directory address for sf_open() ?

I get a “directory/file not found” error.

I have been using relative to project>bin->data but tried a few others too.

Also, how would I set build to use the 10.4 SDK.? I never fixed the reason why my own addition of libsndfile.a didn’t work and suspect it may be the 1386/ppc compiler problem.

Thanks,
Andrew

Most likely sf_open looks in the directory where your app is run. This may be inside the app bundle, not sure.

If you like, have a look at the ofxSoundPlayerExample, I’m using sf_open code there, it’s in SoundFileDefault.cpp:
ttp://code.google.com/p/digitalstarcode/downloads/list

Thanks Pierre.

I’ve tried downloading your example. Strangely, I get error : ‘waitForThread’ was not declared in this scope.

It’s in SoundStream.cpp.

I tried taking your version of the library across and though it compiles, I believe I’m seeing some kind of SYSTEM ERROR when calling sf_open

Any thoughts?

Andrew

__ _ _ _ _
Build Errors:

Building target “openFrameworks” of project “openFrameworks” with configuration “Release”

Checking Dependencies
CompileC build/openFrameworks.build/Release/openFrameworks.build/Objects-normal/i386/SoundFile.o /Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/src/ofxSoundPlayer/OpenAL/SoundFile.cpp normal i386 c++ com.apple.compilers.gcc.4_0
cd /Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample
/usr/bin/gcc-4.0 -x c++ -arch i386 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -Os -fmessage-length=0 -Wno-deprecated-declarations -Wno-invalid-offsetof -mmacosx-version-min=10.4 -I/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/build/openFrameworks.build/Release/openFrameworks.build/openFrameworks.hmap -mdynamic-no-pic -F/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/bin -I/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/bin/include -Isrc/ofxSoundPlayer -Ilibs/osx/include -I…/…/…/libs/poco/include -I/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/build/openFrameworks.build/Release/openFrameworks.build/DerivedSources -D__MACOSX_CORE__ -lpthread -isysroot /Developer/SDKs/MacOSX10.4u.sdk -include /Library/Caches/com.apple.Xcode.501/SharedPrecompiledHeaders/Carbon-arlvkumzrrbtmeedxqdsdfprpbja/Carbon.h -c /Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/src/ofxSoundPlayer/OpenAL/SoundFile.cpp -o /Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/build/openFrameworks.build/Release/openFrameworks.build/Objects-normal/i386/SoundFile.o
i686-apple-darwin8-gcc-4.0.1: -lpthread: linker input file unused because linking not done

CompileC build/openFrameworks.build/Release/openFrameworks.build/Objects-normal/i386/SoundFileDefault.o /Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/src/ofxSoundPlayer/OpenAL/SoundFileDefault.cpp normal i386 c++ com.apple.compilers.gcc.4_0
cd /Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample
/usr/bin/gcc-4.0 -x c++ -arch i386 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -Os -fmessage-length=0 -Wno-deprecated-declarations -Wno-invalid-offsetof -mmacosx-version-min=10.4 -I/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/build/openFrameworks.build/Release/openFrameworks.build/openFrameworks.hmap -mdynamic-no-pic -F/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/bin -I/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/bin/include -Isrc/ofxSoundPlayer -Ilibs/osx/include -I…/…/…/libs/poco/include -I/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/build/openFrameworks.build/Release/openFrameworks.build/DerivedSources -D__MACOSX_CORE__ -lpthread -isysroot /Developer/SDKs/MacOSX10.4u.sdk -include /Library/Caches/com.apple.Xcode.501/SharedPrecompiledHeaders/Carbon-arlvkumzrrbtmeedxqdsdfprpbja/Carbon.h -c /Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/src/ofxSoundPlayer/OpenAL/SoundFileDefault.cpp -o /Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/build/openFrameworks.build/Release/openFrameworks.build/Objects-normal/i386/SoundFileDefault.o
i686-apple-darwin8-gcc-4.0.1: -lpthread: linker input file unused because linking not done

CompileC build/openFrameworks.build/Release/openFrameworks.build/Objects-normal/i386/SoundFileOgg.o /Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/src/ofxSoundPlayer/OpenAL/SoundFileOgg.cpp normal i386 c++ com.apple.compilers.gcc.4_0
cd /Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample
/usr/bin/gcc-4.0 -x c++ -arch i386 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -Os -fmessage-length=0 -Wno-deprecated-declarations -Wno-invalid-offsetof -mmacosx-version-min=10.4 -I/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/build/openFrameworks.build/Release/openFrameworks.build/openFrameworks.hmap -mdynamic-no-pic -F/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/bin -I/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/bin/include -Isrc/ofxSoundPlayer -Ilibs/osx/include -I…/…/…/libs/poco/include -I/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/build/openFrameworks.build/Release/openFrameworks.build/DerivedSources -D__MACOSX_CORE__ -lpthread -isysroot /Developer/SDKs/MacOSX10.4u.sdk -include /Library/Caches/com.apple.Xcode.501/SharedPrecompiledHeaders/Carbon-arlvkumzrrbtmeedxqdsdfprpbja/Carbon.h -c /Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/src/ofxSoundPlayer/OpenAL/SoundFileOgg.cpp -o /Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/build/openFrameworks.build/Release/openFrameworks.build/Objects-normal/i386/SoundFileOgg.o
i686-apple-darwin8-gcc-4.0.1: -lpthread: linker input file unused because linking not done

CompileC build/openFrameworks.build/Release/openFrameworks.build/Objects-normal/i386/SoundStereo.o /Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/src/ofxSoundPlayer/OpenAL/SoundStereo.cpp normal i386 c++ com.apple.compilers.gcc.4_0
cd /Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample
/usr/bin/gcc-4.0 -x c++ -arch i386 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -Os -fmessage-length=0 -Wno-deprecated-declarations -Wno-invalid-offsetof -mmacosx-version-min=10.4 -I/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/build/openFrameworks.build/Release/openFrameworks.build/openFrameworks.hmap -mdynamic-no-pic -F/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/bin -I/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/bin/include -Isrc/ofxSoundPlayer -Ilibs/osx/include -I…/…/…/libs/poco/include -I/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/build/openFrameworks.build/Release/openFrameworks.build/DerivedSources -D__MACOSX_CORE__ -lpthread -isysroot /Developer/SDKs/MacOSX10.4u.sdk -include /Library/Caches/com.apple.Xcode.501/SharedPrecompiledHeaders/Carbon-arlvkumzrrbtmeedxqdsdfprpbja/Carbon.h -c /Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/src/ofxSoundPlayer/OpenAL/SoundStereo.cpp -o /Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/build/openFrameworks.build/Release/openFrameworks.build/Objects-normal/i386/SoundStereo.o
i686-apple-darwin8-gcc-4.0.1: -lpthread: linker input file unused because linking not done

CompileC build/openFrameworks.build/Release/openFrameworks.build/Objects-normal/i386/SoundStream.o /Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/src/ofxSoundPlayer/OpenAL/SoundStream.cpp normal i386 c++ com.apple.compilers.gcc.4_0
cd /Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample
/usr/bin/gcc-4.0 -x c++ -arch i386 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -Os -fmessage-length=0 -Wno-deprecated-declarations -Wno-invalid-offsetof -mmacosx-version-min=10.4 -I/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/build/openFrameworks.build/Release/openFrameworks.build/openFrameworks.hmap -mdynamic-no-pic -F/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/bin -I/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/bin/include -Isrc/ofxSoundPlayer -Ilibs/osx/include -I…/…/…/libs/poco/include -I/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/build/openFrameworks.build/Release/openFrameworks.build/DerivedSources -D__MACOSX_CORE__ -lpthread -isysroot /Developer/SDKs/MacOSX10.4u.sdk -include /Library/Caches/com.apple.Xcode.501/SharedPrecompiledHeaders/Carbon-arlvkumzrrbtmeedxqdsdfprpbja/Carbon.h -c /Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/src/ofxSoundPlayer/OpenAL/SoundStream.cpp -o /Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/build/openFrameworks.build/Release/openFrameworks.build/Objects-normal/i386/SoundStream.o
/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/src/ofxSoundPlayer/OpenAL/SoundStream.cpp: In member function ‘void ofxOpenALPlayer::SoundStream::Stop()’:
/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/src/ofxSoundPlayer/OpenAL/SoundStream.cpp:120: error: ‘waitForThread’ was not declared in this scope

CompileC build/openFrameworks.build/Release/openFrameworks.build/Objects-normal/i386/stb_vorbis.o /Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/src/ofxSoundPlayer/stb_vorbis/stb_vorbis.c normal i386 c com.apple.compilers.gcc.4_0
cd /Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample
/usr/bin/gcc-4.0 -x c -arch i386 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -Os -fmessage-length=0 -Wno-deprecated-declarations -mmacosx-version-min=10.4 -I/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/build/openFrameworks.build/Release/openFrameworks.build/openFrameworks.hmap -mdynamic-no-pic -F/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/bin -I/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/bin/include -Isrc/ofxSoundPlayer -Ilibs/osx/include -I…/…/…/libs/poco/include -I/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/build/openFrameworks.build/Release/openFrameworks.build/DerivedSources -isysroot /Developer/SDKs/MacOSX10.4u.sdk -include /Library/Caches/com.apple.Xcode.501/SharedPrecompiledHeaders/Carbon-fbaovtdfxjciqmckkfvkfemgcmib/Carbon.h -c /Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/src/ofxSoundPlayer/stb_vorbis/stb_vorbis.c -o /Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/Downloads/ofxSoundPlayerExample/build/openFrameworks.build/Release/openFrameworks.build/Objects-normal/i386/stb_vorbis.o

If you actually want to run the example, you need to read the whole thread:
http://forum.openframeworks.cc/t/new-openal-based-ofsoundplayer/2920/0

Basically you just need to add that code to ofxThread, then if should work fine. If not let me know…

This looks great.

Unfortunately, despite changing the code, I now get compile errors (related to either Linux/Windows or some kind of library arrangement.)

Can you explain:

should I delete the Linux/windows libraries?

Should I be manually adding the osx libsndfile library?

and in general, is there a procedure for adding libraries that’s good practice?

Sorry for the questions. It’s hard to understand what’s not working here as previously I haven’t had much trouble with openFrameworks.

Andrew

_____
error: (having deleted windows/linux and added libs file in addons)
/usr/bin/ld: Undefined symbols:

/usr/bin/ld: warning -L: directory name (/Users/andrewrobertson/Work/openFrameworks_v0.06_FAT/apps/my_Open_Frameworks/ofxSoundPlayerExample/…/…/…/…/…/Desktop/libsndfile-1.0.20/build/lib) does not exist

No you don’t need to delete the windows or linux libraries they won’t interfere, they only take up disk space.

I had another look at the XCode project file and it seems it was somehow picking up a dynamic library on my system and not the static “libsndfile.a” one I was providing. Upon fixing that I discovered that my attempt to compile libsndfile for the 10.4 SDK hadn’t worked.
I used these flags:

  
  
CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -mmacosx-version-min=10.4"  
  
CPPFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -mmacosx-version-  
min=10.4"   

but they didn’t seem to have any effect. I think this is also related to how libsndfile detects the architecture and platform at run-time in the configure script. Any ideas anyone? It would be good if someone else could try this to double check.

So now I’ve uploaded a working version built only against the 10.5 SDK for intel macs.
Hopefully you are on this platform (or 10.6) and it will work for you. All you need to do is just open the XCode project and build it. If this is not the case, please let me know…

The latest file to try is here:
http://digitalstarcode.googlecode.com/f-…–0.1.2.zip

oh yeah - that is something to be aware of.

anything libXXXX.a OS X will auto look for a dynamic version of it in your /usr/local/lib/ /usr/lib/ folders.
it will pick this dynamic version over the one you ask it to use - very frustrating!

the simple trick is to get rid of the lib part of the name - or completely rename it.
then xcode doesn’t know that the dynamic one in your system root is the same.

hope that makes sense.

T

Yes, that makes total sense…
Which reminds me I need to rename that damn libdc1394.a file too!

Hey - so I dug up the universal libsndfile.

It looks like I compiled it twice with different build flags for ppc and i386 - then used lipo ( http://ss64.com/osx/lipo.html ) to join them together to make a universal lib.

The only one you need in there is the sndfile.a and the header.

Hopefully that works for people.

File is attached to this post.

Theo

libsndfileFull.zip

Oh great!

So this is built against the 10.4 SDK and is for i386 and ppc?

I tried using these flags:

CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -mmacosx-version-min=10.4"

CPPFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -mmacosx-version-min=10.4"

and couldn’t build anything other than an i386 10.5 lib, which is what my platform is. Lipo kept complaining that my two libs were identical (i.e. I never got a ppc version). Maybe I did something wrong, it previously worked for me for the libdc1394 osx libs.

hi Pierre,

I’ve just come back to this. I have libsndfile working now.

I notice that you also included the aubio library made by Paul Briossier, who happened to be in the same lab where I am now.

I was wondering: do you have a really basic example of onset detection within openframeworks using aubio? I’ve been going through the aubio page but still can’t quite work out how to initialise the structures correctly. If you had some code that opened a file (either aubio_new_sndfile) and did something like aubio_onsetdetection_energy that would be really helpful. Something along the lines of:

//e.g. …having loaded a file using sf_open

readcount = 1;

while(readcount != 0)
{

// read FRAMESIZE samples from ‘infile’ and save in ‘data’
readcount = sf_read_float(infile, frame, FRAMESIZE);

//do some kind on onset detection here???

// write ‘readcount’ samples from ‘frame’ to ‘outfile’
sf_write_float(outfile, frame, readcount) ;

}

Thanks,
Andrew