Author Topic: Solution for: Latest changes in HEAD break C::B build  (Read 16964 times)

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Solution for: Latest changes in HEAD break C::B build
« on: July 13, 2005, 12:45:31 pm »
In this thread, there was some talk regarding usage of environment variables in C::B.

I 've made some relevant updates that won't allow anyone to build C::B HEAD unless the following instructions are followed the first time.
First an overview of custom/environment variables in C::B.

You 've probably noticed the "Custom variables" page in global compiler options. There you can add custom variables that can be used in the compiler/linker options.
I 've extended their usage and now they 're set as environment variables when the build process is launched. This enhances the build process a lot, in many ways.
If you take a look at the project options of CodeBlocks-wx.2.6.0.cbp you 'll notice that I 've added the wxWidgets dirs in compiler/linker dirs using two custom variables: WX_DIR and WX_CFG.
This means you can build C::B no matter where you have wxWidgets headers/libs. You just have to set WX_DIR and WX_CFG accordingly.
And the good thing is that you can set those either as custom variables in the global compiler settings or as system environment variables.
Mine are set as custom variables like so:
Code
WX_DIR=C:\Devel\wxWidgets-2.6.1
WX_CFG=NonUnicode

WX_DIR must be set to point to the base wxWidgets directory.
WX_CFG must be the same as CFG used when building wxWidgets. If you didn't use CFG, no need to set WX_CFG for C::B.

When you next update C::B HEAD from CVS, you 're gonna have problems though with the build. That's because the project file is expecting these vars declared but because your C::B is older it doesn't know how to handle these vars :/
The solution is to set WX_DIR and WX_CFG as environment variables. After that you can build C::B and once C::B is built and launched you can delete these environment variables and set them as custom variables. You new C::B executable will be aware of these variables now.

Sorry for this slight inconvenience but this had to be done because it adds a lot of versatility in the build process.

As usual, if something's unclear or you have any comments/questions please post them here.

Yiannis.
Be patient!
This bug will be fixed soon...

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Solution for: Latest changes in HEAD break C::B build
« Reply #1 on: July 13, 2005, 12:47:15 pm »
I forgot to note that custom variables are global C::B settings. The next logical enhancement will be to set them per-project/target.

Yiannis.
Be patient!
This bug will be fixed soon...

darklordsatan

  • Guest
Solution for: Latest changes in HEAD break C::B build
« Reply #2 on: July 13, 2005, 01:00:20 pm »
Getting better every time Yiannis!
One question that remains though is: The original request that originated this, said that env vars should be set per project (and usually during the execution of the program ONLY, i.e they wont be stored in registry as when you add a new value to a given env var through windows "normal" configuration dialog in system properties). Now, what confuses me is this:

1. How is the variable search process? I guess its win32 env var, and if not found then c::b custom var, right?
2. If we take a default env var such as PATH, how can we modify its value through the custom vars dialog, to have the target app read that new value?
Right now, from what I understood, is done in a global scope basis, but you intend to do it per project, ok, but in case Im right about this, the new value will only stay as long as the c::b process is alive, right? After one closes c::b the example PATH variable will have its original value before starting c::b?

Cheers

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Solution for: Latest changes in HEAD break C::B build
« Reply #3 on: July 13, 2005, 01:06:49 pm »
Quote
1. How is the variable search process? I guess its win32 env var, and if not found then c::b custom var, right?

Custom vars are set as environment vars before building. So, no search process is involved :)

Quote
2. If we take a default env var such as PATH, how can we modify its value through the custom vars dialog, to have the target app read that new value?

Set a PATH custom var with value "some_other_path;%PATH%". I haven't tried it but I guess it 'll work.

Quote
Right now, from what I understood, is done in a global scope basis, but you intend to do it per project, ok, but in case Im right about this, the new value will only stay as long as the c::b process is alive, right? After one closes c::b the example PATH variable will have its original value before starting c::b?

Environment variables setting I mentioned, happens only in the C::B environment and all process launched from within it. When C::B shuts down, no environment variable remains in registry or elsewhere.

Yiannis.
Be patient!
This bug will be fixed soon...

darklordsatan

  • Guest
