Results 1 to 7 of 7

Thread: From Qt exe to dll

  1. #1
    Join Date
    Jul 2009
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default From Qt exe to dll

    Hello,

    i built a simple console application under windows using Visual studio 2008 and qt visual studio integration.
    Now i need to transform this application in a dll.
    What should i do?
    And is it possible???

    Thanks!

  2. #2
    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: From Qt exe to dll

    Quote Originally Posted by Xeo84 View Post
    i built a simple console application under windows using Visual studio 2008 and qt visual studio integration.
    Now i need to transform this application in a dll.
    What should i do?
    Open up command line, cd to the directory containing your exe and run "ren myapp.exe myapp.dll" and your application will be transformed into dll.

    Or you could be more specific with what you really want.
    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.


  3. #3
    Join Date
    Jul 2009
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: From Qt exe to dll

    I want create a dll to import into a c# project, i already built the exe and i use it, but i want to rewrite the code as a dll so i can call the function in the dll from my c# application.

    Is it better?

  4. #4
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

  5. #5
    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: From Qt exe to dll

    If you have an event loop in your Qt application, you will probably be unable to use the library from C# - it would block your C# application until you quit() Qt's event loop.
    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.


  6. #6
    Join Date
    Jul 2009
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: From Qt exe to dll

    Ok thanks, i already read that page but i don't understand how can i do it in visual studio.

    I have one simple function in my exe, the main function!
    I want to put this fuction in the dll, make it global and import into a c# project.

    I created a new project with visual studio wizard: under qt project i choosed Qt library and pasted the code into the cpp.

    This is the function in cpp:

    Qt Code:
    1. int Mp4D::Decap(int argc, char** argv)
    2. {
    3. NaluMatcher.setPattern(QByteArray(( char*)NaluSync, 3));
    4.  
    5. assert(argc > 1);
    6.  
    7. QFile stream(argv[1]);
    8. stream.open(QIODevice::ReadOnly);
    9. QByteArray data = stream.readAll();
    10. QString output = argv[argc-1];
    11.  
    12. bool h264 = isH264(data);
    13. qDebug() << "Autodetected stream format: " << (h264 ? "H264" : "Mpeg4");
    14.  
    15.  
    16. if (h264)
    17. writeH264StreamToMp4File(data, output,25,720,576);
    18. return 0;
    19. }
    To copy to clipboard, switch view to plain text mode 
    don't look at the parameters of the function i know they r not correct, it's just an example.

    Visual studio compile it but it doesn't like any dll or lib.

    The .pro generated by Visual studio is this:
    Qt Code:
    1. TEMPLATE = lib
    2. TARGET = Mp4DecapDll
    3. DESTDIR = ../Release
    4. QT += core qtmain
    5. CONFIG += staticlib
    6. DEFINES += QT_LARGEFILE_SUPPORT MP4DECAPDLL_LIB
    7. INCLUDEPATH += ./GeneratedFiles \
    8. ./GeneratedFiles/Release \
    9. .
    10. LIBS += -llibmp4v2
    11. DEPENDPATH += .
    12. MOC_DIR += ./GeneratedFiles/release
    13. OBJECTS_DIR += release
    14. UI_DIR += ./GeneratedFiles
    15. RCC_DIR += ./GeneratedFiles
    16. include(Mp4DecapDll.pri)
    To copy to clipboard, switch view to plain text mode 

    What should i do??

    Thanks!

  7. #7
    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: From Qt exe to dll

    You need to put the export macro in your class. It's explained in the docs you were given (at the very beginning).
    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.


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.