PDA

View Full Version : Problem with library linking / Execution failed [SOLVED]



jojo9191
1st December 2016, 01:58
Hi,

I've just solved the problem listed below again by running a X11 server.

Cordially

-----------------------------------

Hi,

I've just solved the problem listed below in italic by adding the line :


QT += gui widgets core

to my qmake project file and I was able to compile my source code.

When I try to run it now, I get this error message :


QXcbConnection: Could not connect to display
Aborted (core dumped)


Can someone help me to solve that ?

-----------------------------------------------------
Hi,

I'm programming with the IDE Cygwin on Windows 10.

I'm trying to compile this source code named "main.cpp" written in c++ which contains :


#include <QtWidgets/QtWidgets>

int main(int argc, char *argv[])
{
QString fontname("Calibri Light");
int fontsize = 12;
int fontweight = 50;
bool italic = false;
int windowSizeX = 200;
int windowSizeY = 400;

QApplication app(argc, argv);
QWidget window;
window.setFixedSize(windowSizeX,windowSizeY);
QFont font(fontname, fontsize, fontweight, italic);
QPushButton bouton("Test", &window);
bouton.setFont(font);
bouton.setCursor(Qt::PointingHandCursor);
bouton.setToolTip("TestTip");

window.show();

return app.exec();
}

So I used qmake to get the library required with the project file "main.pro" which contains :



CONFIG += qt
TARGET = test
SOURCES += main.cpp

And it returned me the following compilation line :


g++ -o test.exe main.o -lpthread -lQt5Gui -lQt5Core -lGL

When I execute it, there are still problems with libraries.

I tried to add -lQt and it solved some dependencies but not all.

I get this error message :


/cygdrive/d/test/main.cpp:12: référence indéfinie vers « __imp__ZN12QApplicationC1ERiPPci »
/cygdrive/d/test/main.cpp:12:(.text+0x83): relocalisation tronquée pour concorder avec la taille: R_X86_64_PC32 vers le symbole indéfini __imp__ZN12QApplicationC1ERiPPci
/cygdrive/d/test/main.cpp:13: référence indéfinie vers « __imp__ZN7QWidgetC1EPS_6QFlagsIN2Qt10WindowTypeEE »
/cygdrive/d/test/main.cpp:13:(.text+0xb1): relocalisation tronquée pour concorder avec la taille: R_X86_64_PC32 vers le symbole indéfini __imp__ZN7QWidgetC1EPS_6QFlagsIN2Qt10WindowTypeEE
/cygdrive/d/test/main.cpp:16: référence indéfinie vers « __imp__ZN11QPushButtonC1ERK7QStringP7QWidget »
/cygdrive/d/test/main.cpp:16:(.text+0x128): relocalisation tronquée pour concorder avec la taille: R_X86_64_PC32 vers le symbole indéfini __imp__ZN11QPushButtonC1ERK7QStringP7QWidget
/cygdrive/d/test/main.cpp:19: référence indéfinie vers « __imp__ZN7QWidget10setToolTipERK7QString »
/cygdrive/d/test/main.cpp:19:(.text+0x1a8): relocalisation tronquée pour concorder avec la taille: R_X86_64_PC32 vers le symbole indéfini __imp__ZN7QWidget10setToolTipERK7QString
collect2: erreur*: ld a retourné 1 code d'état d'exécution

It's in French but "référence indéfinie vers" stands for "undefined reference to" and the rest is not important.

I guess it's a problem with my qmake project file.

Can someone help me to solve this ?

Cordially

d_stranz
1st December 2016, 03:33
Wow.

Maybe you could put your problem-solving skills to work on finding a way to have world peace...