Code::Blocks and Qt4 - c++

I´ve been trying desperately to get Qt4 running on my Code::Blocks. I´ve found the following page, with instructions I followed (German):
http://www.heikogorski.de/Compiler---Code/QT-und-Code--Blocks/qt-und-code--blocks.html
I downloaded Qt 4.8.2 like in the tutorial, checked every path 3 times and still, once I try to run the following very basic code:
#include <QApplication>
int main(int a, char ** b)
{
QApplication app(a,b);
return app.exec();
}
the window will just crash and I get the following error message in debugger:
Exception error at 0x6E1CC9A4 (QtCore4.dll) in qttest3.exe:
0xC0000005: Acesss violation at adress 0x01040806
Does anybody have an idea why?

Related

Simple C++ program failing on windows [duplicate]

This question already has answers here:
Process exit code 0xC0000135 while running Qt hello world
(1 answer)
cLion + Qt5 - exit code -1073741515 (0xC0000135)
(1 answer)
Qt error exit code -1073741515 (0xC0000135)
(1 answer)
Closed 5 months ago.
I am little new to windows platform and I may be getting something entirely wrong.
I have this simple program in C++ with Qt.
#include <iostream>
#include <QWidget>
#include <QApplication>
int main(int argc, char **argv) {
QApplication app = QApplication(argc, argv);
std::cout << "abc";
app.exec();
return 0;
}
I was able to succesfully build and link it, however when I try to run it:
Process finished with exit code -1073741515 (0xC0000135)
appears.
I think problem is with the loader so I added C:\Program Files\Qt\6.3.2\mingw_64\lib to the path, did not help.
Any ideas ?
I am using CLion, mingw, cmake, Qt6.
Update:
Using dependency walker, I got the following result:
Error
Also, this is quite new computer (may be a problem?).

How to solve the "no Qt platform plugin could be initialized" problem?

I'm trying to run a simple template in release mode on Visual Studio with the Qt extension. So far I've always been running projects in debug mode (never had trouble). Recently, I started with a browser application using webengine its widgets, but it's very slow on debug mode, so. I wanted to make sure it's possible to run with higher performance (on release mode), before continuing.
I was surprised, because the application throws 4 error message pop-ups after each other after trying to run it:
The procedure entry point ?endl#QTextStreamFunctions##YAAEAVQTextStream##AEAV2##Z could not be located in the dynamic link library C:\Qt\5.14.1\msvc2017_64\bin\Qt5WebChannel.dll.
The procedure entry point ?argToQString#QQtPrivate...QString...QStringView... could not be located in the dynamic link library C:\Qt\5.14.1\msvc2017_64\bin\Qt5WebChannel.dll.
Two more similar ones for QDebug and QRhiDepthStencilClearValue.
So instead, I tried to compile a simple project (the direct QtWidgetsApplication template) and it gave me this:
This application failed to start because no Qt Platform plugin could be initialized. Reinstalling the application may fix this problem.
I've been looking for a solution for quite some time now, but I didn't find a clear answer.
My directory: C:\Qt\5.14.1\msvc2017_64
My template code:
#include "QtWidgetsApplication2.h"
#include <QtWidgets/QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QtWidgetsApplication2 w;
w.show();
return a.exec();
}
#pragma once
#include <QtWidgets/QMainWindow>
#include "ui_QtWidgetsApplication2.h"
class QtWidgetsApplication2 : public QMainWindow
{
Q_OBJECT
public:
QtWidgetsApplication2(QWidget *parent = Q_NULLPTR);
private:
Ui::QtWidgetsApplication2Class ui;
};
#include "QtWidgetsApplication2.h"
QtWidgetsApplication2::QtWidgetsApplication2(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
}
I have no clue of how to fix this problem. Could you please help me out? Thanks in advance!
See if this helps.
Are you trying to start the program by double clicking the .exe ?
I tried to reproduce it:
build a simple project in release mode
run windeployqt ... and delete the generated folder ./platforms
double click on .exe to run it.
and prompts the error message you got.

Wt c++ critical error when creating WApplication object

