帮忙解决, 谢谢!!
--------------------Configuration: WinIoTest - Win32 Debug--------------------
Linking...
WinIoTest.obj : error LNK2001: unresolved external symbol __imp__ShutdownWinIo@0
WinIoTest.obj : error LNK2001: unresolved external symbol __imp__SetPhysLong@8
WinIoTest.obj : error LNK2001: unresolved external symbol __imp__GetPhysLong@8
WinIoTest.obj : error LNK2001: unresolved external symbol __imp__UnmapPhysicalMemory@8
WinIoTest.obj : error LNK2001: unresolved external symbol __imp__MapPhysToLin@12
WinIoTest.obj : error LNK2001: unresolved external symbol __imp__SetPortVal@12
WinIoTest.obj : error LNK2001: unresolved external symbol __imp__GetPortVal@12
WinIoTest.obj : error LNK2001: unresolved external symbol __imp__InitializeWinIo@0
Debug/WinIoTest.exe : fatal error LNK1120: 8 unresolved externals
Error executing link.exe.
WinIoTest.exe - 9 error(s), 0 warning(s)
7 个解决方案
#1
把相关函数的原型贴出来看一下,怀疑是调用约定不对。
#2
//WinIo.h 头文件
#ifndef WINIO_H
#define WINIO_H
#ifdef WINIO_DLL
#define WINIO_API _declspec(dllexport)
#else
#define WINIO_API _declspec(dllimport)
#endif
extern "C"
{
WINIO_API bool _stdcall InitializeWinIo();
WINIO_API void _stdcall ShutdownWinIo();
WINIO_API PBYTE _stdcall MapPhysToLin(PBYTE pbPhysAddr, DWORD dwPhysSize, HANDLE *pPhysicalMemoryHandle);
WINIO_API bool _stdcall UnmapPhysicalMemory(HANDLE PhysicalMemoryHandle, PBYTE pbLinAddr);
WINIO_API bool _stdcall GetPhysLong(PBYTE pbPhysAddr, PDWORD pdwPhysVal);
WINIO_API bool _stdcall SetPhysLong(PBYTE pbPhysAddr, DWORD dwPhysVal);
WINIO_API bool _stdcall GetPortVal(WORD wPortAddr, PDWORD pdwPortVal, BYTE bSize);
WINIO_API bool _stdcall SetPortVal(WORD wPortAddr, DWORD dwPortVal, BYTE bSize);
WINIO_API bool _stdcall InstallWinIoDriver(PSTR pszWinIoDriverPath, bool IsDemandLoaded = false);
WINIO_API bool _stdcall RemoveWinIoDriver();
}
extern bool IsNT;
extern HANDLE hDriver;
extern bool IsWinIoInitialized;
bool _stdcall StartWinIoDriver();
bool _stdcall StopWinIoDriver();
#endif
//WinIoTest.cpp 文件
#include <windows.h>
#include <stdio.h>
#include "winio.h"
int main()
{
DWORD dwPortVal;
DWORD dwMemVal;
bool bResult;
HANDLE hPhysicalMemory;
PBYTE pbLinAddr;
// Call InitializeWinIo to initialize the WinIo library.
bResult = InitializeWinIo();
if (bResult)
{
// Under Windows NT/2000/XP, after calling InitializeWinIo,
// you can call _inp/_outp instead of using GetPortVal/SetPortVal
GetPortVal(0x378, &dwPortVal, 4);
SetPortVal(0x378, 10, 4);
// Map physical addresses 0xA0000 - 0xAFFFF into the linear address space
// of the application. The value returned from the call to MapPhysToLin is
// a linear address corresponding to physical address 0xA0000. In case of
// an error, the return value is NULL.
pbLinAddr = MapPhysToLin((PBYTE)0xA0000, 65536, &hPhysicalMemory);
if (pbLinAddr)
{
// Now we can use pbLinAddr to access physical address 0xA0000
*pbLinAddr = 10;
// When you're done with pbLinAddr, call UnmapPhysicalMemory
UnmapPhysicalMemory(hPhysicalMemory, pbLinAddr);
}
// Instead of using MapPhysToLin, we can use GetPhysLong/SetPhysLong
GetPhysLong((PBYTE)0xA0000, &dwMemVal);
SetPhysLong((PBYTE)0xA0000, 10);
// When you're done using WinIo, call ShutdownWinIo
ShutdownWinIo();
}
else
{
printf("Error during initialization of WinIo.\n");
exit(1);
}
return 0;
}
#ifndef WINIO_H
#define WINIO_H
#ifdef WINIO_DLL
#define WINIO_API _declspec(dllexport)
#else
#define WINIO_API _declspec(dllimport)
#endif
extern "C"
{
WINIO_API bool _stdcall InitializeWinIo();
WINIO_API void _stdcall ShutdownWinIo();
WINIO_API PBYTE _stdcall MapPhysToLin(PBYTE pbPhysAddr, DWORD dwPhysSize, HANDLE *pPhysicalMemoryHandle);
WINIO_API bool _stdcall UnmapPhysicalMemory(HANDLE PhysicalMemoryHandle, PBYTE pbLinAddr);
WINIO_API bool _stdcall GetPhysLong(PBYTE pbPhysAddr, PDWORD pdwPhysVal);
WINIO_API bool _stdcall SetPhysLong(PBYTE pbPhysAddr, DWORD dwPhysVal);
WINIO_API bool _stdcall GetPortVal(WORD wPortAddr, PDWORD pdwPortVal, BYTE bSize);
WINIO_API bool _stdcall SetPortVal(WORD wPortAddr, DWORD dwPortVal, BYTE bSize);
WINIO_API bool _stdcall InstallWinIoDriver(PSTR pszWinIoDriverPath, bool IsDemandLoaded = false);
WINIO_API bool _stdcall RemoveWinIoDriver();
}
extern bool IsNT;
extern HANDLE hDriver;
extern bool IsWinIoInitialized;
bool _stdcall StartWinIoDriver();
bool _stdcall StopWinIoDriver();
#endif
//WinIoTest.cpp 文件
#include <windows.h>
#include <stdio.h>
#include "winio.h"
int main()
{
DWORD dwPortVal;
DWORD dwMemVal;
bool bResult;
HANDLE hPhysicalMemory;
PBYTE pbLinAddr;
// Call InitializeWinIo to initialize the WinIo library.
bResult = InitializeWinIo();
if (bResult)
{
// Under Windows NT/2000/XP, after calling InitializeWinIo,
// you can call _inp/_outp instead of using GetPortVal/SetPortVal
GetPortVal(0x378, &dwPortVal, 4);
SetPortVal(0x378, 10, 4);
// Map physical addresses 0xA0000 - 0xAFFFF into the linear address space
// of the application. The value returned from the call to MapPhysToLin is
// a linear address corresponding to physical address 0xA0000. In case of
// an error, the return value is NULL.
pbLinAddr = MapPhysToLin((PBYTE)0xA0000, 65536, &hPhysicalMemory);
if (pbLinAddr)
{
// Now we can use pbLinAddr to access physical address 0xA0000
*pbLinAddr = 10;
// When you're done with pbLinAddr, call UnmapPhysicalMemory
UnmapPhysicalMemory(hPhysicalMemory, pbLinAddr);
}
// Instead of using MapPhysToLin, we can use GetPhysLong/SetPhysLong
GetPhysLong((PBYTE)0xA0000, &dwMemVal);
SetPhysLong((PBYTE)0xA0000, 10);
// When you're done using WinIo, call ShutdownWinIo
ShutdownWinIo();
}
else
{
printf("Error during initialization of WinIo.\n");
exit(1);
}
return 0;
}
#3
当我插入#pragma comment(lib,"WinIo.lib"),后依然无法通过编译:无法识别外部符号。
不知道还要导入那个LIB 文件。 请各位帮忙!!
--------------------Configuration: WinIoTest - Win32 Debug--------------------
Linking...
LINK : warning LNK4224: /PDBTYPE is no longer supported; ignored
WinIoTest.obj : error LNK2019: unresolved external symbol @_RTC_CheckStackVars@8 referenced in function "void __cdecl KBCWait4IBE(void)" (?KBCWait4IBE@@YAXXZ)
WinIoTest.obj : error LNK2019: unresolved external symbol __RTC_CheckEsp referenced in function "void __cdecl KBCWait4IBE(void)" (?KBCWait4IBE@@YAXXZ)
WinIoTest.obj : error LNK2001: unresolved external symbol __RTC_Shutdown
WinIoTest.obj : error LNK2001: unresolved external symbol __RTC_InitBase
Debug/WinIoTest.exe : fatal error LNK1120: 4 unresolved externals
Error executing link.exe.
WinIoTest.exe - 5 error(s), 1 warning(s)
不知道还要导入那个LIB 文件。 请各位帮忙!!
--------------------Configuration: WinIoTest - Win32 Debug--------------------
Linking...
LINK : warning LNK4224: /PDBTYPE is no longer supported; ignored
WinIoTest.obj : error LNK2019: unresolved external symbol @_RTC_CheckStackVars@8 referenced in function "void __cdecl KBCWait4IBE(void)" (?KBCWait4IBE@@YAXXZ)
WinIoTest.obj : error LNK2019: unresolved external symbol __RTC_CheckEsp referenced in function "void __cdecl KBCWait4IBE(void)" (?KBCWait4IBE@@YAXXZ)
WinIoTest.obj : error LNK2001: unresolved external symbol __RTC_Shutdown
WinIoTest.obj : error LNK2001: unresolved external symbol __RTC_InitBase
Debug/WinIoTest.exe : fatal error LNK1120: 4 unresolved externals
Error executing link.exe.
WinIoTest.exe - 5 error(s), 1 warning(s)
#4
#ifdef WINIO_DLL
#define WINIO_API _declspec(dllexport)
#else
#define WINIO_API _declspec(dllimport)
#endif
#define WINIO_API _declspec(dllexport)
#else
#define WINIO_API _declspec(dllimport)
#endif
#5
这一句WinIo.h 头文件里已经有了..
#6
"__RTC_xxxx"运行时库,改改连接库试试
#7
感谢各位了, 最后我还是改用Win32 动态装入来完成, 结果也可以。
#1
把相关函数的原型贴出来看一下,怀疑是调用约定不对。
#2
//WinIo.h 头文件
#ifndef WINIO_H
#define WINIO_H
#ifdef WINIO_DLL
#define WINIO_API _declspec(dllexport)
#else
#define WINIO_API _declspec(dllimport)
#endif
extern "C"
{
WINIO_API bool _stdcall InitializeWinIo();
WINIO_API void _stdcall ShutdownWinIo();
WINIO_API PBYTE _stdcall MapPhysToLin(PBYTE pbPhysAddr, DWORD dwPhysSize, HANDLE *pPhysicalMemoryHandle);
WINIO_API bool _stdcall UnmapPhysicalMemory(HANDLE PhysicalMemoryHandle, PBYTE pbLinAddr);
WINIO_API bool _stdcall GetPhysLong(PBYTE pbPhysAddr, PDWORD pdwPhysVal);
WINIO_API bool _stdcall SetPhysLong(PBYTE pbPhysAddr, DWORD dwPhysVal);
WINIO_API bool _stdcall GetPortVal(WORD wPortAddr, PDWORD pdwPortVal, BYTE bSize);
WINIO_API bool _stdcall SetPortVal(WORD wPortAddr, DWORD dwPortVal, BYTE bSize);
WINIO_API bool _stdcall InstallWinIoDriver(PSTR pszWinIoDriverPath, bool IsDemandLoaded = false);
WINIO_API bool _stdcall RemoveWinIoDriver();
}
extern bool IsNT;
extern HANDLE hDriver;
extern bool IsWinIoInitialized;
bool _stdcall StartWinIoDriver();
bool _stdcall StopWinIoDriver();
#endif
//WinIoTest.cpp 文件
#include <windows.h>
#include <stdio.h>
#include "winio.h"
int main()
{
DWORD dwPortVal;
DWORD dwMemVal;
bool bResult;
HANDLE hPhysicalMemory;
PBYTE pbLinAddr;
// Call InitializeWinIo to initialize the WinIo library.
bResult = InitializeWinIo();
if (bResult)
{
// Under Windows NT/2000/XP, after calling InitializeWinIo,
// you can call _inp/_outp instead of using GetPortVal/SetPortVal
GetPortVal(0x378, &dwPortVal, 4);
SetPortVal(0x378, 10, 4);
// Map physical addresses 0xA0000 - 0xAFFFF into the linear address space
// of the application. The value returned from the call to MapPhysToLin is
// a linear address corresponding to physical address 0xA0000. In case of
// an error, the return value is NULL.
pbLinAddr = MapPhysToLin((PBYTE)0xA0000, 65536, &hPhysicalMemory);
if (pbLinAddr)
{
// Now we can use pbLinAddr to access physical address 0xA0000
*pbLinAddr = 10;
// When you're done with pbLinAddr, call UnmapPhysicalMemory
UnmapPhysicalMemory(hPhysicalMemory, pbLinAddr);
}
// Instead of using MapPhysToLin, we can use GetPhysLong/SetPhysLong
GetPhysLong((PBYTE)0xA0000, &dwMemVal);
SetPhysLong((PBYTE)0xA0000, 10);
// When you're done using WinIo, call ShutdownWinIo
ShutdownWinIo();
}
else
{
printf("Error during initialization of WinIo.\n");
exit(1);
}
return 0;
}
#ifndef WINIO_H
#define WINIO_H
#ifdef WINIO_DLL
#define WINIO_API _declspec(dllexport)
#else
#define WINIO_API _declspec(dllimport)
#endif
extern "C"
{
WINIO_API bool _stdcall InitializeWinIo();
WINIO_API void _stdcall ShutdownWinIo();
WINIO_API PBYTE _stdcall MapPhysToLin(PBYTE pbPhysAddr, DWORD dwPhysSize, HANDLE *pPhysicalMemoryHandle);
WINIO_API bool _stdcall UnmapPhysicalMemory(HANDLE PhysicalMemoryHandle, PBYTE pbLinAddr);
WINIO_API bool _stdcall GetPhysLong(PBYTE pbPhysAddr, PDWORD pdwPhysVal);
WINIO_API bool _stdcall SetPhysLong(PBYTE pbPhysAddr, DWORD dwPhysVal);
WINIO_API bool _stdcall GetPortVal(WORD wPortAddr, PDWORD pdwPortVal, BYTE bSize);
WINIO_API bool _stdcall SetPortVal(WORD wPortAddr, DWORD dwPortVal, BYTE bSize);
WINIO_API bool _stdcall InstallWinIoDriver(PSTR pszWinIoDriverPath, bool IsDemandLoaded = false);
WINIO_API bool _stdcall RemoveWinIoDriver();
}
extern bool IsNT;
extern HANDLE hDriver;
extern bool IsWinIoInitialized;
bool _stdcall StartWinIoDriver();
bool _stdcall StopWinIoDriver();
#endif
//WinIoTest.cpp 文件
#include <windows.h>
#include <stdio.h>
#include "winio.h"
int main()
{
DWORD dwPortVal;
DWORD dwMemVal;
bool bResult;
HANDLE hPhysicalMemory;
PBYTE pbLinAddr;
// Call InitializeWinIo to initialize the WinIo library.
bResult = InitializeWinIo();
if (bResult)
{
// Under Windows NT/2000/XP, after calling InitializeWinIo,
// you can call _inp/_outp instead of using GetPortVal/SetPortVal
GetPortVal(0x378, &dwPortVal, 4);
SetPortVal(0x378, 10, 4);
// Map physical addresses 0xA0000 - 0xAFFFF into the linear address space
// of the application. The value returned from the call to MapPhysToLin is
// a linear address corresponding to physical address 0xA0000. In case of
// an error, the return value is NULL.
pbLinAddr = MapPhysToLin((PBYTE)0xA0000, 65536, &hPhysicalMemory);
if (pbLinAddr)
{
// Now we can use pbLinAddr to access physical address 0xA0000
*pbLinAddr = 10;
// When you're done with pbLinAddr, call UnmapPhysicalMemory
UnmapPhysicalMemory(hPhysicalMemory, pbLinAddr);
}
// Instead of using MapPhysToLin, we can use GetPhysLong/SetPhysLong
GetPhysLong((PBYTE)0xA0000, &dwMemVal);
SetPhysLong((PBYTE)0xA0000, 10);
// When you're done using WinIo, call ShutdownWinIo
ShutdownWinIo();
}
else
{
printf("Error during initialization of WinIo.\n");
exit(1);
}
return 0;
}
#3
当我插入#pragma comment(lib,"WinIo.lib"),后依然无法通过编译:无法识别外部符号。
不知道还要导入那个LIB 文件。 请各位帮忙!!
--------------------Configuration: WinIoTest - Win32 Debug--------------------
Linking...
LINK : warning LNK4224: /PDBTYPE is no longer supported; ignored
WinIoTest.obj : error LNK2019: unresolved external symbol @_RTC_CheckStackVars@8 referenced in function "void __cdecl KBCWait4IBE(void)" (?KBCWait4IBE@@YAXXZ)
WinIoTest.obj : error LNK2019: unresolved external symbol __RTC_CheckEsp referenced in function "void __cdecl KBCWait4IBE(void)" (?KBCWait4IBE@@YAXXZ)
WinIoTest.obj : error LNK2001: unresolved external symbol __RTC_Shutdown
WinIoTest.obj : error LNK2001: unresolved external symbol __RTC_InitBase
Debug/WinIoTest.exe : fatal error LNK1120: 4 unresolved externals
Error executing link.exe.
WinIoTest.exe - 5 error(s), 1 warning(s)
不知道还要导入那个LIB 文件。 请各位帮忙!!
--------------------Configuration: WinIoTest - Win32 Debug--------------------
Linking...
LINK : warning LNK4224: /PDBTYPE is no longer supported; ignored
WinIoTest.obj : error LNK2019: unresolved external symbol @_RTC_CheckStackVars@8 referenced in function "void __cdecl KBCWait4IBE(void)" (?KBCWait4IBE@@YAXXZ)
WinIoTest.obj : error LNK2019: unresolved external symbol __RTC_CheckEsp referenced in function "void __cdecl KBCWait4IBE(void)" (?KBCWait4IBE@@YAXXZ)
WinIoTest.obj : error LNK2001: unresolved external symbol __RTC_Shutdown
WinIoTest.obj : error LNK2001: unresolved external symbol __RTC_InitBase
Debug/WinIoTest.exe : fatal error LNK1120: 4 unresolved externals
Error executing link.exe.
WinIoTest.exe - 5 error(s), 1 warning(s)
#4
#ifdef WINIO_DLL
#define WINIO_API _declspec(dllexport)
#else
#define WINIO_API _declspec(dllimport)
#endif
#define WINIO_API _declspec(dllexport)
#else
#define WINIO_API _declspec(dllimport)
#endif
#5
这一句WinIo.h 头文件里已经有了..
#6
"__RTC_xxxx"运行时库,改改连接库试试
#7
感谢各位了, 最后我还是改用Win32 动态装入来完成, 结果也可以。