Results 1 to 19 of 19

Thread: Creator and DEF files

  1. #1
    Join Date
    Aug 2010
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Creator and DEF files

    I'm trying to develop a DLL in Qt Creator. I'm new to Qt and Creator. I'm using windows and vs2010.

    I want creator to use a DEF file for the DLL. How can I do that? I added a .def file to the project, it shows up in "Other files" and is apparently not being used.

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Creator and DEF files

    It isn't used as it serves no purpose.

    If you wish to use your DLL in QtCreator, provide the .lib and .dll files so that the dll can be imported into the executable, or just use the .dll file and use dynamic loading (meaning you write the codel to resolve the functions at runtime, rather than the OS doing it at load time). The later also allow you to exit gracefully with a better error message than the OS default.

  3. #3
    Join Date
    Aug 2010
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Creator and DEF files

    I'm trying to write a DLL with stdcall extern C functions defined (that make use of Qt), but will be used by a non-Qt program.

    In VS I was able to use the DEF file to get around the name mangling that goes on with stdcall functions. Like I said, VS just uses the DEF file (at least I don't know where it's specified to the linker), but I can't see how to get Creator to use the def file.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Creator and DEF files

    Are you asking about Creator or MinGW?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Aug 2010
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Creator and DEF files

    I'm using Creator / VS2010.

  6. #6
    Join Date
    Aug 2010
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Creator and DEF files

    Maybe I'm attacking this from the wrong angle.

    Does Creator produce intermediate make files that are used to compile and link the project via VS2010? If I can get to those I think I can adjust things as I need.

  7. #7
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Creator and DEF files

    If your using Creator/VS2010, then just modify the linker options for VS2010 to include your DEF file.

    Creator supports using whatever compiler you want, but obviously can't support every compiler and linker options those various compilers/linkers can use.

    Or you can just do everything in VS2010 and forget about Creator - since your writing the DLL in the VS2010 IDE, you may find it easier to write the application that uses the DLL in that IDE too.

  8. #8
    Join Date
    Aug 2010
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Creator and DEF files

    Quote Originally Posted by squidge View Post
    If your using Creator/VS2010, then just modify the linker options for VS2010 to include your DEF file.

    Creator supports using whatever compiler you want, but obviously can't support every compiler and linker options those various compilers/linkers can use.

    Or you can just do everything in VS2010 and forget about Creator - since your writing the DLL in the VS2010 IDE, you may find it easier to write the application that uses the DLL in that IDE too.
    I don't want to forget about Creator . But I am new to it and attempting to see if I can use it for my development.

    Are you sure Creator doesn't have full control over the VS2010 compiler/linker? That would seem odd to me. The compilers/linkers are generally controllable with command line args--how hard can that be to expose to users? I just need to figure out where/what I need to change to specify the DEF file. Maybe a Creator creator will stop by.

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Creator and DEF files

    Quote Originally Posted by qtYoda View Post
    Are you sure Creator doesn't have full control over the VS2010 compiler/linker?
    Creator calls qmake which generates a Makefile for the compiler. Forget about Creator, it has nothing to do with your problem, it's just an advanced text editor.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #10
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Creator and DEF files

    Quote Originally Posted by qtYoda View Post
    I don't want to forget about Creator . But I am new to it and attempting to see if I can use it for my development.
    Why learn something new when you can use something you are already familiar with and know how to use? Qt really doesn't offer anything over VS + Qt plugin.

    Quote Originally Posted by qtYoda View Post
    Are you sure Creator doesn't have full control over the VS2010 compiler/linker?
    It is possible, but what I mean is that if you use VS, you can specify many options using the IDE rather than figuring out the correct command line options and altering text files. Therefore I see no advantage of using Qt Creator, all I see is a disadvantage.

  11. #11
    Join Date
    Aug 2010
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Creator and DEF files

    Quote Originally Posted by squidge View Post
    Why learn something new ...
    Really!?

    Quote Originally Posted by squidge View Post
    Qt really doesn't offer anything over VS + Qt plugin.
    You may, of course, be right. But I'd like to put in some effort to see how much I can do with Creator. I like what i see. I've just run into this DEF file issue and want to see how much is buried, but controllable. I'm just new to it.


    Added after 6 minutes:


    Quote Originally Posted by wysota View Post
    Creator calls qmake which generates a Makefile for the compiler. Forget about Creator, it has nothing to do with your problem, it's just an advanced text editor.
    Yes, I figured that. But somehow the options that qmake uses must allow control of the build process for the DLL - no? So how does Creator control qmake (options, etc) so you have control of the Makefile from within Creator? I'm mean, you push the little "Run" button and all the magic happens. Something is controlling things from Creator. Can you get in between the steps to control more? Or am I just missing some of the options Creator allows?
    Last edited by qtYoda; 5th March 2011 at 19:10.

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Creator and DEF files

    Quote Originally Posted by qtYoda View Post
    But somehow the options that qmake uses must allow control of the build process for the DLL - no?
    Yes.
    So how does Creator control qmake (options, etc) so you have control of the Makefile from within Creator?
    It adds entries to the .pro file but there is no set of checkboxes you can click for advanced control over a particular compiler.
    I'm mean, you push the little "Run" button and all the magic happens.
    There is no magic. If you push "Run" (or actually "Build"), Creator calls (n)make, that's it. Qt Creator is meant to be a simplistic IDE.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  13. #13
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Creator and DEF files

    Quote Originally Posted by qtYoda View Post
    Really!?
    Yes, really. Sorry if you like learning new stuff. I rarely get that ability as I code as my main job. Deadlines ensure that if something can be done with existing tools, it will be.

  14. #14
    Join Date
    Aug 2010
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Creator and DEF files

    Quote Originally Posted by wysota View Post
    Yes.

    It adds entries to the .pro file but there is no set of checkboxes you can click for advanced control over a particular compiler.

    There is no magic. If you push "Run" (or actually "Build"), Creator calls (n)make, that's it. Qt Creator is meant to be a simplistic IDE.
    Got it. Thanks. I'll see if I can modify the makefile to get what I want. Thanks.

  15. #15
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Creator and DEF files

    Don't modify the makefile. Modify the .pro file.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  16. #16
    Join Date
    Aug 2010
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Creator and DEF files

    Quote Originally Posted by wysota View Post
    Don't modify the makefile. Modify the .pro file.
    Just when I thought I had a solution ...

    Here's what I've done so far and thought I'd got it figured out.

    1. I found the makefile generated by qmake. In it I found the following linker lines:

    $(DESTDIR_TARGET): $(OBJECTS)
    $(LINK) $(LFLAGS) /OUT:$(DESTDIR_TARGET) @<<
    $(OBJECTS) $(LIBS)

    2. I modified these lines to add the /DEF linker option with the def file:

    $(DESTDIR_TARGET): $(OBJECTS)
    $(LINK) $(LFLAGS) /OUT:$(DESTDIR_TARGET) /DEF:..\dllDialog\dllDialog.def @<<
    $(OBJECTS) $(LIBS)

    3. This did fix the stdcall name problem and it worked! I also ran clean and rebuilt and the lines stayed in the make file. So it seems only if qmake is rerun will the makefile be regenerated and I'd have to put the /DEF line back in.

    So, you suggested modifying the .pro file. How can I modify the .pro file to do the same?

  17. #17
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Creator and DEF files

    You can modify the QMAKE_LDFLAGS (or was it LFLAGS?) variable.
    qmake Code:
    1. QMAKE_LDFLAGS+="/DEF ...."
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  18. #18
    Join Date
    Aug 2010
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Creator and DEF files

    Quote Originally Posted by wysota View Post
    You can modify the QMAKE_LDFLAGS (or was it LFLAGS?) variable.
    qmake Code:
    1. QMAKE_LDFLAGS+="/DEF ...."
    To copy to clipboard, switch view to plain text mode 
    Thanks for sticking with this!

    I'll check out all the qmake settings. Until now it wasn't needed as I was more exploring the qt gui way of development.

  19. #19
    Join Date
    Jun 2011
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Creator and DEF files

    thanks a lot for this topic and answer!
    really helped!

Similar Threads

  1. Clean all the build files in Qt Creator
    By gt.beta2 in forum Qt Tools
    Replies: 4
    Last Post: 31st March 2011, 18:08
  2. regen makefile/moc files from Qt Creator ?
    By divide in forum Qt Tools
    Replies: 1
    Last Post: 3rd July 2010, 21:59
  3. Replies: 1
    Last Post: 24th October 2009, 16:11
  4. Have Creator open source files with project
    By Asperamanca in forum Qt Tools
    Replies: 2
    Last Post: 23rd October 2009, 09:25
  5. Replies: 2
    Last Post: 11th July 2006, 15:19

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.