I have problem with my Wt web application. It's rather simple app, I do not need to deploy it on any external server (only localhost), so built in whttpd server provided by framework is sufficient for my needs. I create an executable file in release mode (Visual Studio 2015), run it, and when I open localhost:8080 in browser to access application, I get an error. In debug mode however everything works well.
Debug console shows this:
Exception thrown at 0x00007FFB08477788 in
Neural_network_visualisation.exe: Microsoft C++ exception:
std::runtime_error at memory location 0x00000025E30FB408.
Critical error detected c0000374
Neural_network_visualisation.exe has triggered a breakpoint.
main.cpp
#include "MyApplication.h"
#include "MyContainerWidget.h"
WApplication *createApplication(const WEnvironment& env) //exception is thrown here
{
Wt::WApplication *app = new Wt::WApplication(env); //error c0000374
app->setCssTheme("polished");
new MyContainerWidget(app->root());
return app;
}
int main(int argc, char **argv)
{
return WRun(argc, argv, &createApplication);
}
The exception is thrown just after entering createApplication function, but the program doesn't crash there. After executing first line critical error is shown and application stops.
The code is so simple that I can't see any problem with it. My guess is that release mode expects some special configuration to work with Wt, but official documentation doesn't mention anything more is needed while using built-in http server. Can anybody with Wt experience help me with this?
Edit 1:
I changed my code so it looks like this:
#include "MyApplication.h"
#include "MyContainerWidget.h"
WApplication *createApplication(const WEnvironment& env)
{
//Wt::WApplication *app =
// app->setCssTheme("polished");
//new MyContainerWidget(app->root());
return new Wt::WApplication(env);;
}
int main(int argc, char **argv)
{
return WRun(argc, argv, &createApplication);
}
Now the error is different and states:
HEAP[Neural_network_visualisation.exe]: Invalid address specified to
RtlValidateHeap( 000002A04F550000, 000002A05117F060 )
So this is a memory management problem. In debug mode this management works quite different than in release, that's why I do not get any error while in debug. Unfortunately, I still do not know how to fix this. Any ideas?
Problem solved. I still can't exactly tell what was the cause, but I recompiled Wt and Boost libraries and changed project properties to match with the Wt examples. I also had to change build type from x64 to x86. It works now.

GTKmm3 (GTK+ 3 C++) compiles but throws GLib-GIO-CRITICAL error when run

I've just started trying to get GTK+ 3 working with C++ and have tried to compile the simplest GTKmm Hello-World example.
#include <gtkmm.h>
int main(int argc, char *argv[])
{
Glib::RefPtr<Gtk::Application> app =
Gtk::Application::create(argc, argv,
"org.gtkmm.examples.base");
Gtk::Window window;
window.set_default_size(200, 200);
return app->run(window);
}
After compiling with:
g++ simple.cc -o simple `pkg-config gtkmm-3.0 --cflags --libs`
There are no errors, however when I run the newly compiled application with:
./simple
I get the following error:
GLib-GIO-CRITICAL **: g_application_list_actions: assertion `application->priv->is_registered' failed
Segmentation fault (core dumped)
The code has been copied, unchanged from https://developer.gnome.org/gtkmm-tutorial/stable/sec-basics-simple-example.html.en so presumably it's likely to be a configuration issue, however I've frequently used this machine for PyGtk and CommandLine C++ without any issues.
Any help would be greatly appreciated.
This was a bug in gtkmm (probably triggered by a change in GTK+) that has been fixed in gtkmm:
https://git.gnome.org/browse/gtkmm/commit/?id=506cba376c0a0e09217ad7f5d597b6723d7f91a6
Maybe you can update your gtkmm version.

Qt4.8.1 undhandled exception at QMdiArea::addSubwindow

I compiled Qt 4.8.1 with these instructions:
http://www.holoborodko.com/pavel/2011/02/01/how-to-compile-qt-4-7-with-visual-studio-2010/
for my system (Visual Studio 2010, x64). The compilation worked and everything seemed Ok.
While compiling there is a lot of output, but it's very fast and therefore I can't read it so i suppose that shouldn't be a problem.
After I compiled succesfully my current project I got an unhandled runtime exception. After a while I discovered that it comes from the QMdiArea::addSubwindow function, which seems to throw the exception (I'm not able to catch it with overriden notify function though). So I searched for an example project to see if it's my code or something else. I found this example here:
http://www.codeprogress.com/cpp/libraries/qt/qMdiAreaAddSubWindow.php
And it works fine in 32bit mode as well as debug mode of x64, but again at the
QMdiArea::addSubwindow function there is an unhandled exception. Has anyone an idea what's wrong or had the same problem?
Currently I'm recompiling Qt to get the debug information again (i cleaned it beforehand).
But maybe someone had the same problem and a solution for me.
//Update:
The code is here (the exact same as in the link)
#include <QApplication>
#include <QMainWindow>
#include <QMdiArea>
#include <QMdiSubWindow>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QMainWindow window;
window.setFixedSize(800,600);
window.setWindowTitle(QString::fromUtf8("My QMdiWindow"));
QMdiArea* area = new QMdiArea();
area->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
//Create QMdiSubWindow
QMdiSubWindow* subWindow = new QMdiSubWindow();
subWindow->setFixedSize(200,100);
//Add subWindow to Main QMdiWindow here
area->addSubWindow(subWindow);
window.setCentralWidget(area);
window.show();
return app.exec();
}
//Update2:
I opened another discussion here.
Ok, I found the problem. It is a bug in the MSVC++ compiler. Installing the service pack and recompiling Qt again helps.