complie dll for C invocation with GCC
来源:互联网 发布:织梦pc 手机端同步插件 编辑:程序博客网 时间:2024/05/17 01:29
from:http://blog.sina.com.cn/s/blog_4b02b8d001000avi.html
我们通过实例来学习使用gcc编译出dll文件的方法,看下面的例子说明这个过程,共有三个文件:hello.c、dll.h和dll.c。
hello.c#include
#include
int
{
}
其中,hello()函数是动态连接库提供的函数。
dll.h
#ifdef
#define
#else
#define
#endif
EXPORT
dll.c
#include
EXPORT
{
}
三个文件的内容都很简单,无须解释。
编译连接程序
1、编译hello.c
gcc
2、编译dll.c
gcc
注意要使用要使用-DBUILD_DLL来设置宏BUILD_DLL
3、创建dll
gcc
这一步要详细说明一下
-shared参数用来创建共享库,在windows中为dll
-Wl
--out-implib是给连接程序ld使用的,用于创建要连接dll需要的import
4、创建可执行文件
gcc
-L
-lmessage
好了,编译连接完成,运行程序
C:\>hello
Hello!
- complie dll for C invocation with GCC
- gcc complie ffmpeg strange problem
- Complie Apache with VC6.0
- matlib complie C++ with opencv
- [C++] Build Shared libraries with GCC on Linux ---gcc is actually for compile C
- How to compile a C/C++ DLL for 64 bit with Visual Studio?
- GCC for C 热热身
- Useful GCC flags for C
- linker command failed with exit code 1 (use -v to see invocation) Undefined symbols for architecture
- Exception for IOS 1-linker command failed with exit code 1 (use -v to see invocation)
- C language constructor & destructor with GCC
- Qt5 Alpha Complie in XP with Mingw/vs2008
- 解决 ld: library not found for -xxx linker command failed with exit code 1 (use -v to see invocation)
- function invocation with except handling DEMO
- C program for stack with array implementation
- sqlite for Unity with C sharp
- problems with pointer to struct (C# using C dll)
- complie kernel
- 解决Realplayer在Fedora中播放rmvb没声音的问题
- android bitmap
- 孜孜不倦是一种境界
- hadoop学习
- EJB3.0异常总结---javax.ejb.EJBException: Local and Remote Interfaces cannot have duplicate interface for
- complie dll for C invocation with GCC
- 杭电ACM 2035 人见人爱A^B
- linux命令
- Umbraco 5.x被放弃了
- html中文本域的默认值
- ExtJS4.1 desktop桌面图标自动换行
- 14 个在线生成 CSS3 的工具
- android memleak hint
- Hadoop报错:NoRouteToHostException: No route to host