PDA

View Full Version : problem with static building



mismael85
27th March 2008, 21:06
hi,
i built a simple GUI that uses another console application.and i embeded this console application in my GUI exe file using resources.and i built the program using shared linking and the program worked fine.but when i built my program using static linking , the program runs well but when it tries to run the console app, it failes.
what is the problem?

ChristianEhrlicher
28th March 2008, 06:44
Read your post and then think about how we should help you with this few informations.

mismael85
28th March 2008, 07:36
i used this xml code to add the console app into my resource file

<file>Resources/upx.exe</file>
and i used this code to access the program

UPX = new QProcess(this);
UPX->start("./Resources/upx.exe", QStringList(QDir::toNativeSeparators(lineEdit->text())));
note that this code works fine when it is built shared.
it only does not work when it built static.
i mean by work that my program works but when i execute the last code it do nothing. it means the program doesn not see the console app.
i hope that is enough.

jpn
28th March 2008, 07:39
First of all, you can't execute an executable which has been embedded as a resource. You would have to extract it first. Secondly, start("./Resources/upx.exe") does not even run it from resources but from a sub-directory called similarly.

mismael85
28th March 2008, 08:28
you are right.
i tried the shared version a way from the UPX.exe file and it did not work.
so how can i extracte it?

jpn
28th March 2008, 08:35
so how can i extracte it?
I'd simply try with QFile::copy() from resources to disk. This way the OS has chances to actually execute it.

mismael85
28th March 2008, 13:11
i used this code

QFile::copy("./resources/upx.exe", "c:\\")
but nothing copied in the c: directory.

jpn
28th March 2008, 14:07
I thought it was "./Resources/upx.exe" not "./resources/upx.exe" and the second parameter takes the new name even if it remains the same, not just the target path.


if (QFile::copy(":/Resources/upx.exe", "c:/upx.exe"))
{
...
}

ChristianEhrlicher
28th March 2008, 14:34
and still "./resources/upx.exe" isn't a resource path...

jpn
28th March 2008, 17:53
and still "./resources/upx.exe" isn't a resource path...
Oops, my bad. Thanks for pointing it out. ;)

mismael85
28th March 2008, 20:42
what is the difference between using

./Resources/upx.exe
and using

:/Resources/upx.exe

jpn
28th March 2008, 20:43
The Qt Resource System - Using Resources in the Application (http://doc.trolltech.com/4.3/resources.html#using-resources-in-the-application)