Sample usbfx2 test app?

Hi,
I was wondering if anyone has made a version of the usbfxtest.cpp application for the OSR FX2 learning kit that will compile on VS 2005/2008. I keep getting linker errors LNK2019 and can’t seem to get rid of them. I’m from the embedded microcontroller world, and I’m a whiz at solving linker errors there, but Windows seems to be a different animal.

Any help would be most appreciated!

Take Visual Stdio and remove it from your system. Build the drivers in the
correct environment(s) as the documentation that comes with the WDK says.
Maybe after you get that done with a few of the sample drivers that ship
with the WDK and the OSR FX2 driver, then you can consider using VS as a
glorified editor. I prefer SlickEdit and I can invoke the build using Mark
Roddy’s ddkbuild.bat from there. You can do the same with Visual Studio,
but don’t try it until you can do it as documented.

wrote in message news:xxxxx@ntdev…
> Hi,
> I was wondering if anyone has made a version of the usbfxtest.cpp
> application for the OSR FX2 learning kit that will compile on VS
> 2005/2008. I keep getting linker errors LNK2019 and can’t seem to get rid
> of them. I’m from the embedded microcontroller world, and I’m a whiz at
> solving linker errors there, but Windows seems to be a different animal.
>
> Any help would be most appreciated!
>

Thanks for the response. Maybe I wasn’t clear; I am using the WDK to build the actual USB drivers, now I’m looking to build some kind of GUI to use them after I install the drivers. Since I’m completely new to COM, I was looking for an example (like the test application sent with the FX2 kit) that I could tweak and figure out how it works.

In the WDK, all drivers that have apps that interface with them are built
with the WDK. It appears that at Microsoft, the kernel developers don’t do
Visual Studio type apps. There are limited GUI capabilities in the WDK
build environment, but I am not sure how much capability they have. I have
built apps that use some of the WDK headers, but it takes a lot of work and
experimentation to get it correct. Try the simpler, documented methods
first then you can try to include WDK headers in Visual Studio projects. I
think the last time I used this methodology, it was with the Server 2003 SP1
IFS Kit. It was a program that uses several of the storage stack headers in
a MFC based modal dialog box project.

wrote in message news:xxxxx@ntdev…
> Thanks for the response. Maybe I wasn’t clear; I am using the WDK to
> build the actual USB drivers, now I’m looking to build some kind of GUI to
> use them after I install the drivers. Since I’m completely new to COM, I
> was looking for an example (like the test application sent with the FX2
> kit) that I could tweak and figure out how it works.
>

What are the specific link errors? One thing that can bite you is that the wdk build defines __stdcall as the default calling convention and VS defaults to __cdecl, so if the libs you are linking against which come from the wdk do not have WINAPI in their function declarations, you can have symbol mismatches

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@sbcglobal.net
Sent: Saturday, January 19, 2008 5:44 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Sample usbfx2 test app?

Hi,
I was wondering if anyone has made a version of the usbfxtest.cpp application for the OSR FX2 learning kit that will compile on VS 2005/2008. I keep getting linker errors LNK2019 and can’t seem to get rid of them. I’m from the embedded microcontroller world, and I’m a whiz at solving linker errors there, but Windows seems to be a different animal.

Any help would be most appreciated!


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Thanks Doron. OK, when I create a new project in VS2008 and add the source files ‘usbfxtest.cpp’ and ‘usbfx2lk_ioctl.h’, I then modify the “_cdecl main…” to “int _cdecl main…” to get rid of the compiler error C4430. If attempt build the project now, I get 4 linker errors:

Error 1 error LNK2019: unresolved external symbol xxxxx@4 referenced in function “unsigned char __cdecl FindUSBFX2LKDevice(void * *)” (?FindUSBFX2LKDevice@@YAEPAPAX@Z) usbfxtest.obj FXtest

Error 2 error LNK2019: unresolved external symbol __imp__SetupDiGetDeviceInterfaceDetailW@24 referenced in function “unsigned char __cdecl FindUSBFX2LKDevice(void * *)” (?FindUSBFX2LKDevice@@YAEPAPAX@Z) usbfxtest.obj FXtest

Error 3 error LNK2019: unresolved external symbol __imp__SetupDiEnumDeviceInterfaces@20 referenced in function “unsigned char __cdecl FindUSBFX2LKDevice(void * *)” (?FindUSBFX2LKDevice@@YAEPAPAX@Z) usbfxtest.obj FXtest

