Reputation: 89
I need to compile a qt application on the linux command line but i have some problems including qt libraries
these are the includes on my program: InterfazArchivador.cpp:
#include "InterfazArchivador.h"
#include "ui_InterfazArchivador.h"
#include <iostream>
#include <QMainWindow>
InterfazArchivador.h:
#include <QMainWindow>
Main:
#include "InterfazArchivador.h"
#include <QApplication>
I've tried with something like this:
gcc -m32 -c -I/home/sandarka/Qt/5.4/gcc/include/QtWidgets /home/sandarka/Qt/5.4/gcc/include/QtWidgets/qwidget.h /home/sandarka/Qt/5.4/gcc/include/QtGui main.cpp ArchInterfaz.cpp
but i get errors like:
/home/sandarka/Qt/5.4/gcc/include/QtWidgets/qwidget.h:37:31: fatal error: QtGui/qwindowdefs.h: No existe el archivo o el directorio
#include <QtGui/qwindowdefs.h>
^
compilation terminated.
In file included from /home/sandarka/Qt/5.4/gcc/include/QtWidgets/QMainWindow:1:0,
from ArchInterfaz.h:4,
from main.cpp:1:
/home/sandarka/Qt/5.4/gcc/include/QtWidgets/qmainwindow.h:37:31: fatal error: QtWidgets/qwidget.h: No existe el archivo o el directorio
#include <QtWidgets/qwidget.h>
^
compilation terminated.
In file included from /home/sandarka/Qt/5.4/gcc/include/QtWidgets/QMainWindow:1:0,
from ArchInterfaz.h:4,
from ArchInterfaz.cpp:1:
/home/sandarka/Qt/5.4/gcc/include/QtWidgets/qmainwindow.h:37:31: fatal error: QtWidgets/qwidget.h: No existe el archivo o el directorio
#include <QtWidgets/qwidget.h>
^
compilation terminated.
I don't know what is wrong, maybe I need to include more libraries?
Upvotes: 0
Views: 333
Reputation: 2050
Use both include path:
gcc -m32 -c -I/home/sandarka/Qt/5.4/gcc/include/ -I/home/sandarka/Qt/5.4/gcc/include/QtWidgets -I/home/sandarka/Qt/5.4/gcc/include/QtGui main.cpp ArchInterfaz.cpp
basically you have to pass the compiler two paths:
Why two paths for the same file?
Inside a Qt module, other files are included with the <QtModuleName/FileName>
rule, without the module name you have to tell manually to the subdirectory in which to search, otherwise the compiler will expect the file in the Qt include root.
Upvotes: 1