Results 1 to 2 of 2

Thread: Problem with library linking / Execution failed [SOLVED]

  1. #1
    Join Date
    Dec 2016
    Posts
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Problem with library linking / Execution failed [SOLVED]

    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 Code:
    1. QT += gui widgets core
    To copy to clipboard, switch view to plain text mode 

    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 :

    Qt Code:
    1. QXcbConnection: Could not connect to display
    2. Aborted (core dumped)
    To copy to clipboard, switch view to plain text mode 

    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 :

    Qt Code:
    1. #include <QtWidgets/QtWidgets>
    2.  
    3. int main(int argc, char *argv[])
    4. {
    5. QString fontname("Calibri Light");
    6. int fontsize = 12;
    7. int fontweight = 50;
    8. bool italic = false;
    9. int windowSizeX = 200;
    10. int windowSizeY = 400;
    11.  
    12. QApplication app(argc, argv);
    13. QWidget window;
    14. window.setFixedSize(windowSizeX,windowSizeY);
    15. QFont font(fontname, fontsize, fontweight, italic);
    16. QPushButton bouton("Test", &window);
    17. bouton.setFont(font);
    18. bouton.setCursor(Qt::PointingHandCursor);
    19. bouton.setToolTip("TestTip");
    20.  
    21. window.show();
    22.  
    23. return app.exec();
    24. }
    To copy to clipboard, switch view to plain text mode 

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

    Qt Code:
    1. CONFIG += qt
    2. TARGET = test
    3. SOURCES += main.cpp
    To copy to clipboard, switch view to plain text mode 

    And it returned me the following compilation line :

    Qt Code:
    1. g++ -o test.exe main.o -lpthread -lQt5Gui -lQt5Core -lGL
    To copy to clipboard, switch view to plain text mode 

    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 :

    Qt Code:
    1. /cygdrive/d/test/main.cpp:12: référence indéfinie vers « __imp__ZN12QApplicationC1ERiPPci »
    2. /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
    3. /cygdrive/d/test/main.cpp:13: référence indéfinie vers « __imp__ZN7QWidgetC1EPS_6QFlagsIN2Qt10WindowTypeEE »
    4. /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
    5. /cygdrive/d/test/main.cpp:16: référence indéfinie vers « __imp__ZN11QPushButtonC1ERK7QStringP7QWidget »
    6. /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
    7. /cygdrive/d/test/main.cpp:19: référence indéfinie vers « __imp__ZN7QWidget10setToolTipERK7QString »
    8. /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
    9. collect2: erreur*: ld a retourné 1 code d'état d'exécution
    To copy to clipboard, switch view to plain text mode 

    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
    Last edited by jojo9191; 1st December 2016 at 02:57. Reason: Just solved the problem

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,019
    Thanks
    233
    Thanked 639 Times in 629 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Problem with library linking / Execution failed [SOLVED]

    Wow.

    Maybe you could put your problem-solving skills to work on finding a way to have world peace...
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 2
    Last Post: 30th July 2013, 09:05
  2. Problem linking library
    By tom989 in forum Newbie
    Replies: 1
    Last Post: 2nd May 2013, 07:06
  3. Problem linking against library
    By PowerPlate in forum Qt Programming
    Replies: 3
    Last Post: 15th October 2011, 02:45
  4. Help needed linking to library
    By StephenR in forum Qt Programming
    Replies: 4
    Last Post: 3rd July 2009, 08:50
  5. linking qt3 to a library
    By thebra in forum Newbie
    Replies: 10
    Last Post: 11th November 2006, 01:25

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.