MinGW libraries issues

核能气质少年 提交于 2020-01-03 05:04:06

问题


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



来源:https://stackoverflow.com/questions/9772545/mingw-libraries-issues

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!