C++进阶5:动态库与静态库--类篇
0.前提(文件内容)
(1)test.h
#pragma once
class Test{
public:
Test();
~Test();
void Func(int i);
};
(2)test.cpp
#include <iostream>
#include "test.h"
using namespace std;
Test::Test(){
cout << __func__ << "()" << endl;
}
Test::~Test(){
cout << __func__ << "()" << endl;
}
void Test::Func(int i){
cout << __func__ << "(" << i << ")" << endl;
}
(3)main.cpp
#include "test.h"
int main(){
Test t;
t.Func(100);
}
1、静态库的制作与使用
1.1 创建
(1)编译源文件
g++ -c -o test.o test.cpp
(2)生成静态库
ar -rcs libtest.a test.o
1.2 使用
(1)链接静态库
g++ -o main main.cpp -L. -ltest
或者

本文详细介绍了C++中静态库和动态库的制作与使用过程,包括静态库的创建和链接,动态库的生成与加载,并通过修改test.h, test.cpp及main.cpp展示了具体操作步骤。特别讨论了类的动态链接库,强调其只能用于C++调用,以及如何创建和销毁抽象类对象的接口。"
45168821,2078949,使用MATLAB实现PCNN进行图像特征提取,"['图像处理', '神经网络', 'MATLAB编程', '特征提取', 'PCNN模型']
3万+

被折叠的 条评论
为什么被折叠?



