Qt vulkan classes not defined during make on windows - c++

I have been trying to compile a Qt/Vulkan project that works fine on Linux, on Windows. I am using QtCreator, Qt (5.11.0), and MingW.
I can qmake without problems, but make crashes with errors for each reference to a QVulkan* class, such as "not defined in this scope", but seems to have found and included the headers for that class.
I have tried compiling the qt vulkan examples, and got the same problem.
I ran configure -v, and found :
Qt Gui:
Vulkan ................................. yes
Here is an example of a header that crashes :
#ifndef WINDU_H
#define WINDU_H
#include <QWindow>
#include <QVulkanInstance>
#include <QVulkanFunctions>
#include <QVulkanDeviceFunctions>
class Windu : public QWindow {
public :
Windu();
~Windu();
void render();
void start();
void reset();
QVulkanInstance inst;
QVulkanFunctions* vki;
QVulkanDeviceFunctions* vkd;
};
#endif
I have stripped it down to the important : this gives not defined errors for QWindow, QVulkanInstance, QVulkanFunctions, QVulkanDeviceFunctions.
I have tried building qtgui separately, but it also crashes because it can't find Qt OpenGLES sources files.
I don't know much about C++ on windows.
This is my .pro file :
SHADERS = $$files(*.comp, true)
SHADERS += $$files(*.frag, true)
SHADERS += $$files(*.vert, true)
spirv.output = ${QMAKE_FILE_NAME}.spv
spirv.commands = glslangValidator -V ${QMAKE_FILE_NAME} -o ${QMAKE_FILE_OUT}
spirv.depends = $$SHADERS
spirv.input = SHADERS
spirv.variable_out = COMPILED_SHADERS
spirv.CONFIG = target_predeps
SOURCES = $$files(*.cpp, true)
HEADERS = $$files(*.h, true)
# install
target.path = build
target.depends = spirv
DESTDIR=bin #Target file directory
OBJECTS_DIR=build #Intermediate object files directory
MOC_DIR=build #Intermediate moc files directory
CONFIG+=debug
QMAKE_EXTRA_COMPILERS += spirv
and here is the repo if needed :
https://github.com/Paul-Hubert/fantastic-octree/blob/master/fantastic-octree.pro

So I found out that on Windows, the only way to get the Vulkan classes is to build Qt yourself. I had done this, but something i had done wrong made the build unuseable. You have to build the sources as described here : http://doc.qt.io/qt-5/build-sources.html, and use that to build the project. I added a kit in QtCreator to do this.

Related

linux : make boost work with Qt Creator (undefined reference)

