linux下生成so库及调用

xiaoxiao2021-02-28  92

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

#include <stdio.h> int main() {      tof(); } 链接指定文件夹下的so库文件 生成可执行文件 g++ testtof.cpp -L. -ltof -o testtof -Wl,-rpath,/home/zxh/Documents/testtof
转载请注明原文地址: https://www.6miu.com/read-97397.html

最新回复(0)