I'm trying to add support for Ogg Vorbis in my project (C++, VS 2010). I had no problem compiling LibOgg + LibVorbis to produce a static library.
My procedure is this:
LibOgg
LibVorbis
My program
The build succeeds but unlike the static build (which works), the dynamic build just crashes in the first ov_open
call (which opens some .ogg file). I built lots of libraries (GLEW, SQlite, etc.) yet this one gives me the nuts.
Never mind, i solve this.
It seems OggVorbis is touchy when it comes to Windows and use of ov_open
due to some linking issues with stdio.h and fopen
.
Documentation says it clearly:
WARNING for Windows developers: Do not use ov_open() in Windows applications; Windows linking places restrictions on passing FILE * handles successfully, and ov_open() runs afoul of these restrictions [a]. See the ov_open_callbacks() page for details on using ov_open_callbacks() instead.
Although it is recommended by docs to use callbacks, i found ov_fopen
to be reliable which works for both static and dynamic builds with the OggVorbis; the dynamic build will crash your program if you use ov_open
on Windows.
Going to update this answer after i test it against Linux and OSX to verify ov_fopen
as a safe, all around solution.
UPDATE
As said, i tested the use of ov_fopen
on Windows 7, Linux (Lubuntu), OSX (10.8.2) and Android (KitKat 4.4.4) and i found out that works reliably. So, for those allergic to callbacks (like me), ov_fopen
proved reliably.