Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

The library search path is not included in the PATH in the compilergcc plugin

(1/2) > >>

ollydbg:
Hi, I just build C::B trunk yesterday, and I found that if I link to a dll file directly, and the dll file is in the library search path. The old C::B can run the executable. But the latest failed, because it said the exe can't find the dll file.

Which means the PATH is not including the library search path?

I looked at the change history of the compiler gcc folder, and still not sure which commit cause this issue. The old C::B I'm using is built from 2025-02.

Miguel Gimenez:
I would bet r13731 (Running compiled program fails because of wrong PATH) is related.

ollydbg:

--- Quote from: Miguel Gimenez on September 28, 2025, 09:26:32 am ---I would bet r13731 (Running compiled program fails because of wrong PATH) is related.

--- End quote ---

Thanks.

Yes, I think this is related.

Especially here:


--- Code: ---@@ -1445,8 +1453,10 @@ int CompilerGCC::DoRunQueue()
     else
         m_timerIdleWakeUp.Start(100);
 
-    // restore dynamic linker path
+    // restore old dynamic linker path
     wxSetEnv(CB_LIBRARY_ENVVAR, oldLibPath);
+    // restore old PATH environment
+    wxSetEnv("PATH", oldPath);
 
     delete cmd;
     return DoRunQueue();
--- End code ---

The old "PATH" get restored.

I think when we click the "run" button on the toolbar, we should also set the PATH, and when run finished, we should restore the PATH.

Hi, Morten, can you have a look?

ollydbg:

--- Code: ---
-------------- Run: Debug in wx-sample (compiler: GNU GCC Compiler)---------------

Checking for existence: F\code\threepp\cb\bin\Debug\wx-sample.exe
Set variable: PATH=.;F\code\threepp\build\bin;D:/code/msys2/mingw64/lib;D:\code\msys2\mingw64\bin;D:\code\msys2\mingw64;C:\Windows\System32;C:\Windows;...
Set variable: PATH=D:\code\msys2\mingw64\bin;D:\code\msys2\mingw64\bin;D:\code\msys2\mingw64;C:\Windows\System32;C:\Windows;...
Executing: "F\code\threepp\cb\bin\Debug\wx-sample.exe"  (in F\code\threepp\cb\.)


--- End code ---

Look at the log above, it looks like the "Set variable: PATH" has run 2 times when I click the "Run" button.

The first time, the project's current folder "." (the dot), and the library search path (E:\F\code\threepp\build\bin) was already included in the PATH.

But I see the second time the PATH get restored.

The bad thing is: the executing happens after the PATH get restored.


--- Code: ---
    // restore old dynamic linker path
    wxSetEnv(CB_LIBRARY_ENVVAR, oldLibPath);
    // restore old PATH environment
    wxSetEnv("PATH", oldPath);

    delete cmd;
    return DoRunQueue();
}

--- End code ---

The above code snippet is the last section of the DoRunQueue function, and I guess it has some recursive calls, and it looks like the actual running of the executable is inside the recursive call?

So, to solve this issue, maybe, we need to "restore" the PATH variable after the inner "DoRunQueue()"?

ollydbg:
OK, it looks like under Windows system, CB_LIBRARY_ENVVAR is defined as "PATH". See below definition in prep.h



--- Code: ---#if defined(__APPLE__) && defined(__MACH__)
    #define CB_LIBRARY_ENVVAR _T("DYLD_LIBRARY_PATH")
#elif !defined(__WXMSW__)
    #define CB_LIBRARY_ENVVAR _T("LD_LIBRARY_PATH")
#else
    #define CB_LIBRARY_ENVVAR _T("PATH")
#endif

--- End code ---

Now, the code here is: we set the "PATH" 2 times under Windows. The error is: the second time we set the "PATH", we just override the lib search path!



Navigation

[0] Message Index

[#] Next page

Go to full version