基于windriver开发驱动,64位平台和32位平台一次解决

来源:互联网 发布:儿童听故事软件 编辑:程序博客网 时间:2024/06/05 00:09

一:

        在基于windriver开发驱动来说,对于个人并不喜欢这种东西,但是效率需求,需要使用这种中间件。但是在创建工程的时候往往是创建一个64位的工程,因为我们当前电脑64位,在里面我们可能直接发布出64位版本的驱动,也可能发布出32位的版本驱动,但是注意,这个32位只能在64位平台上跑,在32位平台是跑不起来的,这和windriver有关。哪不能为了开发驱动安装俩个系统吧,然后装俩个windriver,32位版和64位版,然后使用各自的库,当然是可以的,但这样也太麻烦了。其实我们明白的是在32和64位先调用的dll是不一样的,也就是说windriver是区分了32位下的库和64位下的库,但是直接替换dll也是不行。解决方案是dll肯定是要替换,在编译的时候去掉64位工程中的一个64bit的宏然后就可以在32位平台运行了。


二:下面是官方说明:

A.2. Support for 32-Bit Applications on 64-Bit Windows and Linux Platforms

By default, applications created using the 64-bit versions of WinDriver are 64-bit applications. Such applications are more efficient than 32-bit applications. However, you can also use the 64-bit WinDriver versions to create 32-bit applications that will run on the supported Windows and Linux 64-bit platforms [A.1].

[Note] In the following documentation, <WD64> signifies the path to a 64-bit WinDriver installation directory for your target operating system, and <WD32> signifies the path to a 32-bit WinDriver installation directory for the same operating system.

To create a 32-bit application for 64-bit Windows or Linux platforms, using the 64-bit version of WinDriver, do the following:

  1. Create a WinDriver application, as outlined in this manual (e.g., by generating code with DriverWizard, or using one of the WinDriver samples).
  2. Build the application with an appropriate 32-bit compiler for your target OS, using the following configuration:
    • Add a KERNEL_64BIT preprocessor definition to your project or makefile.

      [Note] In the makefiles, the definition is added using the -D flag: -DKERNEL_64BIT.

      The sample and wizard-generated Linux and Windows GCC makefiles and the Windows MS Visual Studio projects, in the 64-bit WinDriver toolkit, already include this definition.

    • Link the application with the specific version of the WinDriver-API library/shared object for 32-bit applications executed on 64-bit platforms —<WD64>\lib\amd64\x86\wdapi1240.lib on Windows / <WD64>/lib/libwdapi1240_32.so on Linux.

      The sample and wizard-generated project and make files for 32-bit applications in the 64-bit WinDriver toolkit already link to the correct library:
      On Windows, the MS Visual Studio project files and Windows GCC makefiles are defined to link with <WD64>\lib\amd64\x86\wdapi1240.lib
      On Linux, the installation of the 64-bit WinDriver toolkit on the development machine creates a libwdapi1240.so symbolic link in the /usr/lib directory — which links to<WD64>/lib/libwdapi1240_32.so — and in the /usr/lib64 directory — which links to <WD64>/lib/libwdapi1240.so (the 64-bit version of this shared object).
      The sample and wizard-generated WinDriver makefiles rely on these symbolic links to link with the appropriate shared object, depending on whether the code is compiled using a 32-bit or 64-bit compiler.

[Note] 
  • When distributing your application to target 64-bit platforms, you need to provide with it the WinDriver-API DLL/shared object for 32-bit applications executed on 64-bit platforms — <WD64>\redist\wdapi1240_32.dll on Windows / <WD64>/lib/libwdapi1240_32.so on Linux. Before distributing this file, rename the copy of the file in your distribution package by removing the _32 portion. The installation on the target should copy the renamed DLL/shared object to the relevant OS directory — \%windir%\sysWOW64 on Windows or /usr/lib on Linux. All other distribution files are the same as for any other 64-bit WinDriver driver distribution, as detailed in Chapter 14.
  • An application created using the method described in this section will not work on 32-bit platforms. A WinDriver application for 32-bit platforms needs to be compiled without the KERNEL_64BIT definition; it needs to be linked with the standard 32-bit version of the WinDriver-API library/shared object from the 32-bit WinDriver installation (<WD32>\lib\x86\wdapi1240.lib on Windows / <WD32>/lib/libwdapi1240.so on Linux); and it should be distributed with the standard 32-bit WinDriver-API DLL/shared object (<WD32>\redist\wdapi1240.dll on Windows / <WD32>/lib/libwdapi1240.so on Linux) and any other required 32-bit distribution file, as outlined in Chapter 14.