0

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?

TJ1
  • 7,578
  • 19
  • 76
  • 119

1 Answers1

1

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
Community
  • 1
  • 1
juzzlin
  • 45,029
  • 5
  • 38
  • 50
  • I have already created a project. as I am on Linux should I use qmake ot Cmake? What is the difference? Also I looked at the link you suggested, there is no mention of how to add the options that I was asking about. For example where and how add `-lrt -lasound -lpthread -lm`, thanks for your help. – TJ1 Nov 15 '15 at 23:05
  • 1
    CMake is a more complete (configuring, finding external libraries, packaging etc) and sophisticated build tool. qmake is the default in Qt and more limited. But Qt Creator natively supports both. If you don't know, then use qmake for now. – juzzlin Nov 15 '15 at 23:08
  • Can you please help me with adding the parameters that I have listed in gcc compile? – TJ1 Nov 15 '15 at 23:10
  • Ok, I edited the answer. Just add the LIBS stuff to your project file. Of course I cannot test that, but that's the idea. – juzzlin Nov 15 '15 at 23:15