Author Topic: EnvVars Plugin and PATH  (Read 30529 times)

Offline pkrcel

  • Multiple posting newcomer
  • *
  • Posts: 17
EnvVars Plugin and PATH
« on: February 09, 2012, 10:34:16 pm »
Hi there,
  I noticed a strange behavior when setting PATH EnvVar with help of the EnvVars Plugin.

I am doing a simple "hello world" kind of program using Allegro 5.0.5 Libray, and set up a very simple project with a single "main.c" and 4 targets (Debug and Release, both and dinamically statically linked to the library).

Compiling and linking is no problem and each target built correctly (and works :) )

Still, the dll's to with I dynamically link aren't in the executable path nor in Win7 %PATH%, so I defined a "liballeg" set of a single Envvar (also set to be used in the EnVars tab of project properties) "PATH" with value "%PATH%;pathtoliballegro;pathto mingwruntime libraries" (see attached pictures).

This allows me to run the dynamically linked executables without actually changing PATH in the windows environment

Well, everything works fine until I press "build" (EVEN if the current target is up to date and nothig has tobe done), then the dynamically linked executables fails to start up and the OS is giving the "unable to find dll" error message.

If I go to the envVars panel and press "set now" or I go in the envVars tab in project properties and set again the (same) set of envvars, then the executables are able to find their dll...

This does not seem the intended behavior, but maybe I am doing something wrog so I am asking if this could be a bug or is only my fault.

I am using the latest official release of C::B (10.05) over Win7, and MinGW 4.5.2 toolchain (NOT the one bundled in C::B).

Images




Thanks for any help


Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: EnvVars Plugin and PATH
« Reply #1 on: February 10, 2012, 02:37:45 am »
I have not used the EnvVars plugin before, so I could be completely wrong, but I believe what it sets are global/per-project variables (not variables in the system environment).

Something you could try is to have add your bin folder (C:\Users\Provasi\_user\Coding\Libraries\allegro-5.0.5-mingw-4.5.2\bin) to both the compiler and the linker search directories of your project.

Offline pkrcel

  • Multiple posting newcomer
  • *
  • Posts: 17
Re: EnvVars Plugin and PATH
« Reply #2 on: February 10, 2012, 08:57:19 am »
Since I am in the office, I may only be able to try this later, but I'm under the impression that it will not work...and exe looking for an external launches an OS call so I guess that the OS EnvVars are involved in the process, not compiler nor linker.

Besides, C::B correctly detects that PATH is a system EnvVar and explicitly tells that whichever value I set it will be done recursively (meaning, I guess, that the current PATH will have those value appended, not substituted).

Setting PATH in Win7 of course does the trick, but I'd like to understand if the EnvVars plugnin can be used in this way or not.

EDIT: having gone (again) through the Wiki you linked me, seems that the envvvars plugin is specifically designed to dabble with system EnvVars, as I deducted reading here
« Last Edit: February 10, 2012, 09:05:35 am by pkrcel »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12597
    • Travis build status
Re: EnvVars Plugin and PATH
« Reply #3 on: February 10, 2012, 08:58:30 am »
Alpha: You are wrong here. It sets system env variables and at least on linux it works as expected.

pkrcel: Can you try with the latest nightly build?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9594
Re: EnvVars Plugin and PATH
« Reply #4 on: February 10, 2012, 09:06:16 am »
pkrcel: Can you try with the latest nightly build?
In addition: Can you enable the ennvars "debug log" (Settings -> Environment -> Envvars) and C::B's "debug log" (by starting C::NB with the command line option --debug-log) and post what the plugin does here? It's written to the debug log then.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline pkrcel

  • Multiple posting newcomer
  • *
  • Posts: 17
Re: EnvVars Plugin and PATH
« Reply #5 on: February 10, 2012, 09:27:37 am »
I've tried with the SVN7671 and the behavior is exaclty the same.


I'm about to retrieve and post the logs.


EDIT:

Attached the debug log.  :)


EDIT2:
for completeness, the log is refered to the following actions:

- launch C::B
- selected latest project (AllegroTUT1)
- launch the "debug_Dyn" target -> "it's all good"
- press "build" -->  "nothing to be done"
- re-launch the same target -> "cannot find DLL"



« Last Edit: February 10, 2012, 09:40:11 am by pkrcel »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9594
Re: EnvVars Plugin and PATH
« Reply #6 on: February 10, 2012, 09:47:27 am »
Attached the debug log.  :)
OK, If I look at this:
EnvVars: Obtained 'liballeg' as active envvar set from config.
EnvVars: Active envvar set is 'liballeg', config path '/sets/liballeg'.
EnvVars: Searching for envvars in path '/sets/liballeg'.
EnvVars: Read 1/1 envvars in path '/sets/liballeg'.
EnvVars: Trying to set environment variable 'PATH' to value 'C:\MinGW\bin;C:\Program Files (x86)\PC Connectivity Solution\;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;c:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;c:\Program Files (x86)\Common Files\Roxio Shared\OEM\DLLShared\;c:\Program Files (x86)\Common Files\Roxio Shared\OEM\DLLShared\;c:\Program Files (x86)\Common Files\Roxio Shared\OEM\12.0\DLLShared\;c:\Program Files (x86)\Roxio\OEM\AudioCore\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\ZipGenius 6\;C:\Users\Provasi\_user\Coding\Libraries\allegro-5.0.5-mingw-4.5.2\bin;C:\MingW\bin'...
EnvVars: 1/1 envvars applied within C::B focus.

