Results 1 to 9 of 9

Thread: Plugin compiler error: undefined reference

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    4
    Thanked 140 Times in 132 Posts

    Default Re: Plugin compiler error: undefined reference

    Quote Originally Posted by FinderCheng View Post
    app.pro
    Qt Code:
    1. TARGET = test
    2. TEMPLATE = app
    3. CONFIG += debug
    4. SOURCES += main.cpp
    5. LIBS += E:/documents/test/app/lib/ui.dll # I realized this is the correct syntax on Windows
    6. INCLUDEPATH += ../ui
    To copy to clipboard, switch view to plain text mode 
    I don't think so. Do you have ui.lib file generated with ui.dll. I'm not sure if DESTDIR works with it so check in debug folder. This ui.lib is the right file to link with while compiling and ui.dll it the right file to link with in runtime. And the previous syntax was okay - I use it on both - Windows and Linux.
    main.cpp
    Qt Code:
    1. // Since this is a library, I think I should use it just like QtGui and so on, so I include necessary head files and create an instance as usual
    2. #include <QtGui/QApplication>
    3. #include "mainwindow.h"
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication a(argc, argv);
    8. MainWindow win;
    9. win.show();
    10. return a.exec();
    11. }
    To copy to clipboard, switch view to plain text mode 
    That's correct.

    ui.pro
    Qt Code:
    1. # also I should edit this file in order to generate a library instead of a plugin
    2. TARGET = ui
    3. TEMPLATE = lib
    4. DEFINES += UI_LIBRARY
    5. CONFIG += debug
    6. SOURCES += mainwindow.cpp
    7. HEADERS += mainwindow.h \
    8. ui_global.h
    9. FORMS += mainwindow.ui
    10. DESTDIR = ../app/lib
    To copy to clipboard, switch view to plain text mode 
    This file looks okay now (for library).
    mainwindow.h
    Qt Code:
    1. // OK, this is almost what QtCreator generated for me, I only added show() function in order to let Qt export this function, am I right?
    To copy to clipboard, switch view to plain text mode 
    No, it is already exported in QtGui.dll as it is part of QWidget class.
    OK, when I recompile this project, there is nothing wrong.
    Are you sure? You are qmaking and building test.pro or app.pro?
    Open VS command prompt, go to the app dir and run:
    Qt Code:
    1. qmake && nmake
    To copy to clipboard, switch view to plain text mode 
    and see what you get.
    But I could not run it. It says that "E:\documents\test\app\debug\test.exe exited with code -1073741819" although I have copied ui.dll to the same directory of test.exe.
    Use Dependency Walker to check library dependencies of your app.exe. And did you try also running it from outside of QtCreator just by double clicking test.exe?
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  2. #2
    Join Date
    Sep 2009
    Location
    Nanjing, China
    Posts
    46
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    12

    Default Re: Plugin compiler error: undefined reference

    Quote Originally Posted by faldżip View Post
    I don't think so. Do you have ui.lib file generated with ui.dll. I'm not sure if DESTDIR works with it so check in debug folder. This ui.lib is the right file to link with while compiling and ui.dll it the right file to link with in runtime. And the previous syntax was okay - I use it on both - Windows and Linux.
    Sorry, I check both DESTDIR and debug folders and there is no such file called ui.lib.

    Quote Originally Posted by faldżip View Post
    Are you sure? You are qmaking and building test.pro or app.pro?
    Yes, I rebuild project with test.pro and app.pro each time and there is no error.

    Quote Originally Posted by faldżip View Post
    Open VS command prompt, go to the app dir and run:
    Qt Code:
    1. qmake && nmake
    To copy to clipboard, switch view to plain text mode 
    and see what you get.
    I'm sorry but I have no VS compiler. So I open app.pro as a separate project and build it, nothing wrong here.

    Quote Originally Posted by faldżip View Post
    Use Dependency Walker to check library dependencies of your app.exe. And did you try also running it from outside of QtCreator just by double clicking test.exe?
    I have a little trouble with Dependency Walker. What results should I looking for? I checked test.exe(not app.exe, TARGET = test in app.pro) and its library contains ui.dll. And I tried to open test.exe outside QtCreator, no window opened...
    Last edited by FinderCheng; 1st May 2010 at 17:54.

Similar Threads

  1. Getting Undefined Reference Error
    By A.H.M. Mahfuzur Rahman in forum Qt Programming
    Replies: 2
    Last Post: 22nd June 2009, 03:12
  2. Error - undefined reference qMain
    By tpf80 in forum Newbie
    Replies: 4
    Last Post: 23rd February 2009, 08:54
  3. Error : undefined reference to `vtable for MyClass'
    By joseph in forum Qt Programming
    Replies: 23
    Last Post: 15th June 2007, 12:21
  4. error undefined reference ...............
    By amit_pansuria in forum Qt Programming
    Replies: 2
    Last Post: 8th June 2007, 15:28
  5. Undefined Reference error!!!
    By Kapil in forum Newbie
    Replies: 25
    Last Post: 28th March 2006, 13:03

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
  •  
Qt is a trademark of The Qt Company.