FPC can't link DLL directly lazarus / 62-General ---------------------------------------------------------------------- jiaxing2 · 2020-05-12 10:23 I tried to link sgl64.dll directly. sgl64.dll is compiled by Pelles C. http://perso.numericable.fr/hserindat/sgl/ Even after I contact and get sgl64.dll compiled by MinGW, it still can't link. It always ended up with Illegal COFF format error. I found I have to create an .a import library for it in other to link the DLL. I think this is a bug. As on Linux, I can link .so library with no problem. FPC version is 3.0.4 shipped with Lazarus 64 bit on Windows 7. ---------------------------------------------------------------------- marcov · 2020-05-12 10:33 - no way to reproduce the problem. You show no code. Most notably the external declarations. (*) - not really excluding that you are accidentally using the 32-bit compiler. (*) On windows, external declarations should have a NAME part and contain the name of the dll.  On Linux just "external"  is enough. The reason for that Linux dynamic linker searches all libraries for a symbol, Windows has something called linker namespaces, in that it only searches for a symbol in a given library (thus allowing multiple occurrences of the same name in differing libraries) Probably if you fix the declaration, the importlibrary parts will be auto-generated. FPC hasn't required importlibraries since before 2000. (p.s. I accidentally appended your post with the above two lines. Moderator only mistake. I fixed it) ---------------------------------------------------------------------- jiaxing2 · 2020-05-12 17:30 Quote from: marcov on May 12, 2020, 12:33:40 pm(*) On windows, external declarations should have a NAME part and contain the name of the dll.  On Linux just "external"  is enough. So it's the problem. I only h2pas -d option. Now I have to use -D -l "libname" instead.