c++动态链接

来源:互联网 发布:电脑模拟笛子软件 编辑:程序博客网 时间:2024/05/17 08:30

hello.h

void hello();
hello.cpp

#include "hello.h"#include <iostream>using namespace std;void hello(){  cout<<"hi"<<endl;}

test.cpp

#include "hello.h"int main(){  hello();}

编译链接

g++ hello.cpp -fpic -shared -o libhello.sog++ test.cpp -L. libhello.so -o test