How to work around “scons: warning: Two different environments were specified for target” [[BUT do not change file ]]

StackOverflow https://stackoverflow.com/questions/17990883

  •  04-06-2022
  •  | 
  •  

Question

I want to build one program using scons under windows 7 64 bits. I also have Microsoft Visual Studio c++ and mingw.

However, when I build the program (which include several files and sub directory) with scons, I see this error

two different environments were specified in target  C:\....... .obj but they appear to have the same action ${TEMPFILE($SHCC _MSVC _OUTPUT _FLAG /c $CHANGED $SHCFLAGS $SHCCFLAGS $_CCCOMCOM

Note: ..... is the path of the file which I want to install.

When I search in stackoverflow, I saw this problem mentioned and there were solutions for that but my problem is it that I should not change program's code because I'm sure the code is true.

If you give me any idea, I will truly appreciate your help

Was it helpful?

Solution

Firstly, this is not an error. It is a warning. Therefore it wont stop your build. If your build is failing, it is because of something else.

What this warning means is that there are two or more libraries or programs in your build that require the same .o file. This isn't currently a problem but if you (say) change the compile switches for one instance, it'll mean you have 2 incompatible sets of requirements for the same object, and that will result in a build error.

OTHER TIPS

As mentioned in a previous comment, the problem is that there's a target (=an object file) that is compiled in two ways. My suggestion is to use the VariantDir build for the two builds. This allows a different output for the two environments.

For example.

build_flavors = ['mingw', 'VS']:
for flavor in build_flavors:
    env = Environment()
    VariantDir(os.path.join('build', flavor))
    # build using the environment

If You are using SConscripts, you can pass a variant_dir='some/variant/dir to the call.

There is a scons flag to silence this warning:

scons --warn=no-duplicate-environment
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top