3791|6

85

帖子

0

TA的资源

一粒金砂(初级)

楼主
 

如何使用 ,而不出现连接错误 [复制链接]

小弟在用pb5写一个简单的流接口驱动,使用了ceddk库函数MmMapIoSpace。可是在编译时出现连接错误.
在下刚学写这样的驱动程序,还望大哥大姐们赐教!

DWORD DEM_Init( LPCTSTR pContext, LPCVOID lpvBusContext)
{
        OutputDebugString(L"MyDriver - DEM_Init - Context: ");
        OutputDebugString(pContext);
        OutputDebugString(L"\n");
       
        OutputDebugString(L"MyDriver - ~ DEM_Init\n");
        ELECTROMOTOR_GPACON=(ULONG)MmMapIoSpace(GPACON,4,FALSE);
        ELECTROMOTOR_GPADATA=(ULONG)MmMapIoSpace(GPADATA,4,FALSE);
        ELECTROMOTOR_1=(ULONG)MmMapIoSpace(EMOTOR_1,8,FALSE);

        return 0x1234;
}
错误内容:
LEDDRIVER.obj : error LNK2019: unresolved external symbol MmMapIoSpace referenced in function "unsigned long __cdecl DEM_Init(unsigned short const *,void const *)" (?DEM_Init@@YAKPBGPBX@Z)
BUILD: [01:0000000065:ERRORE] obj\ARMV4I\retail\LEDDRIVER.dll : fatal error LNK1120: 1 unresolved externals

最新回复

我知道是怎么了,PB定制完wince后,没有将ceddk.lib复制到 $(_PROJECTROOT)\cesysgen\sdk\lib\$(_CPUINDPATH)\ceddk.lib\ 下,我于是将ceddk.lib手动复制到以上目录就OK了。 总之,也谢谢两位的回复。  详情 回复 发表于 2008-9-18 11:59
点赞 关注

回复
举报

62

帖子

0

TA的资源

一粒金砂(初级)

沙发
 
简单啊,把它的实现包进来就不会出现错误 ^_^
 
 

回复

87

帖子

0

TA的资源

一粒金砂(初级)

板凳
 
请在source文件里链接ceddk.lib
例子如下:
TARGETLIBS= \
        $(_COMMONSDKROOT)\lib\$(_CPUINDPATH)\coredll.lib \
        $(_COMMONOAKROOT)\lib\$(_CPUINDPATH)\ceddk.lib \
 
 
 

回复

62

帖子

0

TA的资源

一粒金砂(初级)

4
 
在下还是不太明白,我将代码贴出来,请两位指点。
//LEDDRIVER.CPP
#include "stdafx.h"
#include
#include

#pragma comment(lib,"ceddk.lib")

DWORD DEM_Init(LPCTSTR pContext, LPCVOID lpvBusContext);
BOOL DEM_Deinit( DWORD hDeviceContext );
DWORD DEM_Open( DWORD hDeviceContext, DWORD AccessCode, DWORD ShareMode );
BOOL DEM_Close( DWORD hOpenContext );
BOOL DEM_IOControl( DWORD hOpenContext, DWORD dwCode, PBYTE pBufIn, DWORD dwLenIn, PBYTE pBufOut, DWORD dwLenOut, PDWORD pdwActualOut );
void DEM_PowerUp( DWORD hDeviceContext );
void DEM_PowerDown( DWORD hDeviceContext );
DWORD DEM_Read( DWORD hOpenContext, LPVOID pBuffer, DWORD Count );
DWORD DEM_Write( DWORD hOpenContext, LPCVOID pBuffer, DWORD Count );
DWORD DEM_Seek( DWORD hOpenContext, long Amount, WORD Type );

#define IOCTL_DRIVER_DEMO   42

#define ELECTROMOTOR_6 (ELECTROMOTOR_1+6)
#define ELECTROMOTOR_7 (ELECTROMOTOR_1+7)

unsigned long ELECTROMOTOR_1;
unsigned long ELECTROMOTOR_GPACON;
unsigned long ELECTROMOTOR_GPADATA;

PHYSICAL_ADDRESS GPACON={0X56000000,0};
PHYSICAL_ADDRESS GPADATA={0X56000004,0};
PHYSICAL_ADDRESS EMOTOR_1={0X10000000,0};

// Not exposed by the Device Driver
void DBGOut(DWORD dwValue);
HANDLE hMem=NULL;
DWORD dwCount;


