Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Add Parent Folder Environment Path



  • Hello,
    My program is constructed so there is 2 (and more) .exe :

    • One for the "menu", the one to be launch at start
    • One (and more) for the different app we want to use

    I'm wondering how to set the root folder as an environment path for the second .exe which will be placed in /apps folder from root so I don't have to duplicate the many .dll needed for the two (and more) .exe to work.

    To illustrate, I run the "tree" command from cmp
    Now I have that (and it works)

    ³   CreateCharacterSheet.exe
    ³   CreateCharacterSheet_fr.qm
    ³   icudt53.dll
    ³   icuin53.dll
    ³   icuuc53.dll
    ³   libgcc_s_dw2-1.dll
    ³   libstdc++-6.dll
    ³   libwinpthread-1.dll
    ³   Qt5Core.dll
    ³   Qt5Gui.dll
    ³   Qt5Widgets.dll
    ³   Qt5Xml.dll
    ³   RPGUniversalCharacterSheet.exe
    ³   RPGUniversalCharacterSheet_fr.qm
    ³   
    ÀÄÄÄplatforms
            qminimal.dll
            qoffscreen.dll
            qwindows.dll
    

    and I want that (but launching CreateCharacterSheet.exe won't work due to missed .dll):

    ³   icudt53.dll
    ³   icuin53.dll
    ³   icuuc53.dll
    ³   libgcc_s_dw2-1.dll
    ³   libstdc++-6.dll
    ³   libwinpthread-1.dll
    ³   Qt5Core.dll
    ³   Qt5Gui.dll
    ³   Qt5Widgets.dll
    ³   Qt5Xml.dll
    ³   RPGUniversalCharacterSheet.exe
    ³   RPGUniversalCharacterSheet_fr.qm
    ³   
    ÃÄÄÄapps
    ³       CreateCharacterSheet.exe
    ³       CreateCharacterSheet_fr.qm     
    ÀÄÄÄplatforms
            qminimal.dll
            qoffscreen.dll
            qwindows.dll
    

    Thank you for your response


  • Lifetime Qt Champion

    Hi,

    If you are using QProcess you can use QProcess:: setProcessEnvironment



  • thank you,
    for information, i've done that :

            QProcess newProcess;
            QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
            env.insert("THIS_FOLDER", ".");
            newProcess.setProcessEnvironment(env);
            newProcess.startDetached(programPath);
    

    EDIT : the _qm (linguist) for the subexe needs to be placed in the root folder, unless you replace:

        QString locale = QLocale::system().name().section('_', 0, 0);// get system language
        QTranslator translator;
        translator.load(QString("CreateCharacterSheet_") + locale);
        a.installTranslator(&translator);
    

    by

        QString locale = QLocale::system().name().section('_', 0, 0);// get system language
        QTranslator translator;
        translator.load(QString("apps/CreateCharacterSheet_") + locale);
        a.installTranslator(&translator);
    

    solved


Log in to reply