开发者

resolve link errors for __imp__open and other similarly named functions using Microsoft Visual C++ 6.0

Link errors like this sometimes occur when compiling C++ using Microsoft Visual C++ 6.0:

error LNK2001: unresolved external symbol __imp__close

error LNK2001: unresolved external symbol __imp__read

error LNK2001: unresolved external symbol _开发者_开发问答_imp__lseek

error LNK2001: unresolved external symbol __imp__open

My fix, which I found after searching fruitlessly using Google for a long time, is this:

Do NOT disable language extensions. In the Project Settings dialog, in the C/C++ tab, make sure that the 'Disable language extensions' checkbox is not checked.

The functions close, read, lseek, open, etc., are not standard parts of the C library and the declarations are skipped by conditional compilation using #if !__STDC__ in <io.h>. This happens if you disable language extensions.


The answer is that the __imp prefix refers to function stubs in the OBJ library for the DLL version of the CRT. This means your linker options are incompatible with your compiler options (linker set to static CRT or no CRT and compiler set to dynamic CRT).

In your case rather than the CRT itself it is another library, but the same idea.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