在MinGW中使用libdl.so [英] Using libdl.so in MinGW

查看:791
本文介绍了在MinGW中使用libdl.so的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在MinGW中生成一个dll文件,为了做到这一点,我有几个对象依赖关系,我的一个对象依赖关系是libdl.so,我将这个对象添加到unix中,简单地如下:

  g ++ xx.o yy.o /usr/lib/libdl.so -o module.so 

但在MinGW中,我不知道如何添加此对象。任何想法?

解决方案

有一个 libdl的MinGW端口,可以像Unix一样使用。来自网站的引用:


此库为POSIX和SUS中指定的dlfcn实现包装,围绕动态链接库函数Windows API。



它需要MinGW来构建。



您可以获取预构建的二进制文件gcc 3.4.5)和下载部分的捆绑源代码。


以下命令构建并安装在标准MinGW安装(从MinGW shell运行):



./ configure --prefix = / --libdir = / lib --incdir =包括&&制作&& make install



要将库编译为DLL,请使用以下命令:



g ++ -shared xx.o yy.o -ldl -o module.dll


I want to generate a dll file in MinGW, I have several object dependencies in order to do that, one of my object dependencies is libdl.so, I add this object in unix simply as :

g++ xx.o yy.o /usr/lib/libdl.so -o module.so

but in MinGW, I don't have any idea how to add this object. any ideas?

解决方案

There is a MinGW port of libdl that you can use just like under Unix. Quote from the website:

This library implements a wrapper for dlfcn, as specified in POSIX and SUS, around the dynamic link library functions found in the Windows API.

It requires MinGW to build.

You may get pre-built binaries (with MinGW gcc 3.4.5) and a bundled source code from the Downloads section.

The following commands build and install it in a standard MinGW installation (to be run from your MinGW shell):

./configure --prefix=/ --libdir=/lib --incdir=/include && make && make install

To compile your library as a DLL, use the following command:

g++ -shared xx.o yy.o -ldl -o module.dll

这篇关于在MinGW中使用libdl.so的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