How to configure Eclipse for Gtkmm (with C++) - c++

I have set up Eclipse (on Ubuntu 20.04) for C/C++ programming and are attempting to configure the IDE for Gtkmm.
I have installed the Pkg-config support for Eclipse for CDT 1.0.0 plug-in.
Then I have created a new C++ project and checked the Gtkmm-3.0 box in
Properties
—C/C++ build
—Settings
— Pkg-config
Then I try to compile the following program:
#include <gtkmm.h>
class MyWindow : public Gtk::Window
{
public:
MyWindow();
};
MyWindow::MyWindow()
{
set_title("Basic application");
set_default_size(200, 200);
}
int main(int argc, char* argv[])
{
auto app = Gtk::Application::create("org.gtkmm.examples.base");
return app->make_window_and_run<MyWindow>(argc, argv);
}
But I get the following error:
Fatal error: Gtkmm.h : Cannot find file or folder
How do I configure the IDE or project to get it to compile?
Regards
Jarl

Related

Undefined reference to function in VlcQt (after installation)

I recently installed VlcQt libary for ubuntu 16.04, but when I try to use it, all i get is undefined reference to 'some_function()'.
Currently I am trying to expose video player to QML.
Main.cpp
#include <QGuiApplication>
#include <VLCQtCore/Common.h>
#include <VLCQtQml/QmlVideoPlayer.h>
#include "Controller.h"
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
VlcCommon::setPluginPath(app.applicationDirPath() + "plugins");
VlcQmlVideoPlayer::registerPlugin();
Controller controller;
QQuickWindow *quickWindow = qobject_cast<QQuickWindow *>(controller.view());
quickWindow->show();
return app.exec();
}
When I am trying to include libaries, Qt intellisense is detecting that this libary exists.
What am I doing wrong?
Thank you for your help!
//Edit:
I installed it via their repository:
add-apt-repository ppa:ntadej/tano
apt-get install libvlc-qt-core2 libvlc-qt-widgets2 libvlc-qt-dbg libvlc-qt-dev
//Edit:
This is how I add libs in .pro file, already tried INCLUDEPATH too
LIBS += -lvlccore -lvlc

Qt code c000001d in virtual machine

i created a project in Visual Studio 2013 with Qt. I added Qt to VS2013 with the add-in and started to design a mainwindow in the Qt Creator.
My code looks like this :
main.cpp :
#include "test2.h"
#include <QtWidgets/QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
test2 w;
w.show();
return a.exec();
}
test2.h :
#ifndef TEST2_H
#define TEST2_H
#include <QtWidgets/QMainWindow>
#include "ui_test2.h"
class test2 : public QMainWindow
{
Q_OBJECT
public:
test2(QWidget *parent = 0);
~test2();
private:
Ui::test2Class ui;
};
#endif // TEST2_H
test2.cpp :
#include "test2.h"
test2::test2(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
}
test2::~test2()
{
}
After this I built the solution and moved it to a virtual machine.
Visual Studio : 64 bit Release Version
Qt : Qt 5.3.2 for Windows 64-bit (VS 2013, OpenGL, 573 MB)
Virtual machine : 64 bit.
Installed the Visual C++ Redistributable für Visual Studio 2013 on the virtual machine.
The VmWarePlayer is used for the virtual machine.
On another normal 64bit computer everything works fine.
Problem signature:
Problem Event Name: APPCRASH
Application Name: test2.exe
Application Version: 0.0.0.0
Application Timestamp: 5434e66b
Fault Module Name: MSVCR120.dll
Fault Module Version: 12.0.21005.1
Fault Module Timestamp: 524f83ff
Exception Code: c000001d
Exception Offset: 0000000000095c01
OS Version: 6.1.7600.2.0.0.256.48
Locale ID: 1031
Additional Information 1: 6abf
Additional Information 2: 6abf78853a12e8504a5f26d8c231927b
Additional Information 3: 1f6d
Additional Information 4: 1f6d0c3c3ab43abf0b4e81f905afc8ea
My directory looks like this :
I might have found the answer for my issue, to me it helped to install all updates for the virtual machine, after this my program was running without any problems.
Some VMs have incorrect advanced instructions support. For example: native c++ application build in MSVC++ 2012/2013 x64 toolset with Advanced Vector Extensions (/arch:AVX) will CRASHED on VirtualBox with exception C000001d (invalid instruction code).
You should set project property Enable Enhanced Instruction Set to "Not Set". Only such x64 project configuration will work on all VMs.

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.

QApplication compiles with gcc 4.7 but crashes

from here http://nuwen.net/mingw.html I've downloaded gcc 4.7 and I've set this up in qt. Everything compiles fine in qt, unfortunately when I run my app (from qt) it crashes.
Any thougts?
Edit (this is this application, OS Win7, Qt 4.8):
#include <QApplication>
#include <QDialog>
int main(int c, char** v)
{
QApplication app(c,v);
QDialog* d = new QDialog();
d->show();
return app.exec();
}
If you update the compiler, you should probably recompile Qt.
Different version of gcc can work together, but they might be themselves compiled with incompatible options.

Missing File application.h in gtkmm-3.0 on Ubuntu 11.10

I'm currently trying to compile some code examples from
http://developer.gnome.org/gtkmm-tutorial/unstable/sec-treeview-examples.html.en
but from what I can see Ubuntu 11.10 gtkmm-3.0 is missing the file
/usr/include/gtkmm-3.0/gtkmm/application.h
and I can't find it anywhere else:
apt-file search "gtkmm/application.h"
returns nothing.
Even more strange, Application is not referenced anywhere under /usr/include/gtkmm-3.0/gtkmm.
Here's the main function
#include "../examplewindow.hpp"
#include <gtkmm/application.h>
int main(int argc, char *argv[])
{
Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
ExampleWindow window;
return app->run(window);
}
Have I missed something? Has the API changed recently?
After reading the good answers:
For now, with gtkmm 3.2, I use
#include "../examplewindow.hpp"
int main(int argc, char *argv[])
{
Gtk::Main kit(argc, argv);
ExampleWindow window;
Gtk::Main::run(window);
}
instead. What do I gain by using the 3.4 Application Interface instead?
According to the Gtk::Application documentation, it only exists on gtkmm 3.4+.
You can check the installed version of the package with:
pkg-config --modversion gtkmm-3.0
There was some issues wrapping GtkApplication for gtkmm 3.0 and 3.2. It's now in the 3.3.x development sources, but was recently considered "not ready". I assume it will be in good shape when 3.4 is released.