Libusb Windows MSVC Error : corrupted dll - visual-studio

I am trying to create a program using libusb library on Windows with Visual Studio 2019 (MSVC).
I am UNIX main, and little bit new in windows programming. So I may miss some easy issues.
First I dowloaded libusb on the official website : https://libusb.info/.
I extracted everything and opened the libusb-1.0.24\msvc\libusb_2019.sln project.
I built the dll and lib in all x86/x64 Debug/Release possibilities.
Any probleme with building the library.
I started a Visual Studio new project, with a single sample file (just display connected devices).
I added the include and a x64 Debug dll version off the library, same as the project.
But when I build the program, I have a link error :
"[...]libusb-1.0.24\lib\libusb-1.0.dll : fatal error LNK1107: fichier non valide ou endommagé : impossible de lire à 0x348"
In english : invalid or corrupted file : impossible to read at 0x348.
I tried to build with the static version off the library and I didn't had any issue. The program works with my static build of libusb.
I must use a dynamic link with the library for this project, so this is not a solution for me.
I also tryed to download directly the dll on the website : https://wikidll.com/fr/libusb/libusb-1.0-dll - WARNING THE FIRST DOWNLOAD BUTTON IS AN ADD - and I got same issue when running (the only difference is the corrupted line).
Thank for anyone trying to help me,
Leo

Related

Godot app stop working when added external DLL

I have a problem using external DLL-s in Godot and would like to ask for advice.
I use Godot with Rust. For that, I compile a DLL which contains the game logic written in Rust (dylib.dll). So far everything is good, my application can be run.
Now I added an other external library to the stack (ValveSoftware/GameNetworkingSockets, GNS) as a DLL. This DLL is referenced only by my game logic dll (dylibd.dll), and Godot does not know about it. My game-logic-dll compiles fine referencing GNS.
Now when I start my Godot app, I get an error whic says:
ERROR: Can't open dynamic library: project/libs/dylib.dll, error: Error 126: The specified module could not be found.
.
At: platform/windows/os_windows.cpp:2395
ERROR: get_symbol: No valid library handle, can't get symbol from GDNative object
At: modules/gdnative/gdnative.cpp:501
ERROR: init_library: No nativescript_init in "res://libs/dylib.dll" found
At: modules/gdnative/nativescript/nativescript.cpp:1506
Sidenotes:
It works on linux without any issue, the problem occurs only on windows.
I use nightly-x86_64-pc-windows-msvc rust toolchain
The GameNetworkingSockets was built on the same machine, I think the vcpkg builder uses Visual Studio for the build.
all the required DLLs (my game logic DLL and the lib's DLL) is in the Working directory.
Any idea?
I have found the issue :)
The problem was really simple, the main issue here is rather the misleading and lacking error message from Windows.
The issue was that my external DLL also depends on other DLL-s as well, which windows could not find on its searching paths (in this case, libprotobuf.dll, libssl.dll, libcrypto.dll).
On my linux machines those shared libraries probably were already installed, that is why it worked there but not on Windows.
This tool also helped me al ot: https://learn.microsoft.com/en-us/sysinternals/downloads/procmon#download
With this tool it was easy to spot that my app tried to load the aforementioned DLL-s but could not find them.
I had the same problem. I developed a project with Godot on my pc (Win 10). Then I moved the same project on another pc (Win 10).
When I tried to import the project I found the "ERROR: Can't open dynamic library: C:/GodotProjects/mylib.dll, error: Error 126: The specified module could not be found."
The new pc needed some Visual C++ Redistributable packages:
Visual C++ Redistributable package
I hope this could help you

The application was unable to start correctly 0xc150002

Hey guys so I have combed the internet trying to find a solution to my problems I had decided I want to learn to opencv and am having a hell of a time to get a basic hello world program working.
So I'll start of with I downloaded the OpenCV2.1 from sourceforge
http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.1/
I am currently running Visual studio 2010 on Windows 7, 32 bit.
So I installed ran the OpenCV2.1.exe file and added OpenCV to my path enviroment, I then build the libraries using cmake and ran through the following instructions
http://opencv.willowgarage.com/wiki/VisualC%2B%2B_VS2010_CMake
When i build the code in the tutorial abovei get a sucesfull build but when I try and start the program i get the "The application was unable to start correctly 0xc150002" error. Anyone have any thought ?
EDIT:
I looked at the event log and this is the information i get
Activation context generation failed for "C:\OpenCV2.1\bin\cxcore210d.dll". Dependent Assembly Microsoft.VC90.DebugCRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8" could not be found. Please use sxstrace.exe for detailed diagnosis.
Microsoft.VC90.DebugCRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8"
C:\OpenCV2.1\bin\cxcore210d.dll
Had the same problem. Indeed I did rebuild the Dlls, but in the PATH environment variable of Windows the old DLLs C:\OpenCV2.1\bin; were before the new built DLLs C:\OpenCV2.1\build\bin\Debug; which meant that always the old were loaded ... Now it works