BOOL APIENTRY DllMain( HANDLE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
                                         )
{
    switch ( ul_reason_for_call )
        {
        case DLL_PROCESS_ATTACH:
                OutputDebugString(L"MyDriver - DLL_PROCESS_ATTACH\n");
                break;
        case DLL_PROCESS_DETACH:
                OutputDebugString(L"MyDriver - DLL_PROCESS_DETACH\n");
                break;
        case DLL_THREAD_ATTACH:
                OutputDebugString(L"MyDriver - DLL_THREAD_ATTACH\n");
                break;
        case DLL_THREAD_DETACH:
                OutputDebugString(L"MyDriver - DLL_THREAD_DETACH\n");
                break;   }

        return TRUE;
}

DWORD DEM_Init( LPCTSTR pContext, LPCVOID lpvBusContext)
{
        OutputDebugString(L"MyDriver - DEM_Init - Context: ");
        OutputDebugString(pContext);
        OutputDebugString(L"\n");
       
        OutputDebugString(L"MyDriver - ~ DEM_Init\n");
        ELECTROMOTOR_GPACON=(ULONG)MmMapIoSpace(GPACON,4,FALSE);
        ELECTROMOTOR_GPADATA=(ULONG)MmMapIoSpace(GPADATA,4,FALSE);
        ELECTROMOTOR_1=(ULONG)MmMapIoSpace(EMOTOR_1,8,FALSE);

        return 0x1234;
}

BOOL DEM_Deinit( DWORD hDeviceContext )
{
        OutputDebugString(L"MyDriver - DEM_Deinit\n");
        OutputDebugString(L"MyDriver - ~ DEM_Deinit\n");
        return TRUE;
}

DWORD DEM_Open( DWORD hDeviceContext, DWORD AccessCode, DWORD ShareMode )
{
        OutputDebugString(L"MyDriver - DEM_Open\n");
        OutputDebugString(L"hDeviceContext - ");
        DBGOut(hDeviceContext);
        OutputDebugString(L"\n");
       
        OutputDebugString(L"MyDriver - ~ DEM_Open\n");
        return 0x5678;
}

BOOL DEM_Close( DWORD hOpenContext )
{
        OutputDebugString(L"MyDriver - DEM_Close\n");
        OutputDebugString(L"hOpenContext - ");
        DBGOut(hOpenContext);
        OutputDebugString(L"\n");
        OutputDebugString(L"MyDriver - ~ DEM_Close\n");
       
        return TRUE;
}

BOOL DEM_IOControl( DWORD hOpenContext, DWORD dwCode, PBYTE pBufIn, DWORD dwLenIn, PBYTE pBufOut, DWORD dwLenOut, PDWORD pdwActualOut )
{
        OutputDebugString(L"MyDriver - DEM_IOControl\n");
        OutputDebugString(L"hOpenContext - ");
        DBGOut(hOpenContext);
        OutputDebugString(L"\n");
        OutputDebugString(L"MyDriver - ~ DEM_IOControl\n");
        return TRUE;
}

void DEM_PowerUp( DWORD hDeviceContext )
{
        OutputDebugString(L"MyDriver - DEM_PowerUp\n");
        OutputDebugString(L"hDeviceContext - ");
        DBGOut(hDeviceContext);
        OutputDebugString(L"\n");
        OutputDebugString(L"MyDriver - ~ DEM_PowerUp\n");
}

void DEM_PowerDown( DWORD hDeviceContext )
{
        OutputDebugString(L"MyDriver - DEM_PowerDown\n");
        OutputDebugString(L"hDeviceContext - ");
        DBGOut(hDeviceContext);
        OutputDebugString(L"\n");
        OutputDebugString(L"MyDriver - ~ DEM_PowerDown\n");
}

DWORD DEM_Read( DWORD hOpenContext, LPVOID pBuffer, DWORD Count )
{
        DWORD dwRetCount=0xffff;      // default to error
        OutputDebugString(L"MyDriver - DEM_Read\n");
        OutputDebugString(L"hOpenContext - ");
        DBGOut(hOpenContext);
        OutputDebugString(L"\n");
        if (NULL != hMem) {
                dwRetCount=dwCount;
                memcpy(pBuffer,hMem,dwCount);
        }
        OutputDebugString(L"MyDriver - ~ DEM_Read\n");
        return dwRetCount;
}

DWORD DEM_Write( DWORD hOpenContext, LPCVOID pBuffer, DWORD Count )
{
        OutputDebugString(L"MyDriver - DEM_Write\n");
        OutputDebugString(L"hOpenContext - ");
        DBGOut(hOpenContext);
        OutputDebugString(L"\n");
        if (NULL != hMem) {
                LocalFree(hMem);
        }
       
        hMem=LocalAlloc(LPTR,Count);
        memcpy(hMem,pBuffer,Count);
        dwCount=Count;
        OutputDebugString(L"MyDriver - ~ DEM_Write\n");
        return Count;
}

