User forums > General (but related to Code::Blocks)
C::B execution paths
oBFusCATed:
I'm playing with this patch: http://cmpt.benbmp.org/codeblocks/patches/path_env_log.patch
And the results are rather strange. The code to set the env variable seems to be executed after the command for launching the program.
I've tried both "Build & Run" and "Run".
Can someone test the patch on windows and paste the log from the "Build log" tab?
MortenMacFly:
--- Quote from: oBFusCATed on September 22, 2012, 02:13:19 pm ---Can someone test the patch on windows and paste the log from the "Build log" tab?
--- End quote ---
I'll try, but from what I can say personally: In a private project of mine I had the issue that wxSetEnv is unreliable for some reason. So what I did was the following:
--- Code: ---bool mySetEnv(const wxString& name, const wxString& value)
{
// The WX-way...
bool success = wxSetEnv(name, value);
// The MinGW-way...
wxString putenv_var = name + wxT("=") + value;
#if wxUSE_UNICODE
std::string stl_putenv_var = (const char*)putenv_var.mb_str(wxConvLocal);
#else
std::string stl_putenv_var = putenv_var.c_str();
#endif
char buffer[stl_putenv_var.length()+1]; memset(buffer, 0x00, sizeof(buffer));
memcpy(buffer, stl_putenv_var.c_str(), stl_putenv_var.length());
success &= ( putenv(buffer)==0 ); // returns 0 on success
// success &= ( _putenv(stl_putenv_var.c_str())==0 );
return success;
}// mySetEnv
--- End code ---
...then (and only then!), all my low-level code that relies on envvars being set worked properly. You may face a similar issue here.
oBFusCATed:
I don't know it wxSetEnv works, but I think there is a logic error. As the setenv is called after the program (xterm+project executable) is executed. So there is no point in setting LD_LIBRARY_PATH there.
Pecan:
--- Quote from: MortenMacFly on September 23, 2012, 12:03:51 pm ---...I had the issue that wxSetEnv is unreliable ...
--- End quote ---
I too found that setting env vars via wxWidgets did *not* work.
MortenMacFly:
--- Quote from: Pecan on September 23, 2012, 02:18:14 pm ---I too found that setting env vars via wxWidgets did *not* work.
--- End quote ---
Well sometimes it does, sometimes not. The envvar plugin within C::B works fine for me (as an example) which only used wxSetEnv. However, in my own application when I used it it did not work on Windows... or at least not all the time. I didn't find a pattern and didn't digged further into it, as my work-around (as posted) worked just fine.
--- Quote from: oBFusCATed on September 23, 2012, 12:49:07 pm ---but I think there is a logic error
--- End quote ---
Oh, I see...
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version