Page 1 of 1

wxWidgets and hidapi (for usb)

Posted: Thu Dec 13, 2012 11:13 am
by softport
Hello, I am trying to make a wxWidgets program that uses the hidapi usb library.

It's been several days of struggle, and I have just reached the point where I don't get undefined symbol errors on compile. However the USB library, from the site above, came as a VC++ project. I built the project in Visual Studio
C++ 2008, and am now using resulting dll and .h files in my wxWidgets project. No errors during compile and linking, but... when I run the program (either inside or outside the IDE), I get a popup window saying that the program could not find MSVCR100.dll. (fill in cuss word here).

Apparently this is a run-time environment that all VCpp 2008 executables need. I downloaded it, installed it, and still got the same error. I'm hoping there is an easy fix for this, since I'm very happy with having reached this point :). Otherwise, I have to try and repeat some really boring steps that I took to get here: Install and uninstall VCpp 2005, VCpp2010 etc. every damned version until I find one that works. Apparently only VCpp 2008 needs to have this run time environment installed for its executables to run. Since now I seem to have all the wxWidget project files in their correct places, I could try re-installing VCpp 2010 and recompiling the hidapi project there. I would rather avoid this if there is an alternative.

Thanks in advance

Re: wxWidgets and hidapi (for usb)

Posted: Thu Dec 13, 2012 12:07 pm
by doublemax
I get a popup window saying that the program could not find MSVCR100.dll
MSVCR100.dll is the one from VS2010, not 2008. So you must have one component in your project that was built with it.

If you have the source code for all parts of your project and don't have to use some precompiled libs, you could try static linking of the CRTs.

In VS, go to project properties -> C/C++ -> Code generation -> Runtime library -> Set to "Multithreaded" instead of "Multithreaded DLL".
Then rebuild.

Do this for all parts, the HID libs, wxWIdgets libs, any other libs you might use and your project.

Re: wxWidgets and hidapi (for usb)

Posted: Thu Dec 13, 2012 12:27 pm
by softport
Thanks Doublemax, you always come to the rescue.

I made a mistake in the dll name, it's MSVCR100D.dll . I found several copies of the MSVCR100.dll on my computer,
before realizing I was looking for the wrong thing :).

I'm now going to search for the correct file, then try out your suggestions the best I can.

thanks!

Re: wxWidgets and hidapi (for usb)

Posted: Thu Dec 13, 2012 12:48 pm
by softport
Ok, I do not have MSVCR100D.dll in my computer. I was going to download it from Microsofthere, but I'll try your suggestion first, sounds much better if I can make it work. Thanks again.

Re: wxWidgets and hidapi (for usb)

Posted: Thu Dec 13, 2012 2:04 pm
by doublemax
"MSVCR100D.dll" The "D" means it's the debug version. That's not included in the redistributable package anyway, it contains only the release versions. This means that you didn't build all parts of your project in release mode.

Re: wxWidgets and hidapi (for usb)

Posted: Thu Dec 13, 2012 2:33 pm
by softport
Ok, thanks for that info. Somewhere along the line I realized the compiler was not set in release mode. I thought I had changed that, but maybe not everywhere it needed. I double checked again, and also made the change you suggested:
In VS, go to project properties -> C/C++ -> Code generation -> Runtime library -> Set to "Multithreaded" instead of "Multithreaded DLL".
Then rebuild.
This got rid of the MSVCR100D.dll error. THANK YOU!

Just a note as the clouds are finally thinning out. I spent a lot of time trying to figure out what to do with the hidapi.dll file generated by VC++. At this point, with no errors being generated by wxCpp, I'm not even using hidapi.dll.

The VC++ project also creates a hidapi.lib file, and this is the one I am using in my wxWidgets project (Project options->Parameters->Add Library). Also added #include "hidapi.h" at the top of my form.cpp. That's it.

In the hidapi documentation I kept reading "just add the two files" and I couldn't figure out which files they meant. My test app isn't finished yet, so can't confirm that it's doing anything but compiling with no errors. Hopefully it will be able to perform its HID functions without the hidapi.dll.

..and again many thanks.

Re: wxWidgets and hidapi (for usb)

Posted: Thu Dec 13, 2012 2:41 pm
by doublemax
Just a note as the clouds are finally thinning out. I spent a lot of time trying to figure out what to do with the hidapi.dll file generated by VC++.
If the lib is very small and the dll big, then the lib probably doesn't contain any code, it just the "link" between your code and the DLL, and the DLL needs to be present at runtime.

Re: wxWidgets and hidapi (for usb)

Posted: Thu Dec 13, 2012 3:14 pm
by softport
You are right: hidapi.lib 5.14KB, hidapi.dll 46KB

I had hidapi.dll in my main widgets project folder. In the DevC++ IDE the program runs fine.
I clicked on the hidapi.exe in the output mingw folder... error, can't find hidapi.dll . This made me laugh, and realize I'm not depressed anymore. Moved the hidapi.dll into the mingw folder, and the executable runs fine.