User forums > Using Code::Blocks
Passing command line options to compiler
Jenna:
If you start C::B from a console with the -d parameter:
--- Code: ---codeblocks -d
--- End code ---
you should have an additional tab in "Logs & others" called "Code::Blocks Debug".
After opening your project you can onspect it and see, whether there is an entry like:
--- Code: ---Caching result of `root-config --cflags --libs`
Cached
--- End code ---
You can also try to run the command from the pre- or pos-build steps of the program (without the backticks), to see the output of it, if it is run in the context of C::B.
If it has an error, C::B will cache nothing and expand the backticked command to ... nothing.
JasperC:
Thanks again. I think I know where I've gone wrong now... :oops: Though I might still need help to fix it.
--- Quote from: jens on October 20, 2011, 09:55:16 am ---If you start C::B from a console with the -d parameter:
--- Code: ---codeblocks -d
--- End code ---
you should have an additional tab in "Logs & others" called "Code::Blocks Debug".
After opening your project you can onspect it and see, whether there is an entry like:
--- Code: ---Caching result of `root-config --cflags --libs`
Cached
--- End code ---
You can also try to run the command from the pre- or pos-build steps of the program (without the backticks), to see the output of it, if it is run in the context of C::B.
If it has an error, C::B will cache nothing and expand the backticked command to ... nothing.
--- End quote ---
So I did that and the build process worked fine... Then I started a new Terminal window and tried again - this time it didn't work. Then I remembered that for my first Terminal window, the one where I normally work from, I manually run a script to set up the environment:
--- Code: ---. /home/jasper/gate/root_5.28.00e/bin/thisroot.sh
--- End code ---
I would have thought that that sets the variables for everything else, but it appears to only affect the current Terminal window (and apparently applications launched from it). And normally I start C::B from the launcher...
This line appears under the "Code::Blocks Debug" tab in both cases:
--- Code: ---Caching result of `root-config --cflags --libs`
Cached
--- End code ---
but with nothing else that I can see that indicates success or failure. (Am I looking in the wrong place?)
When successful, `root-config --cflags --libs` expands normally.
New question then, is it possible to get C::B to run the script before calling g++? I'm making the assumption that C::B is internally creating it's own "session" to do the compile and link. I've tried adding the above script command to
Project -> Build options... -> [Project name] -> [GNU GCC Compiler] -> Pre/post build steps -> Pre-build steps
but the build fails, and the build log shows:
--- Code: ---Running project pre-build steps
. /home/jasper/gate/root_5.28.00e/bin/thisroot.sh
/home/jasper/gate/root_5.28.00e/bin/thisroot.sh: 25: Bad substitution
Process terminated with status 2 (0 minutes, 0 seconds)
0 errors, 0 warnings
--- End code ---
Removing the leading ". " I get:
--- Code: ---Running project pre-build steps
/home/jasper/gate/root_5.28.00e/bin/thisroot.sh
/bin/sh: /home/jasper/gate/root_5.28.00e/bin/thisroot.sh: Permission denied
Process terminated with status 126 (0 minutes, 0 seconds)
0 errors, 0 warnings
--- End code ---
Jenna:
If you only need to run root-config, you can run it with full absolute pathname:
--- Code: ---`/path/to/root-config --cflags`
--- End code ---
in the "Compiler options -> Other options" and
--- Code: ---`/path/to/root-config --libs`
--- End code ---
in the "Linker settings -> Other linker options".
It might be useful to put it in the global compiler settings, if you have created a special compiler for root.
About the issue running the shell-script:
I don't know why it fails, looks like missing execution rights for the user who runs C::B, or a script-error.
But this leaves the scope of our forum, sorry.
JasperC:
Hi Jens, not a problem. Thanks for all you help. :D (And the solution you suggested does seem to work.)
Navigation
[0] Message Index
[*] Previous page
Go to full version