当前位置:网站首页>Static library and dynamic library
Static library and dynamic library
2022-07-02 08:07:00 【programmercherry】
Linux Under the system Three ways of program operation
Direct operation
g++ main.cpp src/swap.cpp -Iinclude -Wall -std=c++11 -o a.out
./a.out
Link static libraries to generate executables
// Get into src Under the table of contents
cd src
// assembly Generate swap.o file
g++ swap.cpp -c -I../include
// Generate static libraries libswap.a
ar rs libswap.a swap.o
// Go back to the parent directory
cd ..
// link Generate executable files static_main
g++ main.cpp -Iinclude -Lsrc -o static_main
// Run the executable
./static_main
Link dynamic library to generate executable file
// Get into src Under the table of contents
cd src
// Generate target file ,fPIC Create an address independent compiler (pic,position independent code), In order to be able to share among multiple applications .
g++ swap.cpp -I../include -c -fPIC
// Generate dynamic library libswap.so
g++ -shared -o libswap.so swap.o
// The above two steps can be combined into one command g++ swap.cpp -I../include -fPIC -shared -o libswap.so
// Go back to the parent directory
cd ..
// link Generate executable files dynamic_main
g++ main.cpp -Iinclude -Lsrc -lswap -o dynamic_main
// Run the executable
LD_LIBRARY_PATH=src ./dynamic_main
Excellent article : The difference between static library and dynamic library
边栏推荐
- 浅谈深度学习模型中的后门
- Get the width and height of the screen in real time (adaptive)
- 【Batch】learning notes
- (15) Flick custom source
- Matlab数学建模工具
- Global and Chinese market of recovery equipment 2022-2028: Research Report on technology, participants, trends, market size and share
- 力扣方法总结:双指针
- 利用Transformer来进行目标检测和语义分割
- 将恶意软件嵌入到神经网络中
- Global and Chinese market of medicine cabinet 2022-2028: Research Report on technology, participants, trends, market size and share
猜你喜欢
随机推荐
解决jetson nano安装onnx错误(ERROR: Failed building wheel for onnx)总结
Jetson nano installation tensorflow stepping pit record (scipy1.4.1)
Correction binoculaire
【MobileNet V3】《Searching for MobileNetV3》
Network metering - transport layer
【MnasNet】《MnasNet:Platform-Aware Neural Architecture Search for Mobile》
深入理解JVM
利用超球嵌入来增强对抗训练
Global and Chinese market of tillage finishing machines 2022-2028: Research Report on technology, participants, trends, market size and share
Wang extracurricular words
The internal network of the server can be accessed, but the external network cannot be accessed
Feature Engineering: summary of common feature transformation methods
STL速查手册
【雙目視覺】雙目矯正
【Hide-and-Seek】《Hide-and-Seek: A Data Augmentation Technique for Weakly-Supervised Localization xxx》
Programmers can only be 35? The 74 year old programmer in the United States has been programming for 57 years and has not retired
笔记本电脑卡顿问题原因
【Random Erasing】《Random Erasing Data Augmentation》
Prompt 范式简述
力扣方法总结:滑动窗口