DWORD DEM_Seek( DWORD hOpenContext, long Amount, WORD Type )
{
        OutputDebugString(L"MyDriver - DEM_Seek\n");
        OutputDebugString(L"hOpenContext - ");
        DBGOut(hOpenContext);
        OutputDebugString(L"\n");
        OutputDebugString(L"MyDriver - ~ DEM_Seek\n");
        return 0;
}


void DBGOut(DWORD dwValue)
{
        TCHAR tcTemp[10];
        wsprintf(tcTemp,L"%ld",dwValue);
        OutputDebugString(tcTemp);
}
/////////////////SOURCES文件
WINCEREL=1
RELEASETYPE=LOCAL
_ISVINCPATH=$(_WINCEROOT)\public\common\sdk\inc;
_OEMINCPATH=$(_WINCEROOT)\public\common\oak\inc;$(_WINCEROOT)\public\common\sdk\inc;
TARGETNAME=LEDDRIVER
FILE_VIEW_ROOT_FOLDER= \
  ReadMe.txt \
  StdAfx.cpp \
  prelink.bat \
  postlink.bat \

FILE_VIEW_RESOURCE_FOLDER= \

FILE_VIEW_INCLUDES_FOLDER= \
  StdAfx.h \

INCLUDES= \
  $(_WINCEROOT)\PUBLIC\COMMON\DDK\INC;$(_WINCEROOT)\PUBLIC\COMMON\OAK\INC; \

SOURCES= \
  LEDDRIVER.cpp \

TARGETTYPE=DYNLINK
PRECOMPILED_CXX=1
PRECOMPILED_PCH=StdAfx.pch
TARGETLIBS= \
  $(_PROJECTROOT)\cesysgen\sdk\lib\$(_CPUINDPATH)\coredll.lib\
  $(_PROJECTROOT)\cesysgen\sdk\lib\$(_CPUINDPATH)\ceddk.lib\ ......{1}

PRECOMPILED_OBJ=StdAfx.obj
PRECOMPILED_INCLUDE=StdAfx.h
CDEFINES=$(CDEFINES) -DLEDDRIVER_EXPORTS
POSTLINK_PASS_CMD=postlink.bat
PRELINK_PASS_CMD=prelink.bat
FILE_VIEW_PARAMETER_FOLDER= \
  LEDDRIVER.bib \
  LEDDRIVER.reg \
  LEDDRIVER.dat \
  LEDDRIVER.db \
  LEDDRIVER.def \
  ProjSysgen.bat \

我在SOURCES文件中的
TARGETLIBS 不加(1)编译出现连接错误
TARGETLIBS 加(1)编译出现NMAKE :  U1073: don't know how to make错误

 
 
 

回复

76

帖子

0

TA的资源

一粒金砂(初级)

5
 
引用 3 楼 andyhere2008 的回复:
我在SOURCES文件中的
TARGETLIBS 不加(1)编译出现连接错误
TARGETLIBS 加(1)编译出现NMAKE :  U1073: don't know how to make错误

加是肯定要加的,加了之后出现这个错误,说明没找到ceddk.lib
你试试看这个啊$(_COMMONOAKROOT)\lib\$(_CPUINDPATH)\ceddk.lib \
 
 
 

回复

70

帖子

0

TA的资源

一粒金砂(初级)

6
 
我试过了下,结果是一样,但多出了两个WARNS
Macro: _COMMONPUBROOT not found in $(_COMMONPUBROOT)\sdk\lib\$(_CPUINDPATH)\coredll.lib $(_COMMONSDKROOT)\lib\$(_CPUINDPATH)\ceddk.lib.
Macro: _COMMONPUBROOT not found in \sdk\lib\ARMV4I\retail\coredll.lib $(_COMMONPUBROOT)\sdk\lib\$(_CPUINDPATH)\ceddk.lib.

NMAKE :  U1073: don't know how to make 'D:\WINCE500\PBWorkspaces\aaa\WINCE500\smdk2410_ARMV4I\cesysgen\sdk\lib\ARMV4I\retail\ceddk.lib'
NMAKE.EXE   -i -c BUILDMSG=Stop.  LINKONLY=1 NOPASS0=1 MAKEDLL=1 failed - rc = 2
 
 
 

回复

90

帖子

0

TA的资源

一粒金砂(初级)

7
 
我知道是怎么了,PB定制完wince后,没有将ceddk.lib复制到
$(_PROJECTROOT)\cesysgen\sdk\lib\$(_CPUINDPATH)\ceddk.lib\
下,我于是将ceddk.lib手动复制到以上目录就OK了。

总之,也谢谢两位的回复。
 
 
 

回复
您需要登录后才可以回帖 登录 | 注册

随便看看
查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 1/7 下一条

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表