当前位置:网站首页>静态库和动态库
静态库和动态库
2022-07-02 06:27:00 【programmercherry】
Linux系统下 程序运行的三种方式
直接运行
g++ main.cpp src/swap.cpp -Iinclude -Wall -std=c++11 -o a.out
./a.out
链接静态库生成可执行文件
// 进入src目录下
cd src
// 汇编 生成swap.o文件
g++ swap.cpp -c -I../include
// 生成静态库 libswap.a
ar rs libswap.a swap.o
// 回到上级目录
cd ..
// 链接 生成可执行文件 static_main
g++ main.cpp -Iinclude -Lsrc -o static_main
// 运行可执行文件
./static_main
链接动态库生成可执行文件
// 进入src目录下
cd src
// 生成目标文件,fPIC创建与地址无关的编译程序(pic,position independent code),为了能够在多个应用程序间共享。
g++ swap.cpp -I../include -c -fPIC
// 生成动态库 libswap.so
g++ -shared -o libswap.so swap.o
// 上面两个步骤可以合并成一个命令 g++ swap.cpp -I../include -fPIC -shared -o libswap.so
// 回到上级目录
cd ..
// 链接 生成可执行文件 dynamic_main
g++ main.cpp -Iinclude -Lsrc -lswap -o dynamic_main
// 运行可执行文件
LD_LIBRARY_PATH=src ./dynamic_main
边栏推荐
猜你喜欢
【Random Erasing】《Random Erasing Data Augmentation》
【学习笔记】反向误差传播之数值微分
【Mixed Pooling】《Mixed Pooling for Convolutional Neural Networks》
Hystrix dashboard cannot find hystrix Stream solution
open3d学习笔记四【表面重建】
How do vision transformer work? [interpretation of the paper]
[learning notes] matlab self compiled Gaussian smoother +sobel operator derivation
【学习笔记】Matlab自编高斯平滑器+Sobel算子求导
Implementation of yolov5 single image detection based on pytorch
【Cascade FPD】《Deep Convolutional Network Cascade for Facial Point Detection》
随机推荐
MoCO ——Momentum Contrast for Unsupervised Visual Representation Learning
[binocular vision] binocular correction
open3d学习笔记二【文件读写】
服务器的内网可以访问,外网却不能访问的问题
【FastDepth】《FastDepth:Fast Monocular Depth Estimation on Embedded Systems》
In the era of short video, how to ensure that works are more popular?
【Wing Loss】《Wing Loss for Robust Facial Landmark Localisation with Convolutional Neural Networks》
联邦学习下的数据逆向攻击 -- GradInversion
【双目视觉】双目矫正
[mixup] mixup: Beyond Imperial Risk Minimization
业务架构图
What if the notebook computer cannot run the CMD command
【Paper Reading】
【BiSeNet】《BiSeNet:Bilateral Segmentation Network for Real-time Semantic Segmentation》
Embedding malware into neural networks
将恶意软件嵌入到神经网络中
Income in the first month of naked resignation
Thesis writing tip2
TimeCLR: A self-supervised contrastive learning framework for univariate time series representation
JVM instructions