EnvVars: Obtained 'liballeg' as active envvar set from config.
EnvVars: Discarding envvars set 'liballeg'.
EnvVars: Obtained 'liballeg' as active envvar set from config.
EnvVars: Active envvar set is 'liballeg', config path '/sets/liballeg'.
EnvVars: Searching for envvars in path '/sets/liballeg'.
EnvVars: Read 1/1 envvars in path '/sets/liballeg'.
EnvVars: 1/1 envvars discarded within C::B focus.
EnvVars: Setting up envvars set 'liballeg' for activated project.
EnvVars: Active envvar set is 'liballeg', config path '/sets/liballeg'.
EnvVars: Searching for envvars in path '/sets/liballeg'.
EnvVars: Read 1/1 envvars in path '/sets/liballeg'.
EnvVars: Trying to set environment variable 'PATH' to value ';C:\Users\Provasi\_user\Coding\Libraries\allegro-5.0.5-mingw-4.5.2\bin;C:\MingW\bin'...
EnvVars: 1/1 envvars applied within C::B focus.

EnvVars: Obtained 'liballeg' as active envvar set from config.
EnvVars: Found 2 envvar sets in config.
EnvVars: Found 2 envvar sets in config.
EnvVars: Setup 2/2 envvar sets from config.
EnvVars: Active envvar set is 'liballeg' at index 1, config path '/sets/liballeg'.
EnvVars: Searching for envvars in path '/sets/liballeg'.
EnvVars: Read 1/1 envvars in path '/sets/liballeg'.
EnvVars: Trying to set environment variable 'PATH' to value ';C:\Users\Provasi\_user\Coding\Libraries\allegro-5.0.5-mingw-4.5.2\bin;C:\MingW\bin;C:\Users\Provasi\_user\Coding\Libraries\allegro-5.0.5-mingw-4.5.2\bin;C:\MingW\bin'...
EnvVars: 1/1 envvars applied within C::B focus.

I guess I know/see what happens... This might indeed be a bug due to discarding nested envvars. I'll look into it...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline pkrcel

  • Multiple posting newcomer
  • *
  • Posts: 17
Re: EnvVars Plugin and PATH
« Reply #7 on: February 10, 2012, 09:52:34 am »
Good, I'll stay tuned...and thanks for all this C::B goodness anyway :)



Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9594
Re: EnvVars Plugin and PATH
« Reply #8 on: February 10, 2012, 12:49:11 pm »
Good, I'll stay tuned...and thanks for all this C::B goodness anyway :)
Should be fixed in trunk. Feel free to try...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline pkrcel

  • Multiple posting newcomer
  • *
  • Posts: 17
Re: EnvVars Plugin and PATH
« Reply #9 on: February 10, 2012, 01:26:40 pm »
That was FAST!  ;D

Since I'm not all that accustomed with SVN/git and the like...you mean I shall retrieve all TRUNK and build Code::Blocks or I can do only the plugin?



Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9594
Re: EnvVars Plugin and PATH
« Reply #10 on: February 10, 2012, 01:35:32 pm »
Since I'm not all that accustomed with SVN/git and the like...you mean I shall retrieve all TRUNK and build Code::Blocks or I can do only the plugin?
...depends: If you link against a nightly, a checkout / build of the envvars plugin will be enough. If you are using an old version of C::B you'll have to wait for the next nightly. But I am sure it won't take long until then...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline pkrcel

  • Multiple posting newcomer
  • *
  • Posts: 17
Re: EnvVars Plugin and PATH
« Reply #11 on: February 10, 2012, 01:42:45 pm »
Ok thanks, I thought to checkout into the latest nightly I installed for this trial....will try and see, otherwise I will lazily wait for anightly :P


Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: EnvVars Plugin and PATH
« Reply #12 on: February 10, 2012, 10:44:41 pm »
EDIT: having gone (again) through the Wiki you linked me, seems that the envvvars plugin is specifically designed to dabble with system EnvVars, as I deducted reading here
Alpha: You are wrong here. It sets system env variables and at least on linux it works as expected.
Apologies for the incorrect information... it looks like I have mislead myself based on a previous edit I did to the plugin's page :-[.  (I have now changed it to be more accurate.)

Offline pkrcel

  • Multiple posting newcomer
  • *
  • Posts: 17
Re: EnvVars Plugin and PATH
« Reply #13 on: February 11, 2012, 01:17:21 am »
No need to apologize Alpha, at least to my concern :)

In the meantime I went full league and built C::B from sources (SVN 7787) , with all the contrib plugins....unfortunately it has the same behavior as 10.05, attached you can find the debug-log. ..if that is of any help.

Now that I've a fully working build environment for C::B I should be able to check faster ;D


Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9594
Re: EnvVars Plugin and PATH
« Reply #14 on: February 11, 2012, 06:12:26 am »
attached you can find the debug-log. ..if that is of any help.
Hmmm, I don't see what could go wrong now. Can you strip down you project to a minimalistic example and provide me with exact steps what you do to achieve this "error"? Also, please attach your (zipped) default.conf file - at least the ennvars section, starting with:
Code: [Select]
<envvars>
<sets>
<default>
[...]
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