[Stk] Regarding compilation in Mac OS X

Caleb Rascon caleb.rascon at gmail.com
Wed Feb 10 11:03:22 PST 2010


Hi,

I'm new to this list, so I apologize beforehand (just in case).

When I was trying to compile the examples that come with the STK library in Mac OS X, I ran into the same problems that Atunu (atunu64 at yahoo.ca) ran into back in September 2009:

http://ccrma-mail.stanford.edu/pipermail/stk/2009-September/000644.html

Although the problem appeared to be resolved, no actual solution was implicitly given. Here are my two cents:

It is necessary to install Xcode (to gain access to the g++ compiler), and compile the libstk.a library, by doing "./configure --with-core" in the base directory of the untarred download, and then "make" in the "src" folder inside.

To compile any code that uses the STK library in Mac OS X, the complete command is:

g++ -I <directory/where/the/header/files/are/> -D__MACOSX_CORE__ -framework CoreAudio -framework CoreFoundation -o executable_file_name source_code_file.cpp -L <directory/where/the/libstk.a/file/is/>libstk.a -lpthread

This will:

- Ensure both the header files (the files inside the "include" folder inside the untarred download) and the "libstk.a" file are found.
- Include the MUTEX and CONDITION types, with the option "-D__MACOSX_CORE_", that can't be found otherwise and are necessary to compile the infamous "Mutex.h" header file.
- Include the CoreAudio and CoreFoundation frameworks referred to by the "libstk.a" file when linking (CoreMIDI may also be included by adding "-framework CoreMIDI", but I'm not using MIDI and I don't want to bloat my binaries by including it).
- Ensure that real-time processing is enabled (using the pthread library, included with the "-lpthread" option).


Example:

Lets say the header files are in "/usr/include/stk/" , the libstk.a is in "/usr/lib/" , the source code is in "source.cpp" and the binary "executable" is to be created. The command will be:

g++ -I /usr/include/stk/ -D__MACOSX_CORE__ -framework CoreAudio -framework CoreFoundation -o executable source.cpp -L /usr/lib/libstk.a -lpthread



Hope this helps further Mac developers in using this cool library. 

Caleb

PS. I'll be writing to this list later about a doubt I have regarding Multichannel I/O. So, apologies if I'm filling up people's inboxes. I promise I'm not trying to spam.



More information about the Stk mailing list