Scence:
One MFC program depends on msvcr90.dll and mfc90.dll,I copy those depended DLL to the program directory,program still can't execute.However,the program was executed successfully after I had installed the vcredist_x86.exe.
Miraculous is I checked the dynamic library dependencies of this program again with depends.exe,it automatically linked to dynamic library under fixed path.The path like:c:\windows\winsxs\x86_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.21022.8_none_b81d038aaf540e86\MFC90.DLL,c:\windows\winsxs\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9415_none_508df7e2bcbccb90\MSVCR90.DLL.
Even, I deleted the DLL under those path and it still linked to there.
What have I installed vcredist_x86.exe,which bring about linking to dynamic library under fixed path, e.g.MFC90.DLL,MSVCR90.DLL?And why I copied don't work?
Related
I do have a strange behavior with a flutter package I am building. It uses FFI to integrate a custom-made c++ library.
When I run flutter run -d windows --release the code starts and I do have the window with the code running.
However, when I go to the directory where the executable is stored and I run it, the program starts but the library is not loaded. I do see also that when I run flutter test, it complains that it cannot load the library. I have checked that the dll's needed are there using dependenciesGUI.exe and it seems that everything is fine, at least on my side. I do see however that within kernel32.dll I am missing ext-ms-win-oobe-query-l1-1-0.dll.
I am using Visual Studio 2022 with the x64 configuration.
Any idea on what could be the issue? For me it is VERY puzzling to be able to run the software through flutter but not with the executable directly.
Thanks!
Yours,
Pi-r
EDIT:
I compared my package with a fresh package built with flutter. With a fresh package, the behavior is the one expected: I can have the program run normally or with flutter run.
I compared the libraries of the clean package with the ones linked in my package. They are the same (with the same missing dlls which do not seem to pose an issue).
I also checked that the exported functions I needed where present -> It is the case.
The only difference I can see is that using flutter run adds a series of libraries to the path. Has I am a Linux person, I do not know of a tool that could be used to detect what is the missing library. I am open to write a separated c++ code that would load the library if it could help me identify what is the issue... ANY tips/tricks would be greatly appreciated :)
I finally found the issue I had and it is related to a different behavior under Linux and under Windows (as you will guess, I am a Linux person).
When compiled under Linux, I can force the compiler to link multiple libraries relatively to my main library. I discovered that this is not the case under Windows. Either the dlls are in the executable folder or in the Path.
For the sake of code clarity, my package uses two different libraries. Library A, which is compiled from flutter with the ffi package, called library B. First the second library was in the asset folder and with the relative linking of Linux, it was working perfectly. But it did not work under Windows until I explicitly copied the two in the same directory of the executable.
The solution was then to ensure that both libraries are copied correctly in the directory of the flutter executable. This can be done easily if you add the dependent libraries to the bundle variable in the CMakeLists.txt of the package.
However, this doesn't work when you do the testing (flutter test). As the bundle mechanism seems to be not propagated to the test function. Therefore here, the only solution is to copy the dependent libraries to the root directory of the source code :vomiting_face:
I must point out that this is only the case under Windows, for Linux, it works out of the box...
I am trying to include a external library (.lib pointing to a .dll) in my project. I am building on windows using QT (it appears to be using msvc2010 as the compiler) and have: LIBS += <path>/<libraryName>.lib in my .pro file. I have the corresponding .dll file in the directory where the executable is output so it can be found. When the program is run I get the following from QT:
Starting (program name)...
The program has unexpectedly finished.
(program name) exited with code -1073741515
Searching around it seems this type of error can come from .dll files being different in some way than you expect, which seems to be at least partially the problem here. When I open my program with dependency walker I can see that my .dll file found and the functions in it look to be correct as far as I can tell. However in the parent import function pane the functions do not agree or look correct (I think why I am getting my error). These function definitions exactly match the functions from another external library that I am using.
To me this indicates that somehow the .lib file is incorrect, however I have used this pair of .lib/.dll files before in a different program (not built in QT) and they worked fine. Also I have tried removing the reference to the .lib file from my .pro file and the correct functions calls complain (the ones from this library defined in the .dll file that is found). The .lib file looks exactly how I would expect it too using Dumpbin.exe /EXPORTS to view its content.
Any thoughts on what dependency walker is trying to tell me or what I should be trying now would be awesome.
edit 2/8: I have constructed a minimal example. It stops with the same error however in dependency walker instead of showing the functions from another library it shows no expected functions.
Looking at the explanation given for your minimal example it would seem what is happening here is that there are no MinGW function calls for the library (they are all MSVC calls). The functions found in the libraries are listed correctly because they are, just not being linked form the other compiler. As for why different libraries functions are showing up, I would guess its a bug in dependency walker.
I have a windows dll (Main application directly loads this windows dll) that links to another 2 dlls, which are obtained by cross-compiling using mingw32.
I am facing a weird problem with this linking.
Say I have 2 functions in first cross compiled dll funcA_firstdll() and funcB_firstdll()
and similarly I have 2 functions in second cross compiled dll funcC_secdll() and funcD_secdll().
When linking with windows main dll I dont get any linker errors but the dlls are not getting loaded.
So if I check the dependencies of windows dll using dependency walker I see both the first and second cross compiled dll in red colour.
When I click on first cross compiled dll I am seeing the functions present in that dll(funcA_firstdll() and funcB_firstdll() ) as green and second cross dll(funcC_secdll() and funcD_secdll()) as red.
Similarly When I click on second cross compiled dll I am seeing the functions present in that dll (funcC_secdll() and funcD_secdll()) as green and first cross dll as red.
I am unable to understand why are they unable to interlink with each other.
Is there any different way to link cross compiled dll's.
Any help is appreciated.
Regards,
Techtotie.
Solved it by myself.
It was actually a problem with proxy libs generated by mingw were not interpreted properly by MSVC.
So had to generate the def files also. Follow this tutorial
http://www.mingw.org/wiki/MSVC_and_MinGW_DLLs
I was trying to use QOCI plugin for QtSql, until I had some problems:
Why QOCI plugin isn't working
However it turned out that it is a library loading issue (at least I think so), so I decided to change the subject of the question since it is a new question.
I have a dll file (called qsqloci4.dll) When I try to load it with LoadLibrary, it fails and GetLastError returns ERROR_MOD_NOT_FOUND. When I try to load it with LoadLibraryEx and 3rd parameter is DONT_RESOLVE_DLL_REFERENCES, it loads successfully (does not return NULL).
So, i thought it is a dependency issue. I opened the dll file with dependency walker, there were 2 files that couldn't be located: QtCore4.dll and QtSql4.dll.
However, these files are in the working directory of application, and other dll files which are dependent on those dlls (such as qsqlpsql4.dll) are successfully loaded.
Other dlls (which are located by dependency walker) are:
oci.dll : is in same folder as QtCore4.dll and QtSql4.dll, means my app can access it
kernel32.dll : i believe the easiest dll to locate by my app
msvscr80.dll : other dll files which use this can be loaded successfully.
Here is my question: given dependency walker says : "you have all dlls except qt ones" and i am sure that I have qt dlls, what other reason can be for LoadLibrary to fail with ERROR_MOD_NOT_FOUND?
You need to run Dependency Walker in dynamic mode because the are some dependencies that will be resolved by explicit linking. I believe that you do this from the Profile menu.
I am developing a project in VC++2008. The project uses the OpenCV library (but I guess this applies to any other library). I am working with the Debug configuration, the linker properties include the debug versions of the library .lib's as additional dependencies. In VC++ Directories under Tools|Options i set up the include directory, the .lib directory, the source directories for the library as well. I get an error while calling one of the functions from the library and I'd like to see exactly what that function is doing. The line that produces the error is:
double error = cvStereoCalibrate(&calObjPointsM, &img1PointsM, &img2PointsM,
&pointCountsM,
&cam1M, &dist1M, &cam2M, &dist2M, imgSize, &rotM, &transM, NULL, NULL,
cvTermCriteria(CV_TERMCRIT_ITER + CV_TERMCRIT_EPS, 100, 1e-5));
I set up a breakpoint at this line to see how the cvStereoCalibrate() function fails. Unfortunately the debugger won't show the source code for this function when I hit "Step into". It skips immediately to the cvTermCriteria() (which is a simple inline, macro-kinda function) and show its contents. Is there anything else I need to do to be able to enter the external library functions in the debugger?
EDIT: I think the cvTermCriteria() function shows in the debugger, because it's defined in a header file, therefore immediately accesible to the project.
EDIT2: The .pdb files were missing for the library files, now I recompiled the OpenCV library in Visual C++ in Debug configuration, the .pdb files exist but are still somehow invisible to the debugger:
Loaded 'C:\Users\DarekSz\Documents\Visual Studio 2008\Projects\libcci\Debug\ccisample.exe', Symbols loaded.
'ccisample.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll'
'ccisample.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll'
'ccisample.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll'
'ccisample.exe': Loaded 'C:\OpenCV2.1\bin\cv210d.dll'
'ccisample.exe': Loaded 'C:\OpenCV2.1\bin\cxcore210d.dll'
The symbols aren't loaded apparently for the opencv dlls. Still, the .pdb files exist in the \bin directory.
To sum up all the activity in the comments: the key to the solution was to rebuild the library in VC++ to obtain the .pdb (Program Debug Database) files for debugging, the precompiled "-d" suffix libraries weren't enough. Still, the import libs for the library dlls made the program load precompiled dlls from the OpenCV package tree, not the ones from my build with the .pdb information (the paths were similar so I didn't notice at first). The path to the .pdb files was provided in Tools|Options, but these files weren't loaded because of module version mismatch (obviously). Once I copied the correct dlls and their respective .pdb files to the application directory, the debugger started working inside the library functions.
Confirm: are you actually compiling the OpenCV library from source, or are you just linking against it?
A couple of possibilities come to mind:
It sounds like the debug info for the OpenCV library is not available (the PDB files). You may have to extend PATH to reference the directory containing these files. It seems to me that there is a way of doing this from VC++ but I'm a few years out from using the tool...
Is cvStererCalibrate also a "macro function"? If so, find out what real function it refers to and set the breakpoint in the library.
Finally, although you have already said so, it never hurts to go back and confirm that full debugging has been activated for everything in the project, including external libraries.
I don't know if this helps, but its a good place to start.
i got the same problems, which is:
'ccisample.exe': Loaded 'C:\OpenCV2.1\bin\cv210d.dll'
'ccisample.exe': Loaded 'C:\OpenCV2.1\bin\cxcore210d.dll'
I solved it by:
Linker -> Input -> Additional Dependencies add: 'cv210.lib; cxcore210.lib; highgui210.lib;'
instead of adding : 'cv210d.lib; cxcore210d.lib; highgui210d.lib;'