g++ 动态库的编译及使用
#ifndef __HELLO_H_
#define __HELLO_H_ void print(); #endif
#include "hello.h"
#include <iostream>
using namespace std; void print() {
cout << "hello world" << endl;
}
将上面的 cpp 文件编译为动态库:
g++ hello.cpp -fPIC ishared -o libhello.so
#include "hello.h"
#include <iostream>
using namespace std; int main() {
print();
cout << "hello" << endl;
return ;
}
将 main.cpp 与 libhello.so 链接成一个可执行文件
g++ main.cpp -L. -lhello -o main
g++ 动态库的编译及使用的更多相关文章
- Linux动态库的编译与使用 转载
http://hi.baidu.com/linuxlife/blog/item/0d3e302ae2384d3a5343c1b1.html Linux下的动态库以.so为后缀,我也是初次在Linux下 ...
- Linux动态库的编译与使用
转载: http://hi.baidu.com/linuxlife/blog/item/0d3e302ae2384d3a5343c1b1.html Linux下的动态库以.so为后缀,我也是初次在Li ...
- Linux上静态库和动态库的编译和使用
linux上静态库和动态库的编译和使用(附外部符号错误浅谈) 这就是静态库和动态库的显著区别,静态库是编译期间由链接器通过include目录找到并链接到到可执行文件中,而动态库则是运行期间动态调用,只 ...
- g++动态库静态库混合链接
今天编译一个程序时报错: g++ -static -o echo.fcgi echo_adaptor.o echo.o -L/usr/local/lib/ -lfastcgipp -L/usr/lib ...
- Linux 动态库的编译和使用
1. 动态链接库简介 动态库又叫动态链接库,是程序运行的时候加载的库,当动态链接库正确安装后,所有的程序都可以使用动态库来运行程序.动态库是目标文件的集合,目标文件在动态库中的组织方式是按特殊的方式组 ...
- windows下sqlite3静态库和动态库的编译
1.下载sqlite3源码:http://www.sqlite.org/download.html 主要是sqlite-amalgamation-XXXXXXX.zip.sqlite-dll-win3 ...
- Windows下动态库的编译以及调用
1.MFC下生成动态库 1>显式调用 在.cpp文件里添加接口函数 int sum(int a,int b) { return a + b; } int sub(int a,int b) { r ...
- Linux动态库的编译与使用 转载【转】
转自:http://www.cnblogs.com/leaven/archive/2010/06/11/1756294.html http://hi.baidu.com/linuxlife/blog/ ...
- linux上静态库和动态库的编译和使用(附外部符号错误浅谈)
主要参考博客gcc创建和使用静态库和动态库 对于熟悉windows的同学,linux上的静态库.a相当于win的.lib,动态库.so相当于win的.dll. 首先简要地解释下这两种函数库的区别,参考 ...
随机推荐
- 跨域 XMLHttpRequest对象
XMLHttpRequest对象是ajax编程的基础,用于发送请求(数据)与服务端进行交互. 目前主流浏览器都内置了XMLHttpRequest对象. 浏览器会使用XMLHttpRequest对象来创 ...
- Spring Cloud与Spring Boot版本匹配关系
Spring Cloud是什么? “Spring Cloud provides tools for developers to quickly build some of the common pat ...
- python字符串之split
函数:split() Python中有split()和os.path.split()两个函数,具体作用如下:split():拆分字符串.通过指定分隔符对字符串进行切片,并返回分割后的字符串列表(lis ...
- K3 WISE 开发插件《SQL语句WHERE查询-范围查询/模糊查询》
0.存储过程开头变量定义 @FBeginDate varchar(10), --单据起始日期 @FEndDate varchar(10), --单据截止日期. @FItemID varchar(50) ...
- WCF 配置App.Config
<system.serviceModel> <bindings> <basicHttpBinding> <binding name="/> & ...
- 使用python解决算法和数据结构--使用栈实现进制转换
可以将10进制数据转换成2进制,8进制,16进制等. 晚上练练算法和数据结构哈. # coding = utf-8 class Stack: def __init__(self): self.item ...
- python多线程之t.setDaemon(True) 和 t.join()
0.目录 1.参考2.结论 (1)通过 t.setDaemon(True) 将子线程设置为守护进程(默认False),主线程代码执行完毕后,python程序退出,无需理会守护子线程的状态. ...
- Redis主从实战
为了提升redis高可用性,除了备份redis dump数据之外,还需要创建redis主从架构,可以利用从将数据库持久化,(我们所说的数据持久化将是将数据保存到写磁盘上,保证不会因为断电等因素丢失数据 ...
- python3改版后的特征
1.原始数据类型和运算符 # 整数 3 # => 3 # 算术没有什么出乎意料的 1 + 1 # => 2 8 - 1 # => 7 10 * 2 # => 20 # 但是除法 ...
- Linux read line
cat ./port_list|while read linedo done