LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-11-2009, 01:35 PM   #1
Jordan&&&&
Member
 
Registered: Mar 2006
Location: Bulgaria
Distribution: OpenSuse
Posts: 70

Rep: Reputation: 15
vorbisfile - segmentation fault


I am trying to write a simple program that uses vorbisfile shared library. But I get a segmentation error when I execute my program. My code is:

Code:
#include <iostream>
using namespace std;

#include <ogg/ogg.h>
#include <vorbis/codec.h>
#include <vorbis/vorbisenc.h>
#include <vorbis/vorbisfile.h>

int main() {
    
    OggVorbis_File * song;
    vorbis_info * songInfo;

    int result = ov_fopen("./song.ogg", song);
    if (result!=0){
    	cout<<"failed";
    	return 1;
    }

    ...
    
    return 0;
}
I am compiling the program with the following line:

g++ -lvorbisfile ogg.cpp

and I receive a Segmentation fault error if the song exists when the application is run. Can you help me with this?
 
Old 02-12-2009, 08:48 AM   #2
fantas
Member
 
Registered: Jun 2007
Location: Bavaria
Distribution: slackware, xubuntu
Posts: 143

Rep: Reputation: 22
The error is that you pass an uninitialized pointer to an 'OggVorbis_File' object, while the function expects an already existing object of this kind.
The following should get you closer to what you want:

Code:
OggVorbis_File song;

int result = ov_fopen("./song.ogg", &song);

// ...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Segmentation Fault stefaandk Linux - General 2 09-04-2006 07:10 AM
yast segmentation fault, system freezing - nvidia driver at fault? BaltikaTroika SUSE / openSUSE 2 12-02-2005 09:34 AM
Segmentation fault sin-x Slackware 2 01-12-2005 03:01 PM
Segmentation fault SocialEngineer Linux - General 0 01-07-2005 12:49 PM
What is segmentation fault? Tommi Linux - General 11 05-06-2003 12:34 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:04 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration