Install OSC for Matlab on Windows
This is a short HowTo on compiling the OSC implementation by Andy Schmeder for Matlab on Windows.
Needed Tools
- MinGW: Minimalist GNU for Windows: http://prdownloads.sf.net/mingw/MinGW-5.1.4.exe?download
- MSYS: Bourne Shell for Windows: http://prdownloads.sf.net/mingw/MSYS-1.0.10.exe?download
- MinGW Developer Tool Kit: http://prdownloads.sf.net/mingw/msysDTK-1.0.1.exe?download
- MinGW Autoconf Update 2.59: http://prdownloads.sf.net/mingw/msys-autoconf-2.59.tar.bz2?download
- pthreads for Windows: Threading Library: http://www.mirrorservice.org/sites/sourceware.org/pub/pthreads-win32/pthreads-w32-2-8-0-release.tar.gz
- liblo: OSC Library: http://downloads.sourceforge.net/liblo/liblo-0.24.tar.gz
- gnumex: GCC Compiler for Matlab: http://gnumex.sourceforge.net/
- osc-mexsrc: OSC for Matlab Source: http://andy.schmeder.net/files/osc-mexsrc.zip
Installation
MinGW, MSYS and MinGW-DTK can be installed using the setup programs. Afterwards, you need to add the MinGW/bin folder to your “Path” under Settings → Control Panel → System → Advanced → Environment Variables → System Variable → Path (usually, you need to add “C:\MinGW\bin”)
Then, extract the autoconf update into the MinGW installation folder (usually, C:\MinGW). Replace existing files!
pthreads
Now we need to download and compile pthreads: Extract pthreads to C:\MinGW and start MSYS. You are now dropped to a Unix-like shell. Enter the following:
cd pthreads-w32-2-8-0-release make GC-inlined cp libpthreadGC2.a ../lib cp *.h ../include cp libpthreadGC2.a ../lib/libpthread.a
liblo
Download liblo and extract it to C:\MinGW. Open the file src/server.c in a text editor and comment the gia_strerrorA function (lines 79-95). They cause an error upon compilation.
Again, fire up MSYS and enter the following:
cd liblo-0.24 ./configure LIBS=-lws2_32 CFLAGS="-DWIN32 -D_WIN32_WINNT=0x0501" make make install
gnumex
Download and install gnumex as documented on the homepage. Run gnumex.m in Matlab and enter the details. Now you can find the file mexopts.bat in C:\Document and Settings\%USERNAME%\Application Data\Mathworks\Matlab\R2009a.
Compiling OSC
Download and extract osc-mexsrc.zip somewhere on your harddrive. Copy mexopts.bat from the previous step into this directory.
Open osc_make.m in the Editor and adapt the windows specific function at the bottom. The following works for me:
mex -Ic:\mingw\liblo-0.24 -Lc:\mingw\lib -f mexopts.bat osc_new_address.c c:\mingw\liblo-0.24\src\.libs\*.o c:\mingw\lib\libws2_32.a c:\mingw\lib\libpthreadGC2.a mex -Ic:\mingw\liblo-0.24 -Lc:\mingw\lib -f mexopts.bat osc_free_address.c c:\mingw\liblo-0.24\src\.libs\*.o c:\mingw\lib\libws2_32.a c:\mingw\lib\libpthreadGC2.a mex -Ic:\mingw\liblo-0.24 -Lc:\mingw\lib -f mexopts.bat osc_new_server.c c:\mingw\liblo-0.24\src\.libs\*.o c:\mingw\lib\libws2_32.a c:\mingw\lib\libpthreadGC2.a mex -Ic:\mingw\liblo-0.24 -Lc:\mingw\lib -f mexopts.bat osc_free_server.c c:\mingw\liblo-0.24\src\.libs\*.o c:\mingw\lib\libws2_32.a c:\mingw\lib\libpthreadGC2.a mex -Ic:\mingw\liblo-0.24 -Lc:\mingw\lib -f mexopts.bat osc_send.c c:\mingw\liblo-0.24\src\.libs\*.o c:\mingw\lib\libws2_32.a c:\mingw\lib\libpthreadGC2.a mex -Ic:\mingw\liblo-0.24 -Lc:\mingw\lib -f mexopts.bat osc_recv.c c:\mingw\liblo-0.24\src\.libs\*.o c:\mingw\lib\libws2_32.a c:\mingw\lib\libpthreadGC2.a
If everything went fine, you should now find some new .mexw32 files in your directory.