error LNK2001: 无法解析的外部符号 __wenviron

ZLJ52008 2014-06-30 09:22:50
先说下背景:楼主的程序是从别人那里来的(vc6.0),拿来的时候有错误,但是无法定位错误的位置。后来用VS2008进行编译寻找错误。改了好几周了,总算快结束了。不成想居然卡在这动不了了。搜遍网络,没找到啥好招,求大神。

...全文
280 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
caewow 2014-07-02
  • 打赏
  • 举报
回复
引用 3 楼 lsq19871207 的回复:
error LNK2001: 无法解析的外部符号 __wenviron 这类问题就是链接错误,找不到函数的实现体 检测是否用到了lib或者dll,或者__wenviron函数只有声明没有定义
+1
信阳毛尖 2014-07-02
  • 打赏
  • 举报
回复
error LNK2001: 无法解析的外部符号 __wenviron 这类问题就是链接错误,找不到函数的实现体 检测是否用到了lib或者dll,或者__wenviron函数只有声明没有定义
oldmtn 2014-07-02
  • 打赏
  • 举报
回复
#pragme comment(lib, "***.lib") 这里需要添加一个lib,该lib具有__wenviron的导出符号。
wuzhentian 2014-07-02
  • 打赏
  • 举报
回复
缺少lib或dll文件
Eleven 2014-07-02
  • 打赏
  • 举报
回复
GetEnvironmentStrings()???
BombZhang 2014-07-02
  • 打赏
  • 举报
回复
引用一下LIBCMTD.lib试试
ouyh12345 2014-07-01
  • 打赏
  • 举报
回复
全文查找wenviron,看是否只有声明而没有定义 cpp文件或lib是否已经包含了
ZLJ52008 2014-06-30
  • 打赏
  • 举报
回复
------------附上寻找到的一段---------------------------------- Visual Studio C++ error: unresolved symbol __environ 、、-------------------------------------------------------------- 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. 地址:http://stackoverflow.com/questions/1170427/visual-studio-c-unresolved-symbol-environ //------------------------------------------------------------------------_environ, _wenviron ------------------------------------------------------- Visual Studio 2005 Other Versions 0 out of 1 rated this helpful - Rate this topic The _environ variable is a pointer to an array of pointers to the multibyte-character strings that constitute the process environment. This global variable has been deprecated in Visual C++ 2005 for the more secure functional versions getenv_s, _wgetenv_s and _putenv_s, _wputenv_s, which should be used in place of the global variable. _environ is declared in Stdlib.h. extern char **_environ; Remarks In a program that uses the main function, _environ is initialized at program startup according to settings taken from the operating-system environment. The environment consists of one or more entries of the form ENVVARNAME =string getenv_s and putenv_s use the _environ variable to access and modify the environment table. When _putenv is called to add or delete environment settings, the environment table changes size. Its location in memory may also change, depending on the program's memory requirements. The value of _environ is automatically adjusted accordingly. The _wenviron variable, declared in Stdlib.h as: extern wchar_t **_wenviron; is a wide-character version of _environ. In a program that uses the wmain function, _wenviron is initialized at program startup according to settings taken from the operating-system environment. In a program that uses main, _wenviron is initially NULL because the environment is composed of multibyte-character strings. On the first call to _wgetenv or _wputenv, a corresponding wide-character string environment is created and is pointed to by _wenviron. Similarly, in a program that uses wmain, _environ is initially NULL because the environment is composed of wide-character strings. On the first call to _getenv or _putenv, a corresponding multibyte-character string environment is created and is pointed to by _environ. When two copies of the environment (MBCS and Unicode) exist simultaneously in a program, the run-time system must maintain both copies, resulting in slower execution time. For example, whenever you call _putenv, a call to _wputenv is also executed automatically, so that the two environment strings correspond. Caution noteCaution In rare instances, when the run-time system is maintaining both a Unicode version and a multibyte version of the environment, these two environment versions might not correspond exactly. This is because, although any unique multibyte-character string maps to a unique Unicode string, the mapping from a unique Unicode string to a multibyte-character string is not necessarily unique. Therefore, two distinct Unicode strings might map to the same multibyte string. 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. The following pseudo-code illustrates how this can happen. int i, j; i = _wputenv( "env_var_x=string1" ); // results in the implicit call: // putenv ("env_var_z=string1") j = _wputenv( "env_var_y=string2" ); // also results in implicit call: // putenv("env_var_z=string2") In the notation used for this example, the character strings are not C string literals; rather, they are placeholders that represent Unicode environment string literals in the _wputenv call and multibyte environment strings in the putenv call. The character placeholders 'x' and 'y' in the two distinct Unicode environment strings do not map uniquely to characters in the current MBCS. Instead, both map to some MBCS character 'z' that is the default result of the attempt to convert the strings. Thus, in the multibyte environment, the value of "env_var_z" after the first implicit call to putenv would be "string1", but this value would be overwritten on the second implicit call to putenv, when the value of "env_var_z" is set to "string2". The Unicode environment (in _wenviron) and the multibyte environment (in _environ) would therefore differ following this series of calls. 地址:http://msdn.microsoft.com/en-us/library/stxk41x1%28VS.80%29.aspx

15,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