EVC的编译错误,主要是error LNK2019,高手请进,轻松拿分

y.yan   2008-2-29 11:36 楼主
ps2keybd.obj : error LNK2019: unresolved external symbol "int __cdecl KernelIoControl(unsigned long,void *,unsigned long,void *,unsigned long,unsigned long *)" (?KernelIoControl@@YAHKPAXK0KPAK@Z) referenced in function "public: int __cdecl Ps2Keybd:
:IsrThreadProc(void)" (?IsrThreadProc@Ps2Keybd@@QAAHXZ)
ps2keybd.obj : error LNK2019: unresolved external symbol "int __cdecl InterruptInitialize(unsigned long,void *,void *,unsigned long)" (?InterruptInitialize@@YAHKPAX0K@Z) referenced in function "public: int __cdecl Ps2Keybd::IsrThreadProc(void)" (?Is
rThreadProc@Ps2Keybd@@QAAHXZ)
ps2port.obj : error LNK2019: unresolved external symbol READ_PORT_UCHAR referenced in function "private: bool __cdecl Ps2Port::InputBufPollForEmpty(void)" (?InputBufPollForEmpty@Ps2Port@@AAA_NXZ)
ps2port.obj : error LNK2019: unresolved external symbol WRITE_PORT_UCHAR referenced in function "private: bool __cdecl Ps2Port::EnterWrite(void)" (?EnterWrite@Ps2Port@@AAA_NXZ)
MIPSIIRel/PosArmJz.exe : fatal error LNK1120: 4 unresolved externals

高手们,这些未解决的外部变量我都有定义了啊,怎么还会不认呢?怎么解决啊?

回复评论 (6)

不要乱引用你的头文件啊,主意包含和被包含关系,自己理理啊,问题不大
点赞  2008-2-29 13:14
首先强调一点,这些不是compile error,
而是 link error.

是你缺少包含相应的lib文件
点赞  2008-2-29 13:27
#include "stdafx.h"加在.cpp文件的开始.
点赞  2008-2-29 13:36
too strange.
Can type chinese?
Add follow codes to your *.cpp.
then the first lnk can be cleared.
the last two lnk i can't test, you need to try yourself.


extern "C" __declspec(dllimport)
BOOL KernelIoControl(
                                         DWORD dwIoControlCode,
                                         LPVOID lpInBuf,
                                         DWORD nInBufSize,
                                         LPVOID lpOutBuf,
                                         DWORD nOutBufSize,
                                         LPDWORD lpBytesReturned);

extern "C" __declspec(dllimport)
BOOL InterruptInitialize(
  DWORD idInt,
  HANDLE hEvent,
  LPVOID pvData,
  DWORD cbData
);

点赞  2008-2-29 13:41
楼主在写驱动还是应用程序?
如果是驱动,你要把Coredll.lib Link进来,因为KernelIoControl和InterruptInitialize都在这个Lib中。
还有CEDDK.lib也要,READ_PORT_UCHAR和WRITE_PORT_UCHAR在这个Lib中。


如果应用程序,也可以像上面那样做。
但建议还是LoadLibray和GetProcAddress来加载。
KernelIoControl和InterruptInitialize在CoreDll.dll里,另两个不知道在哪个DLL里,你自己找找看。

点赞  2008-3-1 16:54
把链接库的路径加上试试看
点赞  2008-3-3 08:34
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复