How to "include" libvlc and sdl1.2 on Raspbian C++ project?

854 Views Asked by At

I have installed "libsdl1.2-dev" and "libvlc" (with sudo apt-get install blah) in Raspbian on my Raspberry Pi, I'm using gcc to compile the example project from https://wiki.videolan.org/LibVLC_SampleCode_SDL/

This is my compile command:

gcc -fpermissive test.cpp -lvlc -lsdl1.2-dev -o test

It seems to compile (after I added -fpermissive and manually placed the vlc headers in usr/include/vlc) the error seems to happen during the linking phase, I get these 2 errors;

/usr/bin/ld: cannot find -lvlc
/usr/bin/ld: cannot find -lsdl1.2-dev

I'm a bit new to Linux and I can't work out why it can't find them. I'm also unsure where it installs them by default, there seem to be a few different places they could be.

3

There are 3 best solutions below

1
On BEST ANSWER

Use pkg-config to get the needed compile and link flags. pkg-config --cflags sdl libvlc will print the needed compilation flags, and pkg-config --libs sdl libvlc the needed link flags. You can use the $() feature of the shell to embed the output of pkg-config directly into your compile command. Also, use g++ to compile and link C++ code. gcc is for C code.

g++ $(pkg-config --cflags sdl libvlc) -fpermissive test.cpp -o test $(pkg-config --libs sdl libvlc)

The package names sdl and libvlc correspond to *.pc files that are installed in /usr/lib/pkgconfig. If no such files exist, then that means you forgot to install the -dev versions of the sdl and vlc libraries. So check if there's a libvlc-dev package you need to install. Use this:

apt-cache search vlc | grep dev

See if there's a dev package for libvlc that you need.

3
On

Try sudo apt-get install vlc, you're probably missing some plugins and stuff

1
On

To install libraries and header files, try sudo apt-get install libvlc-dev this should install all the dependent libraries in the correct library paths. sudo apt-get install vlc is used to install the application which in your case you dont need.