MinGW libraries issues

2019-06-08 19:35发布

问题:

In the process of porting a C project from Linux to Windows

Have installed MinGW

Have compiled my shared library using a Makefile

This produces libExample.so

Now I'm trying to link this shared library to a test harness so I can see if everything is working as expected

In the harness Makefile I specify the location of the library, e.g. -LE:/libExample_dir and the name of the library -lExample

but its complaining it cannot find the library, i.e. linker is failing with cannot find -lExample - is there some difference with windows regarding .so and .dll or perhaps pathnames that I am missing?

回答1:

You need to fix the make file so shared libraries are generated with a .dll extension.

If I had to guess, I'd say that while renaming the generated file is enough to make the linker happy, the loader still expects the .so extension because that's the name that was compiled in...



回答2:

Using MinGw to compile C code to produce a shared library, remember to rename the output from libExample.so to libExample.dll otherwise the linker will fail to find your library



标签: c mingw