• ### Announcements

#### Archived

This topic is now archived and is closed to further replies.

# ogg vorbis ov_open isn't working

## Recommended Posts

the problem is it doesn''t even return an error, just an access violation on the ov_open line. what am i doing wrong?
    OggVorbis_File VorbisFile;

FILE * oggfile = NULL;

oggfile = fopen("a.ogg", "r");
if (!oggfile)
return false;

int result = ov_open(oggfile, &VorbisFile, NULL, 0);

{
}
if(result == OV_ENOTVORBIS)
{
MessageBox(NULL, "OV_ENOTVORBIS", NULL, NULL);
}
if(result == OV_EVERSION)
{
MessageBox(NULL, "OV_EVERSION", NULL, NULL);
}
{
}
if(result == OV_EFAULT)
{
MessageBox(NULL, "OV_EFAULT", NULL, NULL);
}


##### Share on other sites
I really don''t know but try opening the file in binary format.
oggfile = fopen("a.ogg", "rb");

Update GameDev.net system time campaign: ''date ddmmHHMMYYYY''

##### Share on other sites
still doesnt work

this is the tenth try because of the (*@#(&(*&!)#*#&!)*@&)!(*#&$)(@*$&%_@\$(%*_!(*)# HTTP 500 errors.

##### Share on other sites
What OS? Most of the problems I''ve seen people have with vorbis file are Windows related, so I''ll assume that.

You must link to the same C runtime as the ogg, vorbis, and vorbis file libraries (the DLL''s are most likely built with the MSVC multithreaded runtime, and MSVC itself links with the single threaded runtimes by default). Statically linking avoids this, but isn''t as nice.

Also, like Dalleboy said, you must open it in binary mode.

##### Share on other sites

i put it in binary, "rb", and it still doesn''t work. same deal.

i''m on windows XP

anyone?

##### Share on other sites
I''ve had to deal with the very same problem as you do. Fortunately though, I have the solution for you

I suppose you are using Microsoft Visual C++ (if not, try to find similar options in your compiler options). You always need to use the same CRT library as the DLLs you''re linking to, otherwise you''ll get access violations like you did. In other words, the Ogg Vorbis DLLs were compiled with the Multithreaded DLL CRT library. However, all new projects in VC++ have the Singlethreaded CRT library setup by default, thus causing the problems you''re experiencing.

To fix this, go in the "Project\Settings" menu, on the "C/C++" tab, select the "Code Generation" category, and on the "Use run-time library" option, select "Multithreaded DLL". Compile and run, this should be working now. Please note that this is for the release configuration of your project, using the release OGG DLLs.

So you should be aware that you also need to match the debug version of your program with the debug OGG DLLs, and the debug CRT library. So for the debug configuration of your project, you need to use the OGG debug DLLs (the libs suffixed by a _d), and the "Multithreaded Debug DLL" CRT library.

There might be a few things I missed, but this is guaranteed to work.

Good luck!
- Veldhar Windrider

• ### Forum Statistics

• Total Topics
628282
• Total Posts
2981812

• 9
• 10
• 11
• 17
• 15