I've been trying to make boost work with my current IDE : Qt Creator. I've done everything that's written in this topic : Boost with Qt Creator and Linux and many others, but I still have this error :
/usr/include/boost/test/unit_test_suite.hpp:228: erreur : undefined reference to `boost::unit_test::framework::master_test_suite()'
and many others that follow
my base code is this one :
#define BOOST_TEST_MODULE MyTest
#include <boost/test/unit_test.hpp>
BOOST_AUTO_TEST_CASE( my_test )
{
BOOST_CHECK( true );
}
which I got from this small tutorial : http://www.boost.org/doc/libs/1_41_0/libs/test/doc/html/tutorials/hello-the-testing-world.html
My .pro looks like this :
QT += testlib
QMAKE_CXXFLAGS += -std=c++11
OTHER_FILES += \
...
SOURCES += \
...
HEADERS += \
...
LIBS += \
-lboost_system
with files instead of "..."
I've done the
sudo apt-get libboost-all-dev
For information, I'm using Qt Creator 3.6.0 and Qt 5.5.1 on kubuntu 14.04 LTS
What should I do ? I hope to find an answer
Thanks in advance and tell me if I forgot to mention something
Thanks #cv_and_me for the answer :
The error was that I was not including the good library.
LIBS += \
-lboost_system
should be replaced by
LIBS += \
-lboost_unit_test_framework
I made the error to belive that boost was only for unit testing, but it could do a lot more, so we have to add the right part of boost that we will be using (in my case, the unit testing framework).
(for people at the same stage than this post, I then used this tutorial for making a good project structure, separating unit tests and the app : http://dragly.org/2014/03/13/new-project-structure-for-projects-in-qt-creator-with-unit-tests/)

Porting a Windows compiled QT application to Linux?

I created this simply application in Qt4 and would like to test it on RH Linux distro. The distro has both QtCore "Qt4" and Qt3 installed. I cannot add or delete any of these Qt versions, but would like to work with what's available.
I have an error compiling my windows based Qt program "Qt4" in Linux .
First question :
- How do I compile my compile in Linux without QT creator "only Qt libraries" are installed, what I did is get the .pro file from windows and typed qmake . , the errors are :
WARNING : Found potential symbol conflict of mainwindow.cpp (mainwwindow.cpp) in SOURCES
WARNING : Found potential symbol conflict of mainwindow.h (mainwwindow.cpp) in HEADERS
WARNING : Found potential symbol conflict of dialog.cpp (dialog.cpp) in SOURCES
WARNING : Found potential symbol conflict of dialog.h (dialog.h) in HEADERS
How can I modify qmake to specify the version of Qt
Thank you.
Below is my .pro file
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = TestTool
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
dialog.cpp
HEADERS += mainwindow.h \
dialog.h
FORMS += mainwindow.ui \
dialog.ui
The compilation error is :
Try using the Qt4 version of qmake explicitly:
/usr/lib64/qt4/bin/qmake -o Makefile TestTool.pro

Error accessing GStreamer Library in Qt C++ - Program excited with code 0xc0000135 when Debugging

I want to use gstreamer library for video programming and I read that Qt5.5.0 provided support for gstreamer-1.0, which is the library I use. I downloaded firstly version 1.0.7, but I got the following error, so I downloaded the latest version 1.5.2, which I am trying to use now.
I managed to link the gstreamer library header files, so I didn't build it, but just include its path and access the header files and libs. Anyway, now I have an error of The program has unexpectedly finished. When I try to debug it, I get the following error in a pop-up:
During startup program excited with code 0xc0000135.
On General Messages:
:1:24: Reading only version 1.1 parts.
:10:5: Expected only Component and ModuleApi object definitions.
I read many questions related to this error, but none helped, I think is an error with the gstreamer library, but may be a compiler/debugger error too, as I read in some threads.
I checked my PATH variable, as I also can not run the program outside Qt (by trying to run the .exe in debug folder of the build) - the error : library Qt5Cored.dll missing - and I found this paths:
C:\Qt\Qt5.5.0_Android\5.5\mingw492_32\lib;
C:\Users\user\Documents\build-GStreamer-test5-Desktop_Qt_5_5_0_MinGW_32bit-Debug;
C:\Qt\Qt5.5.0_Android\5.5\mingw492_32\bin;
C:\Qt\Qt5.5.0_Android\Tools\mingw492_32\bin;
C:\Windows\system32; C:\Windows; C:\Windows\System32\Wbem; C:\Windows\System32\WindowsPowerShell\v1.0;
C:\Program Files\Skype\Phone\ (I dont know why is this included, but it was there when I checked )
I am relatively new to Qt, and never encountered this error before. If you need any code:
.pro:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = GStreamer-test5
TEMPLATE = app
SOURCES += main.cpp
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
INCLUDEPATH += C:/gstreamer/1.0/x86/include/gstreamer-1.0
C:/gstreamer/1.0/x86/lib/gstreamer-1.0/include
C:/gstreamer/1.0/x86/include/glib-2.0
C:/gstreamer/1.0/x86/lib/glib-2.0/include
LIBS += -L C:/gstreamer/1.0/x86/lib/ -lgstreamer-1.0
and .main:
#include "mainwindow.h"
#include <QApplication>
#include <QDebug>
#include <stdio.h>
#include "gst/gst.h"
void *__gxx_personality_v0;
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
const gchar *nano_str;
guint major, minor, micro, nano;
gst_init (&argc, &argv);
gst_version (&major, &minor, &micro, &nano);
if (nano == 1)
nano_str = "(CVS)";
else if (nano == 2)
nano_str = "(Prerelease)";
else
nano_str = "";
// printf ("This program is linked against GStreamer %d.%d.%d %s\n", major, minor, micro, nano_str);
qDebug() << "This program is linked against GStreamer %d.%d.%d %s\n", major, minor, micro, nano_str ;
return a.exec();
Firstly, I had the error :
undefined reference to `__gxx_personality_v0' , but fixed it by adding *void __gxx_personality_v0; , although I don't know what excatly it is.
Its been three days I struggle with this problem. Any help appreciated, or maybe if you can help me by some code on how to access the header files and libs, or how the configuration of the debugger options / PATH must be.
I am using Qt5.5.0 for Android, for Windows I use MinGW 4.9.2 32 bit compiler and GNU gdb 7.8 as debugger.
Thanks in advance!
I had similar problems in my project that was using both Qt and Gstreamer.
The сause of "undefined reference to `__gxx_personality_v0'" error is that Qt and GStreamer for windows from official sites were built using different compilers and their libstdc++ libraries are not compatible - they are using different exception handling methods.
In fact, GStreamer is pure C library. The only component of it that was written in C++ is taglib library. If you will build this lib from sources using your MinGW compiler, and then replace it in the GStreamer folder, the problem of incompatibility will be solved.
In more detail you can read here: https://github.com/knowthelist/knowthelist.
I managed to solve the above problem. I had to include in the .exe folder (the build-debug folder) all the dlls included, so I tried to run the .exe from there, not run it from Qt, and some errors with dlls missing gave me the names of the dlls. I found some in my library bin folder and some downloaded, and now everything seems fine :)

