PDA

View Full Version : From Qt exe to dll



Xeo84
21st September 2010, 14:38
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!

wysota
21st September 2010, 15:36
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.

Xeo84
21st September 2010, 15:43
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?

tbscope
21st September 2010, 16:04
http://doc.qt.nokia.com/4.6/sharedlibrary.html

wysota
21st September 2010, 16:11
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.

Xeo84
22nd September 2010, 07:52
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:



int Mp4D::Decap(int argc, char** argv)
{
NaluMatcher.setPattern(QByteArray(( char*)NaluSync, 3));

assert(argc > 1);

QFile stream(argv[1]);
stream.open(QIODevice::ReadOnly);
QByteArray data = stream.readAll();
QString output = argv[argc-1];

bool h264 = isH264(data);
qDebug() << "Autodetected stream format: " << (h264 ? "H264" : "Mpeg4");


if (h264)
writeH264StreamToMp4File(data, output,25,720,576);
return 0;
}

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:


TEMPLATE = lib
TARGET = Mp4DecapDll
DESTDIR = ../Release
QT += core qtmain
CONFIG += staticlib
DEFINES += QT_LARGEFILE_SUPPORT MP4DECAPDLL_LIB
INCLUDEPATH += ./GeneratedFiles \
./GeneratedFiles/Release \
.
LIBS += -llibmp4v2
DEPENDPATH += .
MOC_DIR += ./GeneratedFiles/release
OBJECTS_DIR += release
UI_DIR += ./GeneratedFiles
RCC_DIR += ./GeneratedFiles
include(Mp4DecapDll.pri)


What should i do??

Thanks!

wysota
22nd September 2010, 09:14
You need to put the export macro in your class. It's explained in the docs you were given (at the very beginning).