TJ1
TJ1

Reputation: 8498

Use QT creator on Linux to compile a portaudio based C code

I found a sample C code that uses portaudio. To be able to compile the code I had to copy a header file and a library file on my working folder. So in my folder I have the following 3 files:

- main.c
- myheader.h
- libportaudio.a

In Linux I use this to compile the code:

gcc -o myprog main.c libportaudio.a -lrt -lasound -lpthread -lm

I now want to use QT creator on Linux to compile and debug the code. How can add -lrt -lasound -lpthread -lm parameters in QT creator and how and where to add the libportaudio.a to the QT creator?

Upvotes: 0

Views: 1041

Answers (1)

juzzlin
juzzlin

Reputation: 47875

First you have to decide if you're going to use qmake or CMake with Qt Creator to build your project. Qt Creator is just an IDE that uses a build tool which in turn runs gcc or g++ or whatever. If we assume that you're using qmake you must first create a new project either from Qt Creator or from command line in your source dir:

qmake -project

This will create a .pro file where you can set your sources, compiler flags and libraries.

I recommend you to read this first: http://doc.qt.io/qt-5/qmake-tutorial.html

About linking to external library with qmake: Adding external library into Qt Creator project

LIBS += -L/path/to/libraries libportaudio.a -lrt -lasound -lpthread -lm

Upvotes: 1

Related Questions