Error 4 error LNK2019: unresolved external symbol __imp__SetupDiGetClassDevsW@16 referenced in function “unsigned char __cdecl FindUSBFX2LKDevice(void * *)” (?FindUSBFX2LKDevice@@YAEPAPAX@Z) usbfxtest.obj FXtest

When I look up where these are defined, it takes me to ‘setupAPI.h’ in "c:\program files\Microsoft SDKs\Windows\v6.0a\Include". It appears some of the functions are “legacy”, which I sort of expect if this code was written some time ago, long before VS2005. But I was hoping for a couple of minor changes and be on my way. Maybe I’m in over my head?

Check the paths for SDK include and lib files are for the latest - libs etc
for VS6 (ancient!) are not compatible with VS2008 IIRC. You may well have to
download from MSDN.

I don’t have 08 installed but the paths will be defined in a dialog accessed
via something like Tools > Options > Projects > VS++ Directories.

HTH

Jerry.

----- Original Message -----
From:
To: “Windows System Software Devs Interest List”
Sent: Sunday, January 20, 2008 2:54 PM
Subject: RE:[ntdev] Sample usbfx2 test app?

> Thanks Doron. OK, when I create a new project in VS2008 and add the
> source files ‘usbfxtest.cpp’ and ‘usbfx2lk_ioctl.h’, I then modify the
> “_cdecl main…” to “int _cdecl main…” to get rid of the compiler error
> C4430. If attempt build the project now, I get 4 linker errors:
>
> Error 1 error LNK2019: unresolved external symbol
> xxxxx@4 referenced in function “unsigned
> char __cdecl FindUSBFX2LKDevice(void * *)”
> (?FindUSBFX2LKDevice@@YAEPAPAX@Z) usbfxtest.obj FXtest
>
> Error 2 error LNK2019: unresolved external symbol
>__imp SetupDiGetDeviceInterfaceDetailW@24 referenced in function
> "unsigned char
cdecl FindUSBFX2LKDevice(void * *)"
> (?FindUSBFX2LKDevice@@YAEPAPAX@Z) usbfxtest.obj FXtest
>
> Error 3 error LNK2019: unresolved external symbol
> imp SetupDiEnumDeviceInterfaces@20 referenced in function “unsigned
> char __cdecl FindUSBFX2LKDevice(void * *)”
> (?FindUSBFX2LKDevice@@YAEPAPAX@Z) usbfxtest.obj FXtest
>
> Error 4 error LNK2019: unresolved external symbol
>__imp SetupDiGetClassDevsW@16 referenced in function "unsigned char
>
cdecl FindUSBFX2LKDevice(void * *)" (?FindUSBFX2LKDevice@@YAEPAPAX@Z)
> usbfxtest.obj FXtest
> --------------------
> When I look up where these are defined, it takes me to ‘setupAPI.h’ in
> "c:\program files\Microsoft SDKs\Windows\v6.0a\Include". It appears some
> of the functions are “legacy”, which I sort of expect if this code was
> written some time ago, long before VS2005. But I was hoping for a couple
> of minor changes and be on my way. Maybe I’m in over my head?
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

E. Hill wrote:

Error 1 error LNK2019: unresolved external symbol
__imp__SetupDiDestroyDeviceInfoList@4

You need to include setupapi.lib as an input library, you don’t get it by default in Visual Studio. (Project properties => Linker => Input)

Thanks Jerry! Thanks Chris! That was the precise thing I was doing wrong. For those that may be following this (and hopefully don’t repeat the same mistake), I added the library “\WinDDK\6000\lib\wxp\setupapi.lib” to the Additional Dependencies list in VS2008. The project now builds and I can successfully talk to the OSR board now.

I never would have figured that out on my own, so I really appreciate the help. Now onto learning COM…
-Eric.

Congratulations. I have discovered over the years that contaminating
the VS build environment and toolset with components from the DDK
build environment and toolset, or vice versa, is generally not a good
idea and will bite you over the long term. So for cases where there
exists a VS equivalent (setupapi.lib is a standard platform SDK
library) I would suggest using the VS sourced version for VS built
apps rather than importing the DDK version.

On Jan 22, 2008 9:41 PM, wrote:
> Thanks Jerry! Thanks Chris! That was the precise thing I was doing wrong. For those that may be following this (and hopefully don’t repeat the same mistake), I added the library “\WinDDK\6000\lib\wxp\setupapi.lib” to the Additional Dependencies list in VS2008. The project now builds and I can successfully talk to the OSR board now.
>
> I never would have figured that out on my own, so I really appreciate the help. Now onto learning COM…
> -Eric.
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
>


Mark Roddy