how compile .c file when using vorbis library. undefined reference to vorbis_info_init

419 Views Asked by At

I installed libvorbis-div with sudo apt install libvorbis-dev. But when i tried to compile my simple code with gcc a.c command, i get "undefined reference to `vorbis_info_init'" error.

a.c

#include "vorbis/codec.h"
int main(int argc, char **argv){
   vorbis_info vi;
   vorbis_info_init(&vi);
   return(0);
}
1

There are 1 best solutions below

0
arashka On BEST ANSWER

If you are only running gcc a.c, then you are missing the linker arguments. You should introduce the library you are using to the compiler/linker, which in this case is gcc.

P.S. Probably just add -lvorbis, but don't just copy-paste, parse these flags in your brain!