I wrote small GTK+ application on C++ that works fine for me on Debian x64 with Gnome 3. However, it doesn't work on Lubuntu x86. So I've written test program that creates window with some widgets from my gui.glade file, and it doesn't work too on Lubuntu, but works on Debian. Here goes test code:
#include <gtk/gtk.h>
void create_window()
{
GtkBuilder *builder;
builder = gtk_builder_new();
gtk_builder_add_from_file (builder, "src/gui.glade", NULL);
gtk_builder_connect_signals (builder, NULL);
GtkWidget *window;
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
gtk_window_set_title (GTK_WINDOW (window), "Startup Settings");
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
gtk_widget_show (window);
}
int main (int argc, char *argv[])
{
gtk_init (&argc, &argv);
create_window();
gtk_main ();
}
I compile it with g++:
g++ -std=c++11 `pkg-config --cflags gtk+-3.0` test.cpp -rdynamic `pkg-config --libs gtk+-3.0`
Error output:
** (a.out:17864): WARNING **: Error retrieving accessibility bus address: org.freedesktop.DBus.Error.ServiceUnknown: The name org.a11y.Bus was not provided by any .service files
(a.out:17864): Gtk-CRITICAL **: gtk_window_set_title: assertion 'GTK_IS_WINDOW (window)' failed
(a.out:17864): GLib-GObject-WARNING **: invalid (NULL) pointer instance
(a.out:17864): GLib-GObject-CRITICAL **: g_signal_connect_data: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
(a.out:17864): Gtk-CRITICAL **: gtk_widget_show: assertion 'GTK_IS_WIDGET (widget)' faile
You can download gui.glade here.
I've just opened my gui.glade file properties and the problem became obvious. By default Glade requires the latest version of GTK+ installed on your computer. I'm using Debian unstable, so for me it's GTK 3.20. When I tested it on stable system, it didn't work, because there was GTK 3.18 installed on it.
To solve the problem I've changed my gui.glade properties via Glage and decreased required GTK version to 3.10.
Related
I Use My SQL and i developped my application on QT. I see many answer about my question but, the question was old and, i have an other probleme less speake.
my code it's just this :
#include <stdlib.h>
#include <stdio.h>
#include <QtSql>
int main(int argc, char *argv[])
{
printf("Hello wordl ! \n");
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("localhost");
db.setDatabaseName("meropyDatabase");
db.setUserName("User");
db.setPassword("ApplicationUser21!");
bool ok = db.open();
printf("Data base : %d \n",ok);
//QSqlQuery query;
db.exec("INSERT INTO Users (FirstName,LastName,IDCompany,EmailAddress) VALUES ('Jean','MICKEL',1,'jean.mickel#hotmail.fr')");
printf("erreur : %s \n",db.lastError().text().toStdString().c_str());
return 0;
}
And i have this error message :
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7
QSqlDatabase: an instance of QCoreApplication is required for loading driver plugins
QSqlQuery::exec: database not open
Hello wordl !
Data base : 0
erreur : Driver not loaded Driver not loaded
Today, i don't understand what make i for take work this...
For the option available drivers MYSQL is not here
I try to add different dll but not change....
I have juste change when i use QSQLITE but, it's connect on my database but it's don't find the table...
i use QT 5.15 and MySQL 8.0
In try to test this tuto : https://doc.qt.io/qt-5/sql-driver.html for window,
the first step it's ok, i discover the correcly directory,
But, for the second step : "qmake MYSQL_INCDIR="C:\Program Files\MySQL\Connector C++ 8.0\include" MYSQL_LIBDIR="C:\Program Files\MySQL\Connector C++ 8.0\lib64""
I have this message:
Running configuration tests...
Done running configuration tests.
Configure summary:
Qt Sql Drivers:
DB2 (IBM) .............................. no
InterBase .............................. no
MySql .................................. no
OCI (Oracle) ........................... no
ODBC ................................... no
PostgreSQL ............................. no
SQLite2 ................................ no
SQLite ................................. yes
Using system provided SQLite ......... no
TDS (Sybase) ........................... no
Qt is now configured for building. Just run 'nmake'.
Once everything is built, you must run 'nmake install'.
Qt will be installed into 'C:\Qt\5.15.2\msvc2019_64'.
Prior to reconfiguration, make sure you remove any leftovers from
the previous build.
and nmake or mingw32-make don't work
for n make i have this error :
rc /NOLOGO -DUNICODE -D_UNICODE -DWIN32 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DWIN64 -DQT_NO_LINKED_LIST -DQT_NO_JAVA_STYLE_ITERATORS -DNDEBUG -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_OMIT_COMPLETE -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_JSON1 -DSQLITE_OMIT_LOAD_EXTENSION -DQT_DEPRECATED_WARNINGS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DNDEBUG -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -D_WINDLL -fo .obj\release\qsqlite_resource.res qsqlite_resource.rc
qsqlite_resource.rc(1) : fatal error RC1015: cannot open include file 'windows.h'.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\rc.EXE"' : code retour '0x1'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\bin\Hostx64\x64\nmake.exe"' : code retour '0x2'
Stop.
NMAKE : fatal error U1077: 'cd' : code retour '0x2'
Stop.
En effect, i don't find the file windows.h or the other file for QT...
I'm in Ubuntu 20.04 using Opencv 4.4.0 in C++. I can run the file but failure throwing the next message:
[ WARN:0] global /home/user/opencv-4.4.0/modules/videoio/src/cap_gstreamer.cpp (713) open OpenCV | GStreamer warning: Error opening bin: error de sintaxis
[ WARN:0] global /home/user/opencv-4.4.0/modules/videoio/src/cap_gstreamer.cpp (480) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
Error opening video stream or file
I don't know what's the problem
undefined reference to '[various things from GLEW library]'
This is my CMakeLists.txt:
cmake_minimum_required(VERSION 3.7)
project(newerOpenGLTest)
set(CMAKE_CXX_STANDARD 11)
set(SOURCE_FILES main.cpp)
add_executable(newerOpenGLTest ${SOURCE_FILES})
find_package(OpenGL)
# tell it where to look for glew
set(CMAKE_PREFIX_PATH "F:/glew-2.0.0")
set(CMAKE_LIBRARY_PATH "F:/glew-2.0.0/lib/Release/x64")
find_package(GLEW REQUIRED)
if (GLEW_FOUND)
message(${GLEW_INCLUDE_DIRS})
message(${GLEW_LIBRARIES})
# Detect and add SFML
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH})
#Find any version 2.X of SFML
#See the FindSFML.cmake file for additional details and instructions
find_package(SFML 2 REQUIRED graphics window system)
if(SFML_FOUND)
include_directories(
${GLEW_INCLUDE_DIRS}
${SFML_INCLUDE_DIR}
)
target_link_libraries(
newerOpenGLTest
${GLEW_LIBRARIES}
${SFML_LIBRARIES}
${SFML_DEPENDENCIES}
${OPENGL_gl_LIBRARY}
)
endif()
endif()
This is the output from Cmake:
F:/glew-2.0.0/include
F:/glew-2.0.0/lib/Release/x64/glew32.lib
-- Found SFML 2.4.2 in F:/SFML-2.4.2 for GCC 6.1.0 MinGW (SEH) - 64-bit/include
-- Configuring done
-- Generating done
-- Build files have been written to: F:/Users/Doug/CLionProjects/newerOpenGLTest/cmake-build-debug
Everything looks fine to me there. It finds GLEW and finds locations for the include files and libraries.
Here is my main.cpp:
#include <GL/glew.h>
#include <SFML/Window.hpp>
int main() {
sf::Window window(sf::VideoMode(800, 600), "openGL");
window.setVerticalSyncEnabled(true);
window.setActive(true);
// Initialize GLEW
glewExperimental = true;
if (glewInit() != GLEW_OK) {
fprintf(stderr, "Failed to initialize GLEW\n");
return -1;
}
GLuint VertexArrayID;
glGenVertexArrays(1, &VertexArrayID);
glBindVertexArray(VertexArrayID);
bool running = true;
while (running) {
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed) {
running = false;
}
}
}
return 0;
}
Here is the output from linking:
Linking CXX executable newerOpenGLTest.exe
CMakeFiles\newerOpenGLTest.dir\build.make:100: recipe for target 'newerOpenGLTest.exe' failed
CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/newerOpenGLTest.dir/all' failed
CMakeFiles\Makefile2:78: recipe for target 'CMakeFiles/newerOpenGLTest.dir/rule' failed
Makefile:117: recipe for target 'newerOpenGLTest' failed
CMakeFiles\newerOpenGLTest.dir/objects.a(main.cpp.obj): In function `main':
main.cpp:xx: undefined reference to `__imp_glewExperimental'
main.cpp:xx: undefined reference to `__imp___glewGenVertexArrays'
main.cpp:xx: undefined reference to `__imp___glewBindVertexArray'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[3]: *** [newerOpenGLTest.exe] Error 1
mingw32-make.exe[2]: *** [CMakeFiles/newerOpenGLTest.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles/newerOpenGLTest.dir/rule] Error 2
mingw32-make.exe: *** [newerOpenGLTest] Error 2
Undefined reference to 3 GLEW elements.
Notice that it does not say undefined reference to '__imp_glewInit'
So it is linking some of GLEW, but not everything.
I run glewinfo.exe and the output has glGenVertexArrays: OK
I think that means my driver supports that function.
Apparently, the binaries from the GLEW website only work for Visual C++.
If you want to use it with MinGW, you have to compile your own.
Instructions copied from here:
https://www.opengl.org/discussion_boards/showthread.php/198730-How-do-I-build-GLEW-for-mingw-w64-using-cmake-on-Windows
1) Download the GLEW Source files. DO NOT download the 32/64bit Window Binaries unless you're using Visual Studio, and if you are, you wouldn't be reading this.
2) Download, install, and update msys2. Unfortunately, I was unable to find a way to compile GLEW (for mingw-w64) without it, but trust me, it's painless, and once you're done, you don't need msys2, we're only using it to compile the GLEW lib files. Follow the update instructions at the official msys2 site before you do anything else. It's only 3 steps long.
Warning: For some strange reason, once you pass the second update step, the msys2 command prompt shortcut stops working on my computer. Just navigate to the c:/msys2 folder and run msys2_shell.cmd if it does.
3) You'll need mingw-w64 for msys2. Some Stack Overflow answers suggest downloading both 64bit and 32bit versions of mingw, but since I'm no expert on the matter, it turned into a pain, so I was better off just downloading the 64bit version which is what I'm using and targeting. Run the following cmd in the msys2 cmd prompt: $ pacman -S gcc make mingw-w64-x86_64-gcc
3-a) You'll need make and gcc for msys2. Run this in the msys2 cmd line: $ pacman -S gcc make
4) Once you're done downloading mingw-w64, gcc, and make. You're ready to compile GLEW. Unzip the source files you downloaded earlier, and put it into you're C:\msys64\home\yourusername folder.
5) Open the msys2 cmd prompt, navigate to the glew2.x.x folder and run the following CMDs in the following order (as soon as each one is done):
5-a) make
5-b) make install
5-c) make install.all
6) You might get some errors and warnings, don't worry. Look in the lib folder within the glew2.x.x folder, and you'll see the lib files you'll need.
7) Copy glew32.dll into the same folder where your programs executable is, and libglew32.a into your program's lib folder.
When I run make to compile the Makefile produced by cmake, to compile an hello world example of a Qt5 application, the compilation fails with the following error:
Why is the compilation failing?
(details of what exactly I'm trying to do follow)
I'm under Windows 10, using the Qt5.5 binaries downloaded from Qt official website, mingw-w64 gcc and g++ shipped with WinBuilds, and cmake v3.6 downloaded from the official website and installed with the Windows win64-x64 Installer.
I'm trying to compile the following hello world test file, provided in Qt5's official wiki:
#include <QCoreApplication>
int main(int argc, char *argv[])
{
QCoreApplication app (argc, argv);
return app.exec();
}
The Makefile is built successfully using the command cmake -G "MinGW Makefiles" .. from a folder called build inside the directory containing the .cpp file. The following CMakeLists.txt file (taken from Qt5's cmake wiki page, with the addition of the specification of the CMAKE_PREFIX_PATH variable, which is required as for example discussed in this SO post) was used:
cmake_minimum_required(VERSION 2.8.11)
SET(CMAKE_C_COMPILER C:/WinBuilds/bin/x86_64-w64-mingw32-gcc-4.8.3.exe)
SET(CMAKE_CXX_COMPILER C:/WinBuilds/bin/x86_64-w64-mingw32-g++-4.8.3.exe)
project(testproject)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
#set(CMAKE_PREFIX_PATH "C:/WinBuilds/lib64/cmake")
set(CMAKE_PREFIX_PATH "C:/Qt/5.5/mingw492_32/lib/cmake")
find_package(Qt5Widgets)
add_executable(testfile WIN32 test.cpp)
target_link_libraries(testfile Qt5::Widgets)
(I did not use the cmake shipped with Qt5 as that did not work).
Now, the problem arises when I run make (or more precisely, mingw32-make, again shipped with WinBuilds) on the Makefile produced by cmake.
When I do this, the compilation fails with the following error (same one showed in the screenshot above):
CMakeFiles\testfile.dir/objects.a(test.cpp.obj):test.cpp:(.text+0x35): undefined reference to `__imp__ZN16QCoreApplicationC1ERiPPci'
CMakeFiles\testfile.dir/objects.a(test.cpp.obj):test.cpp:(.text+0x3e): undefined reference to `__imp__ZN16QCoreApplication4execEv'
CMakeFiles\testfile.dir/objects.a(test.cpp.obj):test.cpp:(.text+0x50): undefined reference to `__imp__ZN16QCoreApplicationD1Ev'
CMakeFiles\testfile.dir/objects.a(test.cpp.obj):test.cpp:(.text+0x67): undefined reference to `__imp__ZN16QCoreApplicationD1Ev'
c:/winbuilds/bin/../lib64/gcc/x86_64-w64-mingw32/4.8.3/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\testfile.dir/objects.a(test.cpp.obj): bad reloc address 0xc in section `.xdata'
c:/winbuilds/bin/../lib64/gcc/x86_64-w64-mingw32/4.8.3/../../../../x86_64-w64-mingw32/bin/ld.exe: final link failed: Invalid operation
collect2.exe: error: ld returned 1 exit status
CMakeFiles\testfile.dir\build.make:127: recipe for target 'testfile.exe' failed
mingw32-make[2]: *** [testfile.exe] Error 1
CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/testfile.dir/all' failed
mingw32-make[1]: *** [CMakeFiles/testfile.dir/all] Error 2
Makefile:82: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
Why is the compilation failing?
A similar undefined reference error was reported in this other SO question, but the reason there seemed to be different than the present case.
The problem is you are using 32 bit mingw compiled Qt binaries when you are trying to build a 64 bit Qt application. You need to use 64 bit Qt binaries compiled with mingw for this to work.
I'm trying to set up my Qt for college and I'm running into some issues. I'm running Windows 8, and I'm not sure which version of Qt or QtCreator but not the latest - we were given the version installer so we must use this one, although I did install the latest MinGW myself before the QtCreator setup.
I tried some demo code in QtCreator and I got the error "Unrecognized Command Line Option "-WI" when I try run the following code.
#include <QtCore/QCoreApplication>
#include <QtGui/QMessageBox>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QMessageBox msgBox;
msgBox.setText("This is some text.");
msgBox.exec();
return a.exec();
}
I need to do my assignment and I'm not sure how I can do it when I'm getting all of these strange errors.
Any help would be appreciated.
Thanks in advance!
* EDIT *
This is the error output that I can find in QtCreator during the build process.
Running build steps for project TestProject...
Configuration unchanged, skipping qmake step.
Starting: "C:/MinGW/bin/mingw32-make.exe" -w
mingw32-make: Entering directory 'C:/Users/Nick/Documents/Qt Projects/TestProject-build-desktop'
C:/MinGW/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory 'C:/Users/Nick/Documents/Qt Projects/TestProject-build-desktop'
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-subsystem,console -mthreads -Wl -o debug\TestProject.exe debug/main.o -L"c:\Qt\2010.04\qt\lib" -lQtCored4
Makefile.Debug:73: recipe for target 'debug\TestProject.exe' failed
mingw32-make[1]: Leaving directory 'C:/Users/Nick/Documents/Qt Projects/TestProject-build-desktop'
Makefile:34: recipe for target 'debug' failed
mingw32-make: Leaving directory 'C:/Users/Nick/Documents/Qt Projects/TestProject-build-desktop'
g++: error: unrecognized command line option '-Wl'
mingw32-make[1]: *** [debug\TestProject.exe] Error 1
mingw32-make: *** [debug] Error 2
The process "C:/MinGW/bin/mingw32-make.exe" exited with code %2.
Error while building project TestProject (target: Desktop)
When executing build step 'Make'
Here are the contents of the .pro file generated by QtCreator :
QT += core
QT -= gui
TARGET = TestProject
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
As Mats says the problem is the extra -Wl in the command line.
This is due to a bug in the QT conf files, and thankfully this can be fixed "permanently" (locally).
You need to edit one (possibly both) of these files (often in C:\Qt\2010.02\qt\mkspecs):
mkspecs\default\qmake.conf
mkspecs\win32-g++\qmake.conf
changing this:
QMAKE_LFLAGS = -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc
QMAKE_LFLAGS_EXCEPTIONS_ON = -mthreads -Wl
to this:
QMAKE_LFLAGS = -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc
QMAKE_LFLAGS_EXCEPTIONS_ON = -mthreads
because somehow the -Wl, from the start of the first line is wrongly on the end of the second line.
After this edit, if you clean and then rebuild your project you will no longer see the error.
Notes:
this same bug causes this issue too, so thanks to leemes for his answer there)
it is fixed in Qt since version 4.7 I believe
The problem is clearly:
g++ -enable-stdcall-fixup -Wl,-enable-auto-import
-Wl,-enable-runtime-pseudo-reloc -Wl,-subsystem,console -mthreads -Wl -o debug\TestProject.exe debug/main.o -L"c:\Qt\2010.04\qt\lib" -lQtCored4
I'm not sure exaclty how this is compiled, but to me it looks like a makefile with -Wl${somestuff} and for some reason ${somestuff} is not defined. Either that, or there is a spurious -Wl in the commendline for the link command, but that seems less likely.