0

I can cross compile simple Qt Project from Windows (Qt Creator) to RPi, following that.
How can I add libsndfile to my project?
I installed libsndfile to RPi then re-sync RPi<->PC with QtCrossTool. But then?

1

Make sure libsndfile is added to your toolchain libraries. Then to link it to your project add a -lsndfile flag or similar to your linker flags. You may also need to copy the libsndfile.so or similar to your raspberry pi to run the program.
If pkgconfig (bleh) is installed that is the recommended way of generating the linker flags.
Quoting the FAQ:

The pkg-config program makes finding the correct compiler flag values and library location far easier. During the installation of libsndfile, a file named sndfile.pc is installed in the directory ${libdir}/pkgconfig (ie if libsndfile is installed in /usr/local/lib, sndfile.pc will be installed in /usr/local/lib/pkgconfig/).

In order for pkg-config to find sndfile.pc it may be necessary to point the environment variable PKG_CONFIG_PATH in the right direction.

    export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

Then, to compile a C file into an object file, the command would be:

    gcc `pkg-config --cflags sndfile` -c somefile.c

and to link a number of objects into an executable that links against libsndfile, the command would be:

    gcc `pkg-config --libs sndfile` obj1.o obj2.o -o program

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.