Hi,
I'm using VS 2008 and compile my application with Multi-threaded Debug (/MTd). At link time I receive the following error:
error LNK2001: unresolved external symbol __environ
Where the symbol is defined?
Thanks Dima
Hi,
I'm using VS 2008 and compile my application with Multi-threaded Debug (/MTd). At link time I receive the following error:
error LNK2001: unresolved external symbol __environ
Where the symbol is defined?
Thanks Dima
When you are using /Md (or variants), the symbols _environ
and _wenviron
are replaced by function calls. You need to track down the code that uses these (obsolete and deprecated) symbols, and make them use the proper function names. I found lots of people with the same problem as you in google also.
I found some more detail here:
Polling _environ in a Unicode context is meaningless when /MD or /MDd linkage is used. For the CRT DLL, the type (wide or multibyte) of the program is unknown. Only the multibyte type is created because that is the most likely scenario.
If you change the use of the symbol _environ
to the wide character version _wenviron
, your original code will probably work.
As the documentation describes, _environ is declared in Stdlib.h and implemented in the crt lib.
Therefore you might have a problem with linking with this library, or maybe it's picking up the wrong lib (try checking your build paths).