Solution for: Latest changes in HEAD break C::B build
« Reply #4 on: July 13, 2005, 01:14:14 pm »
Oh I see. Two last questions if you dont mind
1. How do you set the env vars, via win32 API (SetEnvironmentVariable()) or...?
2. This is totally offtopic here, but, what is the exact function that calls the new process?
I was thinking it would be CompilerGCC::Run(ProjectBuildTarget* target) in compilergcc.cpp but given my env vars test I told you about, seemed like not

Cheers

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Solution for: Latest changes in HEAD break C::B build
« Reply #5 on: July 13, 2005, 02:12:50 pm »
Quote
1. How do you set the env vars, via win32 API (SetEnvironmentVariable()) or...?

wxSetEnv() to be cross-platform
Quote
2. This is totally offtopic here, but, what is the exact function that calls the new process?

CompilerGCC::DoRunQueue() is actually spawning processes. CompilerGCC::Run() and the likes, just fill the commands queue that is processed by CompilerGCC::DoRunQueue().

Yiannis.
Be patient!
This bug will be fixed soon...

darklordsatan

  • Guest
Solution for: Latest changes in HEAD break C::B build
« Reply #6 on: July 13, 2005, 02:22:47 pm »
Ok, thanks! BTW, nice "666" post count

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Solution for: Latest changes in HEAD break C::B build
« Reply #7 on: July 13, 2005, 03:21:32 pm »
Hehehe, and I was replying to DarkLordSatan with my 666th post  :twisted:

Yiannis.
Be patient!
This bug will be fixed soon...

Offline David Perfors

  • Developer
  • Lives here!
  • *****
  • Posts: 560
Solution for: Latest changes in HEAD break C::B build
« Reply #8 on: July 14, 2005, 10:28:07 am »
I have troubles with this when using the unicode version of wx...
1. Instead of lib/gcc_dll/msw it is lib/gcc_dll/mswu
2. libwxmsw26.a and libwxmsw26_stc.a are also with the "u". (this coudl be changed by using WX_VER again)
OS: winXP
Compiler: mingw
IDE: Code::Blocks SVN WX: 2.8.4 Wish list: faster code completion, easier debugging, refactoring

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Solution for: Latest changes in HEAD break C::B build
« Reply #9 on: July 14, 2005, 10:37:06 am »
Quote from: mandrav
I forgot to note that custom variables are global C::B settings. The next logical enhancement will be to set them per-project/target.

Yiannis.


at least a "per project" setting is absolutely necessary before i can use this feature.
i don't want to edit everytime the globals when i have to compile one project with wx24 and the other with wx26,
another one with wx-dll and another another one with wx-static-lib ...
not already mentioned debug and release versions ...
wx has soooooo much flavours...

--tiwag

Offline David Perfors

  • Developer
  • Lives here!
  • *****
  • Posts: 560
Solution for: Latest changes in HEAD break C::B build
« Reply #10 on: July 14, 2005, 10:49:19 am »
An other thing.. when using your default paths, the compiler can't find wx/setup.h Originaly it could be find in $(WX_DIR)/lib/gcc_dll$(WX_CFG)/msw/wx/setup.h but the compiler can't find it.
WX_CFG is empty, so I think there is the problem... (I am not sure..) When I copy setup.h the the include/wx dir it works fine, but that is not an option for me, because I want to have more version of wx (one with directx support for instance)
Any suggestions?
btw, what when you don't use gcc for compiling wx? than the directory gcc_dll doesn't excist, does it?
OS: winXP
Compiler: mingw
IDE: Code::Blocks SVN WX: 2.8.4 Wish list: faster code completion, easier debugging, refactoring

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Solution for: Latest changes in HEAD break C::B build
« Reply #11 on: July 14, 2005, 11:04:20 am »
Quote
at least a "per project" setting is absolutely necessary before i can use this feature.

I 'm currently working on it. I will commit it later, when it's done.

Quote
An other thing.. when using your default paths, the compiler can't find wx/setup.h Originaly it could be find in $(WX_DIR)/lib/gcc_dll$(WX_CFG)/msw/wx/setup.h but the compiler can't find it.

Verify that $(WX_DIR)/lib/gcc_dll$(WX_CFG)/msw is in the include dirs for the project.

Quote
WX_CFG is empty, so I think there is the problem... (I am not sure..) When I copy setup.h the the include/wx dir it works fine, but that is not an option for me, because I want to have more version of wx (one with directx support for instance)
Any suggestions?

