Results 1 to 12 of 12

Thread: dll + application

  1. #1
    Join Date
    Jul 2006
    Posts
    25
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default dll + application

    Hello,

    I've developed application + libraryunder linux and now I need to run it under windows. So I installed precompiled binaries qt4-2.2 + ming. I have generated the dll and I compiled my application, it compiles all right, but the surprise is that application don't start it crashes with a windows message, I traduct to english "The application cannot be started" (0xC0000005) click ok to close it. I put a qDebug to first line of int main() but I don't see it, so the application crashes before.

    I discovered the problem but no the solution, my application have classes that inherits from classes of the dll, for example a personalized QDialog. To reduce the problem I have created a little application that use the dll. If in a definition of some class in my application I quit the Q_OBJECT macro, the application runs without the error but I cannot connect slots, I don't understand this problem.

    Thank you.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dll + application

    Where is that DLL placed?

    Edit: Dr. Mingw might be helpful.
    Last edited by jacek; 9th April 2007 at 00:51.

  3. #3
    Join Date
    Jul 2006
    Posts
    25
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dll + application

    Hello,

    This dll is placed to c:\winnt\system32

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dll + application

    Quote Originally Posted by fpujol View Post
    This dll is placed to c:\winnt\system32
    OK, so this shouldn't be a problem, unless there's another DLL with the same name somewhere.

    Try Dr Mingw (or Dr Watson), it should catch the exception and show you a report.

  5. #5
    Join Date
    Jul 2006
    Posts
    25
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dll + application

    I don't understand it. In my application I can Instance classes from the dll but I can't inherit classes of dll with the Q_OBJECT macro declared, because the application don't start.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dll + application

    Quote Originally Posted by fpujol View Post
    I can't inherit classes of dll with the Q_OBJECT macro declared, because the application don't start.
    This might be a case of static initialization order fiasco as Q_OBJECT adds a static variable to every class.

  7. #7
    Join Date
    Aug 2006
    Posts
    44
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: dll + application

    Have you built debug versions of your DLL and application and checked it out there? C0000005 is a basic 'bad memory' exception, e.g. a NULL dereference.

    One common problem I've seen people encounter is that both the DLL and the app try to create an instance of QApplication -- which Qt insists must be a singleton. Could that be the case here?

    Also, it may be that you've got some global objects that aren't initialized. Quite often, if you've got anything but the most trivial P.O.D. objects as global data (i.e. actual constructors are invoked upon creation), you can get into trouble with the order of creation of the statics/globals in your application. I've seen this plenty of times before (e.g. in one OS, gobals initialize in a different order than on another -- or even in different build scenarios on the same OS).

    Since this problem is happening so early, first I'd check for globals / statics and:
    a) try to eliminate them ... or
    b) impose an order so you know you won't access an uninitialized global

  8. #8
    Join Date
    Aug 2006
    Posts
    44
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: dll + application

    Hah! Jacek beat me to it. I shouldn't be so long-winded. :P

  9. #9
    Join Date
    Jul 2006
    Posts
    25
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dll + application

    Hello,

    I optimized my application and my dll. I get out static and globals, now I'm working only in one class so there's no secrets but I'm in the same problem Q_OBJECT macro give me problems. I atach aklibs.pro is the pro of library. Perhaps somebody can found if there's some error. Dr. Watson don't tells nothing, now I'm searching Dr Mingw. There isn't a Dr mingw in the default qt-4.2.2+mingw precompiled binaries (setup.exe).

    You tell me to to debug versions of dll, can you tell me more details about to do it.

    Thank you.
    Attached Files Attached Files

  10. #10
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dll + application

    Are you sure all your classes are properly exported? If so splitting your app between a library and an executable shouldn't be a problem at all, even when dealing with Q_OBJECT or QApplication creation. I myself use such a design in Edyuk and everything works fine...
    Current Qt projects : QCodeEdit, RotiDeCode

  11. #11
    Join Date
    Jul 2006
    Posts
    25
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dll + application

    Hello,

    I compiled my library as staticlib and the application don't have problems runs all rigth with Q_OBJECT defined, but what that's mean ? with static lib runs ok, this mean that all is exported all rigth. This problem tells me that precomipiled binaries 4.2.2 for windows are working in static ? I'm confused in some concepts, why not in dynamic ?

  12. #12
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dll + application

    Honestly your project file does not help much, especially because it is only a subdir wrapper. What would be interesting is a minimum compilable example reproducing the bug you're facing.

    I compiled my library as staticlib and the application don't have problems
    Didn't you previously said that YOUR library had been compiled as dll (shared library)??? The notion of exporting symbols is something that is very specific because AFAIk it is required only under Window$ with SHARED libraries... Thus, a static version compiling/linking/running fine does not imply that a shared one will do the same under Window$... Exporting/importing under Qt is done through two macros Q_DECL_EXPORT and Q_DECL_IMPORT which are often wrapped by another macro for more ease of use :

    Qt Code:
    1. #ifdef _BUILD_MY_LIB_
    2. #if defined(QT_DLL) || defined(QT_SHARED)
    3. #define MYLIB_EXPORT Q_DECL_EXPORT
    4. #endif
    5. #else
    6. #define MYLIB_EXPORT Q_DECL_IMPORT
    7. #endif
    To copy to clipboard, switch view to plain text mode 

    Then definitions of classes/functions to export should be prefixed with th MYLIB_EXPORT macro (or whatever you called it of course) as follows :
    Qt Code:
    1. class MYLIB_EXPORT SomeClass {};
    2.  
    3. MYLIB_EXPORT void someFunction();
    To copy to clipboard, switch view to plain text mode 

    Hope this helps.
    Current Qt projects : QCodeEdit, RotiDeCode

  13. The following user says thank you to fullmetalcoder for this useful post:

    fpujol (16th April 2007)

Similar Threads

  1. Replies: 3
    Last Post: 6th March 2007, 19:24
  2. Replies: 3
    Last Post: 8th December 2006, 19:51
  3. Application default font
    By larry104 in forum Qt Programming
    Replies: 2
    Last Post: 16th September 2006, 02:24
  4. Gnome makes application crash
    By regix in forum Qt Programming
    Replies: 35
    Last Post: 18th August 2006, 20:44
  5. Replies: 3
    Last Post: 31st March 2006, 19:38

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.