Issue
In my working directory there are main.c and a folder named lib with libtest.dll in it.
I use
to compile, and the compilation process is no problem (no warning and error). But when i run a.exe the system remind
D:/MYSY2/home/user/code/a.exe: error while loading shared libraries: libtest.dll: cannot open shared object file: No such file or directory
So why the library can be found when compiling but not when running?
Solution
Shared libraries on Windows are .dll
files and the are located by looking in the same folder as the running .exe
file, or if that doesn't work by looking in the locations specified by the PATH
environment variable.
So the best solution is to copy the .dll
file(s) in the same location as the .exe
file(s).
For distribution of your application you can use copypedeps -r
from https://github.com/brechtsanders/pedeps to copy the .exe file along with any dependency .dll
files, in case you are not certain which files are needed.
Answered By - Brecht Sanders Answer Checked By - Robin (WPSolving Admin)