QT 載入外部CAN dll庫

2021-08-05 21:21:13 字數 1016 閱讀 2022

顯示呼叫
typedef dword (*funopen)(dword,dword,dword); //定義函式指標,以備呼叫
funopen open=(funopen)lib.resolve("vci_opendevice"); //援引 vci_opendevice() 函式
另外一種方
typedef dword(__stdcall vci_opendevice)(dword devicetype,dword deviceind,dword reserved);
vci_opendevice *popendevice;
popendevice = (vci_opendevice *)lib.resolve("vci_opendevice");

隱式呼叫
pro

檔案增加:

libs +=c:/users/administrator/desktop/qt/workdesign/cantcptest/build-cantcptest-desktop_qt_5_7_0_mingw_32bit-debug/debug/controlcan.dll

includepath+=c:/users/administrator/desktop/qt/workdesign/cantcptest/cantcptest/head/
這種方法不太好,但是如果專案檔案位置更改就編譯不通過必須要改變上面的路徑。可使用下面的方法
先把dll和lib以及h檔案三大件兒拷貝到專案路徑下
在專案上右鍵新增庫,新增外部庫   去掉為debug版本新增'd作為字尾。然後包含標頭檔案呼叫函式庫。

Qt動態庫載入

首先建立動態庫,在 下生成了名字為lib專案名.so lib專案名.so.1 lib專案名.so.1.0lib專案名.so.1.0.0的動態庫檔案,除了lib專案名.so.1.0.0 其他都是鏈結。在使用的專案的 檔案中,新增以下文字 是生成的專案名字。template 是這個專案的型別模板,代表是...

QT中將外部字型載入到程式中

在qt開發中,會遇到有些電腦沒安裝某種或者某一種字型,又不能每台電腦去安裝。這時候,我們就要考慮在程式中將外部字型檔案當做資源一樣載入,保證顯示效果一致。main.cpp include widget.h include include include include include qstring...

Qt 呼叫外部C動態庫

先寫乙個測試程式 test.h include test test.c include test printf hello,1234 做成動態庫,gcc o fpic shared o libtest.so test.h test.c 將libtest.so和test.h拷貝到qt的工程目錄,在pr...