none
Build USBPRN.DLL RRS feed

  • Question

  • I am trying to build USBPRN_LIB.LIB as USBPRN.DLL, using the code provided in WINCE600\PUBLIC\COMMON\OAK\DRIVERS\USB\CLASS\PRINTER (but copied to my project directory). I need to provide an override driver to resolve a bug in the built-in driver (I have previously done this successfully on CE4 and CE5).

    However, the CE6 linker complains about several undefined symbols.

    Adding USBCLIENT.LIB to TARGETLIBS (in sources file) resolves most of them. However, 4 still remain, including RegisterClientSettings, RegisterClientDriverID, UnRegisterClientDriverID, and UnRegisterClientSettings.

    Adding USBD_LIB.LIB resolves these 4. However, now there are 7 MULTIPLY defined symbols that are already defined in usbclient.lib.

    How do I fix this?

    Thanks,

    Rob

    Thursday, March 31, 2011 1:06 AM

All replies

  • you should use usbd.lib not usbd_lib.lib.
    $(_COMMONSDKROOT)\lib\$(_CPUINDPATH)\usbd.lib
    Thursday, March 31, 2011 1:19 AM
  • Have a look here: http://guruce.com/blogpost/cloningpubliccodeanexample
    And here: http://guruce.com/blogpost/manualcloneofpubliccode
     

    Good luck,

    Michel Verhagen, eMVP
    Check out my blog: http://guruce.com/blog

    GuruCE
    Microsoft Embedded Partner
    http://guruce.com
    Consultancy, training and development services.
    Thursday, March 31, 2011 7:06 AM
    Moderator
  •  

    >>$(_COMMONSDKROOT)\lib\$(_CPUINDPATH)\usbd.lib

    This file does NOT exist!

    Thursday, March 31, 2011 4:40 PM
  • Looks like it should be $(_COMMONOAKROOT)\lib\$(_CPUINDPATH)\usbd.lib
    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.
    www.Eurotech.com
    Thursday, March 31, 2011 4:45 PM
    Moderator
  • There is no file "usbd.lib" in the entire WINCE600 folder tree. This is why I previously tried "usbd_lib.lib".

    NOTE: My OSDesign only includes the Device Emulator target, in case this makes any difference. I don't have and typically don't need a BSP. Just trying to build a printer driver (and associated components, such as USBPRN).

    Thursday, March 31, 2011 5:11 PM
  • The USBD.LIB is the stub library of USBD.DLL which is generated during SYSGEN phase.
    So even the DE doesn't have USB host controller, you still need to include SYSGEN_USB in order to generate USBD.DLL and its stub library.

    Thursday, March 31, 2011 5:16 PM
  • If you follow the links that Michel gave to you, you will find that he recommends using SYSGEN_CAPTURE to create the sources file.  This file will have the corect paths and lib files that you need to link with to build your printer driver.

    I suspect (but don't know because I haven't dug that far) that you don't have USBD.LIB becuase you don't have USB host or the printer driver included in your OS.  But when you run SYSGEN_CAPTURE, as Michel's links point out to do, you will also create a sources file for USBD.

    Building your driver for the device emulator is about useless.   Instead, select a BSP that matches your target (or your customer's) CPU family.


    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.
    www.Eurotech.com
    Thursday, March 31, 2011 5:20 PM
    Moderator
  • I rebuilt usbd.lib, essentially using the info from Michael's links.

    I changed the TARGETLIBS in sources for USBPRN to be similar to those created in "sources.usbprn".

    But, upon rebuild of USBPRN, I get the same "already defined in usbclient.lib" problems:

    BUILD: [01:0000000087:ERRORE] usbd.lib(usbddrv.obj) : error LNK2005: ResetPipe already defined in usbclient.lib(usbclient.obj)

    BUILD: [01:0000000088:ERRORE] usbd.lib(usbddrv.obj) : error LNK2005: IssueVendorTransfer already defined in usbclient.lib(usbclient.obj)

    BUILD: [01:0000000089:ERRORE] usbd.lib(usbddrv.obj) : error LNK2005: IssueBulkTransfer already defined in usbclient.lib(usbclient.obj)

    BUILD: [01:0000000090:ERRORE] usbd.lib(usbddrv.obj) : error LNK2005: IssueInterruptTransfer already defined in usbclient.lib(usbclient.obj)

    BUILD: [01:0000000091:ERRORE] usbd.lib(usbddrv.obj) : error LNK2005: AbortTransfer already defined in usbclient.lib(usbclient.obj)

    BUILD: [01:0000000092:ERRORE] usbd.lib(usbddrv.obj) : error LNK2005: GetTransferStatus already defined in usbclient.lib(usbclient.obj)

    BUILD: [01:0000000093:ERRORE] usbd.lib(usbddrv.obj) : error LNK2005: GetStatus already defined in usbclient.lib(usbclient.obj)

    Thursday, March 31, 2011 5:47 PM
  • >>Building your driver for the device emulator is about useless.

    JFYI, the printer driver itself builds just fine for ARMV4I and runs great on the actual customer device, even though DE is the only "BSP". I don't need to build the OS. I don't need to run in DE. I just need to build an ARM DLL for the printer driver that I can install to the customer device, and all this works fine.

    But, the built-in USBPRN has a bug that has existed forever (in a nutshell, the RegisterPrinterSettings function doesn't support the standard "MDL:" abbreviation for "MODEL:" after getting the DeviceID. Some of our printers report it one way and some report it the other way). I have fixed it before without any problems using CE4 and CE5 dev tools (Platform Builder). But, the CE6 tools and/or LIB files seem to be broken because I cannot seem to resolve the "undefined" vs "multiply defined" symbols in the various LIB files I need to link against to build USBPRN.

    NOTE: I have NOT installed CE6 R2 or R3, in case somehow these releases have fixed the problem. I don't want to bother with this unless it is absolutely certain that one of these releases fixes the issue.

    Well, here's an idea...maybe I can use the same DLL I built before for CE4 and CE5. This will probably work as a short term solution. But, I would like to be able to actually build it using the CE6 tools.

    Thursday, March 31, 2011 6:46 PM
  • I just cloned it pretty much following how I did it for OALIOCTL in http://geekswithblogs.net/BruceEitman/archive/2008/07/02/platform-builder-clone-public-code.aspx.  I do it a little different from how Michel does it in that I set up seperate folders, one for the cloned code and one for linking to create the DLL - this just helps skip a few steps, but ends with the same results.

    The only change that I had to make to the sources file that was generated when I ran SYSGEN_CAPTURE was to change the path for the def file to $(_SYSGENOAKROOT)\lib\$(_CPUINDPATH)\usbprn.def

    I did this with CE 6.0 R3.  I don't know if any changes have been made since the originaly CE 6.0 release either with the R releases or with QFEs.


    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.
    www.Eurotech.com
    Thursday, March 31, 2011 8:13 PM
    Moderator
  • Since USBD is a driver interface layer and is host controller/platform independent so it is feasible to use DE to generate USBD.LIB for your driver.
    Even you don't need to build the BSP, you still need to set SYSGEN_USB=1 and then do the SYSGEN in order to generate USBD.LIB.
    Or you can use the following steps.

    1. Open a command line windows (from your start menu not the build window from PB)
    2. set _WINCEROOT=C:\WINCE600 (or whatever location you install the PB)
    3. %_WINCEROOT%\public\common\oak\misc\wince ARMV4I CEBASE NOPLAT (or DeviceEmulator if you like)
    4. set SYSGEN_USB=1
    5. SYSGEN -p common preproc

    Then the USBD.LIB is in %_WINCEROOT%\public\CEBase\cesysgen\oak\lib\ARMV4I\retail

    Thursday, March 31, 2011 8:42 PM
  • KMOS,

    Thank you! This worked! Once this procedure generated USBD.LIB and I set this in TARGETLIBS, the multiply-defined errors went away and USBPRN.DLL was built.

    Bruce, Michael - Thanks for your assistance too.

    Thursday, March 31, 2011 10:16 PM
  • I am glad it works.
    And for your info - The USBD_LIB.LIB is for linked into USBD.DLL so unless for creating your own USBD.DLL, no one should link USBD_LIB.LIB to their driver.
    In the other hand, the USBD.LIB is a DLL stub library for USBD.DLL and that is the one for USB class driver, such as USBPRN.
    When using Bruce and Michael's approach, you should use SOURCES.USBD to generate USBD.DLL and more important is its stub, USBD.LIB, which is then being used as stub lib for your driver.

    Thursday, March 31, 2011 11:10 PM
  • Here is some additional information in case it helps someone down the road...

    The reason I got into this situation in the first place was due to selecting an OSDesign template that did NOT include SYSGEN_USB=1. Refer to Windows Embedded CE documentation to see which features each design template supports.

    I went back and created a NEW OSDesign project based on "Internet Appliance", and this generated USBD.LIB when building the OS.

    In this OSDesign project, setting TARGETLIBS to use "$(_COMMONOAKROOT)\lib\$(_CPUINDPATH)\usbd.lib" when building USBPRN worked just fine.


    Friday, April 8, 2011 9:16 PM