I would like to write a GUI app using Qt and SOCI. How to write a good *.pro file to compile a project with no errors? I wrote this:
QT += core gui TARGET = example-project TEMPLATE = app SOURCES += main.cpp\ mainwindow.cpp HEADERS += mainwindow.h FORMS += mainwindow.ui INCLUDEPATH += /usr/local/include/soci\ /usr/include/postgresql/ LIBS += -lsoci_core -lsoci_postgresql -ldl -lpq
and it works but I don’t know if it’s correct.
The .pro file you wrote looks good, the INCLUDEPATH
/usr/include/postgresql/ may not need a trailing slash, however, the way to tell if it will produce “no errors” is to try it. The INCLUDEPATH definition will let you use headers from those directories like this:
LIBS+= section should only contain the libraries from SOCI that contain symbols that you reference in your code. If you are statically compiling your program it will bundle these libraries into your binary, increasing its size.
There are a lot of features you can easily add with the .pro file, and it’s helpful to know how to write one, for example you can add an application icon for Mac OS programs by adding the line:
ICON = Icon.icns
Have a look at the Qt 4.7 .pro file reference.
You can always use an auto-generated .pro file by navigating to the directory that your source is in (in a terminal), and using the command:
In my experience, the auto generated .pro file is usually incomplete, but it gives you a standard of comparison and sometimes includes stuff that you would otherwise forget.
A final method of .pro file authoring is from the QtCreator IDE. It automatically adds and subtracts things from your pro file as you add/subtract them from your project, it’s especially simple to add forms and resources in this environment.
Answered By – buster
Answer Checked By – Marie Seifert (BugsFixing Admin)