OpenCV_HelloWorld project in VC++ 2010 Runtime Error:

I set up the environment according to this tutorial:
http://opencv.willowgarage.com/wiki/VisualC%2B%2B_VS2010
However the picture they want you to use is no longer there, so I just saved the supplied screen shot with the same name as the original file.
Builds fine, Begins to run but then I get a runtime error
Here is the runtime error:
OpenCV_HelloWorld.exe - Application Error : The application was unable to start correctly (0xc0150002). Click OK to close the application.
I looked in Event Viewer and found that it also set off a another error but did not announce
Here is the unannounced error:
Activation context generation failed for "C:\OpenCV2.1\bin\cxcore210d.dll". Dependent Assembly Microsoft.VC90.DebugCRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8" could not be found. Please use sxstrace.exe for detailed diagnosis.
As you can see it says to use sxstrace.exe however I don't appear to have that program. After a quick Google I read that the program was included in the Microsoft Windows Platform SDK, so I'm downloading the most relevant version (windows 7 version for c# and .net) and installing that to follow up on that, I'll post what I find as it comes.
Any help is very much appreciated
Unexpectedly the project builds and runs now. The only modifications made were removing spaces in the c++ directory and linker options from the tutorial. External changes were the completed installation of the windows platform SDK, however OpenCV has no dependencies with windows platform sdk. I am unsure how it was resolved, but it's no longer a problem.

Using Boost Windows Installer - do I still need to make the non header only libraries?

I'm using the Boost Windows installer provided by boostpro.com and already have all the compiled binaries present in my boost_1.44/lib folder. However, when I'm trying to use the boost filesystem library, I'm getting a build error saying that
LINK : fatal error LNK1104: cannot open file 'libboost_system-vc90-mt-gd-1_44.lib'
I'm using Visual Studio 9, and I don't have a file called 'libboost_system-vc90-mt-gd-1_44.lib'. Any ideas on what I should do next?
You either need to compile the variant of Boost with "threading=multi runtime-debugging=on variant=debug" as that's not a variant that normally comes with the BoostPro installer (AFAIK); or switch your project to use a different variant. Most likely you need to turn off the "runtime-debugging=on" in VC, which translates to turning off the debug STD. See the Getting Started for what the name of the library it's asking for means.

Qt4 Program Crashing Unless SDK Installed

I've written a Open Source program that I've released as GPL built using the Qt4 LGPL SDK. This program has the ability to search an optional Sqlite3 database for data.
Here is what is making me lose my mind. I compile the program on the development machine. When I try to run it, I can errors about missing DLLs. I copy those dlls into the same directory as the executable and it now works fine ( mingwm10.dll, libgcc_s_dw2-1.dll, QtCore4.dll, QtSql4.dll, QtGui4.dll ), including the database search.
Now, if I copy that folder with the executable and the DLLs to a new machine that has not had the SDK installed on it, it runs fine until I try to search. As soon as I hit the search button, I can the following error:
Title: Microsoft Visual C++ Runtime Library
Runtime Error!
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
I then download and install the SDK, doing nothing else, I can now run the program and search the sqlite3 file just fine!
What magic am I missing?
P.S. Both machines are freshly installed Windows XP systems.
You may have some libs or Qt plugins that are not deployed to the target machine. It most likely is the SQL driver plugin. Here's some info about it: http://doc.trolltech.com/latest/deployment-windows.html#qt-plugins
You'll need to copy the needed Qt plugins to a directory next to your executable. And add something like this in your main():
QApplication::addLibraryPath(QCoreApplication::applicationDirPath() + "/plugins");
(Edited link and added code)
I found the problem.
Stephen Chu was correct in that I was missing the sqlite driver. However, I can into more complications along the way.
The SDK comes with two sets of dlls. One set resides in $BASEDIR/bin and the other in $BASEDIR/qt/bin. The former contains the dlls used by Qt Creator, while the latter are the dlls that you want to ship with your executable.
I needed to take the sqlite plugin ( qsqlite4.dll ) and copy it to APP_DIR/sqlplugins. My problem was I was using the wrong qsqlite4.dll file.
A big thanks to everyone who contributed to this question.
For future reference, this issue was also discussed here: http://www.qtforum.org/article/34639/qt4-program-crashing-unless-sdk-installed.html

Resources