Results 1 to 12 of 12

Thread: problem with static building

  1. #1
    Join Date
    Feb 2008
    Posts
    154
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Question problem with static building

    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?

  2. #2
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    554
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problem with static building

    Read your post and then think about how we should help you with this few informations.

  3. #3
    Join Date
    Feb 2008
    Posts
    154
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problem with static building

    i used this xml code to add the console app into my resource file
    Qt Code:
    1. <file>Resources/upx.exe</file>
    To copy to clipboard, switch view to plain text mode 
    and i used this code to access the program
    Qt Code:
    1. UPX = new QProcess(this);
    2. UPX->start("./Resources/upx.exe", QStringList(QDir::toNativeSeparators(lineEdit->text())));
    To copy to clipboard, switch view to plain text mode 
    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.
    Last edited by mismael85; 28th March 2008 at 07:45.

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: problem with static building

    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.
    J-P Nurmi

  5. #5
    Join Date
    Feb 2008
    Posts
    154
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problem with static building

    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?

  6. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: problem with static building

    Quote Originally Posted by mismael85 View Post
    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.
    J-P Nurmi

  7. #7
    Join Date
    Feb 2008
    Posts
    154
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problem with static building

    i used this code
    Qt Code:
    1. QFile::copy("./resources/upx.exe", "c:\\")
    To copy to clipboard, switch view to plain text mode 
    but nothing copied in the c: directory.

  8. #8
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: problem with static building

    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.
    Qt Code:
    1. if (QFile::copy(":/Resources/upx.exe", "c:/upx.exe"))
    2. {
    3. ...
    4. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 28th March 2008 at 17:55. Reason: Changed "./Resources" to ":/Resources" as it should be
    J-P Nurmi

  9. #9
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    554
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problem with static building

    and still "./resources/upx.exe" isn't a resource path...

  10. #10
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: problem with static building

    Quote Originally Posted by ChristianEhrlicher View Post
    and still "./resources/upx.exe" isn't a resource path...
    Oops, my bad. Thanks for pointing it out.
    J-P Nurmi

  11. #11
    Join Date
    Feb 2008
    Posts
    154
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problem with static building

    what is the difference between using
    Qt Code:
    1. ./Resources/upx.exe
    To copy to clipboard, switch view to plain text mode 
    and using
    Qt Code:
    1. :/Resources/upx.exe
    To copy to clipboard, switch view to plain text mode 

  12. #12
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: problem with static building

    J-P Nurmi

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

    mismael85 (28th March 2008)

Similar Threads

  1. Replies: 16
    Last Post: 23rd May 2008, 10:12
  2. Building qt program with static library
    By JonathanForQT4 in forum Newbie
    Replies: 2
    Last Post: 22nd June 2007, 23:15
  3. Problem emitting signal from a static function
    By Valheru in forum Qt Programming
    Replies: 21
    Last Post: 12th June 2007, 14:48
  4. problem after Qt 4.2.2 static build
    By npc in forum Newbie
    Replies: 2
    Last Post: 23rd February 2007, 12:28
  5. Problem with libmng on static link
    By jlbrd in forum Installation and Deployment
    Replies: 2
    Last Post: 10th May 2006, 22: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.