System function doesn't work anymore after deploy



  • Hey, I'm using curl. I have the following code been used to send an email:

    QString cmd = "curl smtp://smtp.gmail.com:587 -v --mail-from \"xxxxxxxxxx@gmail.com\" --mail-rcpt \"xxxxxxxxx@gmail.com\" --ssl -u xxxxxxxxxxx@gmail.com:xxxxxxxxxxxxxx-T \"msg.txt\" -k --anyauth";
    const char* ccmd = cmd.toStdString().c_str();
    WinExec(ccmd, SW_HIDE);
    
    

    It works fine in Qt Creator Debug but when I "Deploy" it, it doesn't work anymore. Here is how I deployed it. { Qt Console >> cd <MyPathToMyProject> >> windeployqt --gui . } Thanks for your help...



  • @RekTek249 ,

    May be some dll's and libraries will be missing.


  • Qt Champions 2017

    make sure curl have all needed dlls also.



  • Why using WinExec rather than QProcess? but, most importantly, why using curl.exe rather than the libcurl API?



  • @VRonin Because I didn't find any code for libcurl in c++... And I'm using WinExec because I had no idea QProcess existed. I'll google that and try replacing it with that... @Vinod-Kuntoji @mrjj I use the same that in debug, it should work...



  • @RekTek249 said in System function doesn't work anymore after deploy:

    Because I didn't find any code for libcurl in c++.

    It's literally on libcurl's website: https://curl.haxx.se/libcurl/bindings.html


  • Qt Champions 2017

    Hi

    • I use the same that in debug, it should work...

    When you run the app in Creator (both release/debug) it has a runtime environment setup including paths for dlls etc.

    When you run it outside in a folder, its not setup same way.

    You could use
    http://www.dependencywalker.com/
    to see if any is listed as missing.
    I would examine the curl.exe first to see what it needs.

    windeployqt cannot know if curls need anything to run as its external app.


  • Moderators

    @RekTek249 said in System function doesn't work anymore after deploy:

    QString cmd = "curl smtp://smtp.gmail.com:587 -v --mail-from "xxxxxxxxxx@gmail.com" --mail-rcpt "xxxxxxxxx@gmail.com" --ssl -u xxxxxxxxxxx@gmail.com:xxxxxxxxxxxxxx-T "msg.txt" -k --anyauth";
    const char* ccmd = cmd.toStdString().c_str();

    One note: why do you create a QString first and then a char*? The QString in this case isn't needed, just do:

    char* cmd = "curl smtp://smtp.gmail.com:587 -v --mail-from \"xxxxxxxxxx@gmail.com\" --mail-rcpt \"xxxxxxxxx@gmail.com\" --ssl -u xxxxxxxxxxx@gmail.com:xxxxxxxxxxxxxx-T \"msg.txt\" -k --anyauth";
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.