tof.h
#include "stdio.h"
void tof();
tof.cpp
#include "tof.h"
#include <iostream>
using namespace std;
void tof()
{
cout<<"OK5"<<endl;
}
生成so 库
gcc tof.cpp -fPIC -shared -o libtof.so-fPIC 编译cpp文件需要
libtof.so 格式必须是libxx.so
testtof.cpp
int main()
{
tof();
}
链接指定文件夹下的so库文件 生成可执行文件
g++ testtof.cpp -L. -ltof -o testtof -Wl,-rpath,/home/zxh/Documents/testtof