创建.so: 新建一个Qt Creator项目(这里使用QT5.4.2),Libraries -> C++ Library,类型为Shared Library,一路Next,选取模块的时候按需要选择,默认仅选择QtCore模块(如果你要包含UI,必须选择QtGui),我创建的项目名为make_so。 双击打开项目的plugintest_global.h文件,我加入了一行:#include ,在make_so.h中加公共函数声明:int add(int a,int b); cpp中添加:int Make_so::add(int a,int b)函数,然后构建,生成:make_so.h、make_so_global.h、libmake_so.so、libmake_so.so.1、ibmake_so.so.1.0、ibmake_so.so.1.0.0 调用.so: 新建工程 test_so 在工程->右键->Addlibray->external library->next->选择.so目录 platform下选择linux 就行,其他不选 next->完成 在 Test_SO.cpp 文件中添加 make_so.h 在调用外部函数到地方使用如下 Make_so TestAdd; int a = TestAdd.add(2,3); QMessageBox::about(this,tr("提示信息"),QString::number (a,10));
2019-12-21 19:55:50 19KB so使用
1