linux c dynamic library programming
2014-07-31 18:58
351 查看
.h
.c
.c
gcc -ldl dltest.c -o dltest.exe
./dltest.exe
#ifndef __TESTDL #define __TESTDL #ifdef __cplusplus extern "C" { #endif int (*add)(int,int,int*); //int addint(int,int,int*); #ifdef __cplusplus } #endif #endif
.c
//#include "testdl.h" int addint(int a,int b,int* c){ *c = a + b; return 0; }
.c
#include <stdlib.h> #include <stdio.h> #include <dlfcn.h> //#include "testdl.h" int main(int argc,char** argv){ void* handler; int (*add)(int,int,int*); int c = 0; handler = dlopen("./testdl.so",RTLD_LAZY); add = dlsym(handler,"addint"); add(1,2,&c); printf("%d",c); dlclose(handler); return 0; }gcc -shared -fpic testdl.c -o testdl.so
gcc -ldl dltest.c -o dltest.exe
./dltest.exe
相关文章推荐
- Linux System Programming: Talking Directly to the Kernel and C Library [ILLUSTRATED]
- how to compile and link static/dynamic library in linux
- Linux System Programming: Talking Directly to the Kernel and, C Library [ILLUSTRATED] (Paperback) Sep.2007.eBook-BBL
- dynamic linked library on linux
- Dynamic Library Programming Topics
- Static library & dynamic library -- linux系统下的静态库与动态库
- Setting shared (dynamic) library in Eclipse C++ in Linux
- How to Use the Dynamic Link Library in C++ Linux (C++调用Delphi写的.so文件)
- Linux Dynamic Shared Library && LD Linker
- Linux System Programming: Talking Directly to the Kernel and C Library
- explicit call dynamic library in windows and linux platform
- linux static and dynamic library
- Linux learning jottings(2)-static or dynamic library
- library linking on LINUX
- 手工解析选项参数问题《Linux Programming by Example:The Fundamentals》chapter2,exercise
- Linux Serial Programming HOWTO - 串口通讯编程
- 动态链接库(Dynamic Link Library)
- The Linux Kernel Module Programming Guide(1)
- Finding the Longest Nondecreasing Subsequence of A Given Sequence:An analysis of dynamic programming