User forums > Using Code::Blocks
How to define a Variable value frome shell cmd
(1/1)
			ccdric:
			
			Hi Everybody,
I intend to define a variable in CB project from shell cmd return value.
example : 
--- Quote ---PYBIND_INCLUDE=$(python -m pybind11 --includes)
--- End quote ---
of course $(something) use something as a variable label in C::B project, unlike executed in the shell environment.
Does anyone have any ideas?
have a nice day
		
			stahta01:
			
			The tilted tic does that in places in CB   [`]  the tic between the square brackets.
Edit you need one at both the start and end of the command.
Edit2: I have never used it to define a variable; so, not sure where all it works.
I have used it in both compiler and linker extra setting.
Tim S.
		
			ccdric:
			
			Thanks stahta01 : 
it works halfway  :D
in CodeBlocks_project_file/Project/Build/Environment
add 2 variables : 
--- Code:  ---    <Variable name="PYBIND_INCLUDES" value="`python -m pybind11 --includes`" />
    <Variable name="PYBIND_EXTENTION" value="`python -m pybind11 --extension-suffix`" />
--- End code ---
in CodeBlocks_project_file/Project/Build/Target/Compiler 
add this :
--- Code:  ---<Add option="$(PYBIND_INCLUDES)" />
--- End code ---
(this is the half part that works fine  :) )
But here it doesn't works :( : 
in CodeBlocks_project_file/Project/Build/Target/Option/@output
--- Code:  --- <Option output="bin/Debug/trie$(PYBIND_EXTENTION)" ... >
--- End code ---
the var is literally copied in the link cmd : 
--- Code:  ---g++-13 -shared obj/Debug/src/mod1.o obj/Debug/src/mod2.o  -o "bin/Debug/libmylib`python -m pybind11 --extension-suffix`.so" -m64 
--- End code ---
Perhaps there is a better way for that second part ?
(I try ton compile c++ lib for use it in python. It's new for me. I 'll hive probably other question how to parameterize C::B to fit in python env)
		
			stahta01:
			
			You might try a post build step to rename the file or copy it.
Tim S.
		
Navigation
[0] Message Index
Go to full version