WX_CFG should not be empty only if you 've used CFG when building wxWidgets.
I use CFG=NonUnicode (for now) and so I set WX_CFG=NonUnicode. For empty CFG, WX_CFG should be empty too.
That's why I added WX_CFG: to allow for using different wx builds...

Quote
btw, what when you don't use gcc for compiling wx? than the directory gcc_dll doesn't excist, does it?

Currently, C::B only builds with gcc. When it can be built with other compilers we 'll probably add another variable, like WX_COMPILER or something, to control the "gcc" part of the paths :)

Yiannis.
Be patient!
This bug will be fixed soon...

Offline David Perfors

  • Developer
  • Lives here!
  • *****
  • Posts: 560
Solution for: Latest changes in HEAD break C::B build
« Reply #12 on: July 14, 2005, 12:09:20 pm »
I compiled wxwidgets without that CFG option, so I should left the WX_CFG empty, but that didn't work.. Now I have compiled wx with CFG and I set WX_CFG and it works like a charme. So I think there is a problem :P
OS: winXP
Compiler: mingw
IDE: Code::Blocks SVN WX: 2.8.4 Wish list: faster code completion, easier debugging, refactoring

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Solution for: Latest changes in HEAD break C::B build
« Reply #13 on: July 14, 2005, 12:12:27 pm »
Quote from: mispunt
I compiled wxwidgets without that CFG option, so I should left the WX_CFG empty, but that didn't work.. Now I have compiled wx with CFG and I set WX_CFG and it works like a charme. So I think there is a problem :P

Strange because in wx docs it states that whatever you set as CFG is just appended to the output dir (gcc_dll in this case)...

I 'll look into it. Thanks :)

Yiannis.
Be patient!
This bug will be fixed soon...

Offline David Perfors

  • Developer
  • Lives here!
  • *****
  • Posts: 560
Solution for: Latest changes in HEAD break C::B build
« Reply #14 on: July 14, 2005, 12:34:12 pm »
Yiannis, did you moved the *.a files to $(WX_DIR)/lib/gcc_dll$(WX_CFG)/msw? because by default they are in $(WX_DIR)/lib/gcc_dll$(WX_CFG)..
When linking the sdk the linker says it can't find -lwxmsw26_stc and the only dir in the linker directories is: $(WX_DIR)/lib/gcc_dll$(WX_CFG)/msw
(hope you understand :P)
OS: winXP
Compiler: mingw
IDE: Code::Blocks SVN WX: 2.8.4 Wish list: faster code completion, easier debugging, refactoring

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Solution for: Latest changes in HEAD break C::B build
« Reply #15 on: July 14, 2005, 12:40:52 pm »
Quote from: mispunt
Yiannis, did you moved the *.a files to $(WX_DIR)/lib/gcc_dll$(WX_CFG)/msw? because by default they are in $(WX_DIR)/lib/gcc_dll$(WX_CFG)..
When linking the sdk the linker says it can't find -lwxmsw26_stc and the only dir in the linker directories is: $(WX_DIR)/lib/gcc_dll$(WX_CFG)/msw
(hope you understand :P)

No, I didn't move the files. Have I made such a mistake? I 'll check it in a while.
On the WX_CFG issue: you did set it to be empty, didn't you?

Yiannis.
Be patient!
This bug will be fixed soon...

Offline David Perfors

  • Developer
  • Lives here!
  • *****
  • Posts: 560
Solution for: Latest changes in HEAD break C::B build
« Reply #16 on: July 14, 2005, 12:46:13 pm »
That wasn't possible, when you set a var empty, it is gone...
OS: winXP
Compiler: mingw
IDE: Code::Blocks SVN WX: 2.8.4 Wish list: faster code completion, easier debugging, refactoring

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Solution for: Latest changes in HEAD break C::B build
« Reply #17 on: July 14, 2005, 01:47:55 pm »
Quote from: mispunt
That wasn't possible, when you set a var empty, it is gone...

You 're right. That's why it was not working...

Yiannis.
Be patient!
This bug will be fixed soon...

Offline David Perfors

  • Developer
  • Lives here!
  • *****
  • Posts: 560
Solution for: Latest changes in HEAD break C::B build
« Reply #18 on: July 14, 2005, 02:41:20 pm »
It is working now, thanks
OS: winXP
Compiler: mingw
IDE: Code::Blocks SVN WX: 2.8.4 Wish list: faster code completion, easier debugging, refactoring