Search code examples
cygwinshared-libraries

Correct "cannot open shared object file" error, but incorrect file reported in Cygwin?


In Cygwin, I have an executable linked to shared libraries, for the sake of the question cygA.dll and cygB.dll (and more, but not relevant here). To my knowledge one should use PATH for shared library paths in Cygwin, which is where I had cygA.dll on already. I then tried to run the executable, expecting an error that cygB.dll could not be found. To my surprise, I got error while loading shared libraries: cygA.dll: cannot open shared object file: No such file or directory

Inspecting with ldd showed no entry of either .dll, but cygcheck correctly reported cygcheck: track_down: could not find cygB.dll

I also have a different executable with the same shared link to cygA.dll, which ran without issue. Upon putting the path to cygA.dll on the PATH, my new executable also runs without issue. So Cygwin could not find cygB.dll but incorrectly reported cygA.dll as the missing one. This could be painful for a large project ... is this expected behavior, or a bug? In the latter case, a bug of what? Should I report it to Cygwin itself?


Solution

  • If a secondary level DLL is missing cygwin see only the failure of loading the first level DLL. Windows does not pass the info

    you can have the corrent info using strace EG:

    $ cygcheck gm.exe
    Found: D:\cygwin64\bin\gm.exe
    D:\cygwin64\bin\gm.exe
      D:\cygwin64\bin\cygwin1.dll
        C:\WINDOWS\system32\KERNEL32.dll
          C:\WINDOWS\system32\ntdll.dll
          C:\WINDOWS\system32\KERNELBASE.dll
      D:\cygwin64\bin\cygGraphicsMagick-3.dll
        D:\cygwin64\bin\cygbz2-1.dll
    ...
    
    $ mv cygbz2-1.dll cygbz2-1.dll-bk
    
     $ strace -o /tmp/gm.strace /usr/bin/gm.exe --help
    D:/cygwin64/bin/strace.exe: error while loading shared libraries: ?: cannot open
     shared object file: No such file or directory
    

    But windows correctly provides a popup info:

    enter image description here