SYSTEMTIME in qt

I am a bit stuck at the moment with a little sample project that I would like to run to test some cryptology that I want to use in a main project.
Basically I am using the latest Qt Creator and I have created a simple window dialog. Furthermore, I would like to test the PBKDF2 implementation through CkCrypt2
So what I have done is downloading the X64 version of the library and added it to my project folder. I then told my Qt project to use an external library, the final .pro file looks like this:
#-------------------------------------------------
#
# Project created by QtCreator 2013-06-09T18:09:44
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = crypt2test
TEMPLATE = app
SOURCES += main.cpp\
m
ainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/libs/ -lChilkatDbgDll_x64
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/libs/ -lChilkatDbgDll_x64d
else:unix: LIBS += -L$$PWD/libs/ -lChilkatDbgDll_x64
INCLUDEPATH += $$PWD/include
DEPENDPATH += $$PWD/include
I can successfully load the library but I cannot start the application.
My mainwindow.cpp looks like this:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "CkCrypt2.h"
#include <QDebug>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
CkCrypt2 crypt;
bool success;
success = crypt.UnlockComponent("Just some random text ");
if ( !success )
{
qDebug() << "Not successfully unlocking the library";
}
}
MainWindow::~MainWindow()
{
delete ui;
}
The error message I get in the compiler is:
c:\qt\qt5.0.2\tools\qtcreator\bin\crypt2test\include\CkString.h:127: error: C2061: syntax error : identifier 'SYSTEMTIME'
c:\qt\qt5.0.2\tools\qtcreator\bin\crypt2test\include\CkString.h:129: error: C2061: syntax error : identifier 'SYSTEMTIME'
C:\Qt\Qt5.0.2\Tools\QtCreator\bin\crypt2test\include\CkCrypt2.h:429: error: C2061: syntax error : identifier 'SYSTEMTIME'
Looking into the files I see:
void appendDateRfc822(SYSTEMTIME &sysTime);
void appendDateRfc822Gmt(SYSTEMTIME &sysTime);
// GETSIGNATURESIGNINGTIME_BEGIN
bool GetSignatureSigningTime(int index, SYSTEMTIME &outSysTime);
// GETSIGNATURESIGNINGTIME_END
Okay, so it is complaining about the SYSTEMTIME construct. So I look up the error C2061
Basically it says:
The compiler found an identifier where it wasn't expected. Make sure
that identifier is declared before you use it.
Which makes sense, so I look up the SYSTEMTIME and try to do :
#include <windows.h>
But that leads to many more errors in the windows.h file itself.
I use the MS Visual C++ compiler in Qt. Even though I use qmake. I am very new to this and I do not understand it all yet. Furthermore, I have no idea how to fix this, because including the windows.h does not help.
What seems to be the problem here ? Is this an issue regarding my compiler or the constulation that I use a third party app which library is compiled with MS Visual C++ and I am now trying to use this on my Windows machine in Qt with a Windows Visual C++ compiler ?
For any help I am gratefully thankful!
EDIT1:
Actually, after a clean all and qmake and build project I have now different errors and none were found in the Windows.h as previously stated. Since there were so many I have made a screenshot: http://i.imgur.com/B8EoENB.png
EDIT2:
I have adjusted the library that I include. Before this I was using the multi-threaded library of CkCrypt in the Debug mode. I have now included the single realease library. Which is located in the same directory.
When including windows.h I got the errors that things were already defined. So I removed the line again. With this result: http://i.imgur.com/z415txR.png
This shows at the bottom that MSVCRT conflichts with other library. It mentions to use NODEFAULTLIB:library but I am not to sure how to do that. Will google and keep this up to date as I process.
Many years ago, Chilkat was originally developed for the Windows platform only, and used SYSTEMTIME for this reason. In the last 5 years (approx) Chilkat is cross-platform, and SYSTEMTIME no longer makes sense. To cope with the issue, there is a "SystemTime.h" header in the same directory as the CkCrypt2.h header file. You could include this to solve the problem. (However, if WIN32 is defined, you'll probably need to edit SystemTime.h to remove the #ifdef.)
In any case, the methods using SYSTEMTIME are going to be deprecated. For any method or property that uses SYSTEMTIME, there should be a newer alternative method/property that instead uses CkDateTime.
Finally, Chilkat will test with Qt so that for the next version, (hopefully) Qt out-of-the-box will compile without any pitfalls.

Using External Lib/DLLs in Qt Creator?

I decided after a bunch of headaches all morning, that using Qt Creator for my first Qt project would probably be better than MSVC (had too many issues compiling).
I am wondering though how I can add the .dlls and .libs I need for my external tools through Qt Creator. I found this post Adding external library into Qt Creator project which makes sense.
I need a little more info though such as...Do I link dlls or libs first, what is the syntax to add dlls to the build step in qmake (i assume its close to win32:LIBS += path/to/Psapi.lib)
Thanks!
Compiling external libraries with QtCreator/gcc
If you own the source code of your libraries this is the .pro file to make an external library (.dll and .a) or Framework (on Mac OS X) from them:
TEMPLATE = lib
INCLUDEPATH = <your-include-paths>
HEADERS += <your-headers>
SOURCES += <your-sources>
TARGET = MyLib /* The name of your libary */
/* Win32: To generate a MyLib.dll and libMyLib.a (gcc) or MyLib.lib (MSVC) file */
win32 {
CONFIG += dll
}
/* Just in case you need to generate Mac Frameworks: */
macx {
CONFIG += shared lib_bundle
FRAMEWORK_HEADERS.version = Versions
FRAMEWORK_HEADERS.files += <your library headers>
/* Example:
FRAMEWORK_HEADERS.files += /path/to/your/lib/MyLib.h
*/
FRAMEWORK_HEADERS.path = Headers
QMAKE_BUNDLE_DATA = FRAMEWORK_HEADERS
VERSION = 0.5.0 // a framework version you can define
}
Adding external libraries to your QtCreator/gcc project
/* your project settings */
/* If you compile on windows */
win32 {
/* If you compile with QtCreator/gcc: */
win32-g++:LIBS += /path/to/your/libMyLib.a
/* IF you compile with MSVC: */
win32-msvc:LIBS += /path/to/your/libMyLib.lib
}
/* If compile on Mac and want to link against a framework */
macx {
LIBS+= -framework MyLib
QMAKE_FLAGS += -F/path/to/MyLib
}
Note that to use external libraries with gcc you need the libMyLib.a file that contains the linking information. The libMyLib.lib are generated by MS Visual Studio and can't be processed by gcc afaik!