Home > OS >  Assign ON to a variable
Assign ON to a variable

Time:10-13

If I assign Boost_USE_STATIC_LIBS variable and then print it in Windows Command Prompt as follows:

set Boost_USE_STATIC_LIBS=ON
echo %Boost_USE_STATIC_LIBS%

an empty line is displayed.

And I get an error in some script that requires the variable to be exactly "ON":

* libboost_system-vc143-mt-s-x64-1_80.lib (static runtime,
Boost_USE_STATIC_RUNTIME not ON)

How to fix this?

CodePudding user response:

It is set correctly, but "echo ON" is a shell command to turn echo mode on or off and has no output. Try any of the following:

set Boost_USE_STATIC_LIBS=ON

set Boost_USE_STATIC_LIBS
echo "%Boost_USE_STATIC_LIBS%"
echo it is %Boost_USE_STATIC_LIBS%
if %Boost_USE_STATIC_LIBS%==ON echo yes

Output:

yes
it is ON
Boost_USE_STATIC_LIBS=ON
  • Related