封裝動態庫dll和靜態庫lib(企業級應用例項)

2021-10-13 05:38:25 字數 3944 閱讀 1481

結合彎管點雲提取流程**,實踐動態庫封裝

pcl庫及相關過程配庫

屬性-常規-目標檔名 xttubedepart_64d (debugx64)

屬性-常規-目標檔名 xttubedepart_64(relea***64)

1、建立xttubedepartplatform.h

2、命名規範:_____platform.h 平台檔案

3、此檔案控制動態dynamic、介面exports、引用此標頭檔案時鏈結lib

#pragma once

#ifdef xttubedepart_dynamic

//預處理命令中是否存在(存在代表動態庫)

#ifdef xttubedepart_exports

//預處理命令中是否存在(存在代表輸出動態庫)

# define xttubedepart_api __declspec(dllexport)

#else

# define xttubedepart_api __declspec(dllimport)

#endif

#else

#define xttubedepart_api

#endif

#ifndef xttubedepart_exports

//預處理命令中是否不存在(不存在才進行鏈結,此時是動態庫輸入)

#ifdef _debug

//是否是debug模式

#ifdef xttubedepart_dynamic

//是否是動態庫

#pragma comment(lib, "xttubedepart_64d.lib")

#pragma message("*****=== automatically linking with xttubedepart_64d.lib")

#else

#pragma comment(lib, "xttubedepart_64ds.lib")

#pragma message("*****=== automatically linking with xttubedepart_64ds.lib")

#endif

//xttubedepart_dynamic

#else

#ifdef xttubedepart_dynamic

#pragma comment(lib, "xttubedepart_64.lib")

#pragma message("*****=== automatically linking with xttubedepart_64.lib")

#else

#pragma comment(lib, "xttubedepart_64s.lib")

//release版本靜態庫

#pragma message("*****=== automatically linking with xttubedepart_64s.lib")

#endif

//xttubedepart_dynamic

#endif

//_debug

#endif

//xttubedepart_exports

1、建立xttubedeparth

2、命名規範:_____.h 最終專案引用檔案

3、此檔案包含:專案所需標頭檔案、各個函式、結構體、類

#pragma once

#include

"xttubedepartplatform.h"

#include

vtk_module_init(vtkrenderingopengl)

#include

#include

#include

#include

#include

#include

//注意類給介面

class

xttubedepart_api tubedepart};

//注意函式給介面

void xttubedepart_api createcloudfromtxt

(const std::string& file_path, pcl::pointcloud

::ptr cloud)

;void xttubedepart_api splitpipecloud

(pcl::pointcloud

::ptr &cloud, pcl::pointcloud

::ptr &outpipecloud)

;

#include

"xttubedepartplatform.h"

#include

"xttubedepart.h"

void

createcloudfromtxt

(const std::string& file_path, pcl::pointcloud

::ptr cloud)

file.

close()

;}void

splitpipecloud

(pcl::pointcloud

::ptr &cloud, pcl::pointcloud

::ptr &outpipecloud)

//---------------------歐式聚類---------------------------//

std::vectoreceinlier;

pcl::search::kdtree

::ptr tree

(new pcl::search::kdtree);

pcl::euclideanclusterextraction ece;

ece.

setinputcloud

(n_sorcloud)

; ece.

setclustertolerance(2

);//設定近鄰搜尋的搜尋半徑為2cm

ece.

setminclustersize

(500);

ece.

setmaxclustersize

(200000);

//設定乙個聚類需要的最大點數目

ece.

setsearchmethod

(tree)

;//設定點雲的搜尋機制

ece.

extract

(eceinlier)

;//-----------------聚類結果中提取彎管類----------------------//

for(

int i =

0; i < eceinlier.

size()

;++i)

//----------------提取多個滿足條件的點雲----------------//

eceinlierextend.

insert

(eceinlierextend.

end(

), eceinlier[i]

.indices.

begin()

, eceinlier[i]

.indices.

end())

;copypointcloud

(*sorcloud, eceinlierextend,

*outpipecloud)

;//按照索引提取點雲資料

}}

#include

"../xttubedepart/xttubedepart.h"

void

test()

intmain()

C 中動態庫( dll)和靜態庫 lib

最近,做一些程式的封裝,就了解了c 中封裝動態庫 dll 和靜態庫 lib 的方法,以及兩種庫呼叫時異同,現在記錄下,後續有新的理解,會繼續更新 動態庫 dll 動態庫又稱 動態鏈結庫 英文為dll,是dynamic link library 的縮寫形式,dll是乙個包含可由多個程式同時使用的 和資...

靜態庫Lib和動態庫Dll

1.概論 1.什麼是靜態連線庫,什麼是動態鏈結庫 靜態鏈結庫與動態鏈結庫都是共享 的方式,如果採用靜態鏈結庫,則無論你願不願意,lib 中的指令都全部被直接包含在最終生成的 exe 檔案中了。但是若使用 dll,該 dll 不必被包含在最終 exe 檔案中,exe 檔案執行時可以 動態 地引用和解除...

靜態庫Lib和動態庫Dll

1.概論 1.什麼是靜態連線庫,什麼是動態鏈結庫 靜態鏈結庫與動態鏈結庫都是共享 的方式,如果採用靜態鏈結庫,則無論你願不願意,lib 中的指令都全部被直接包含在最終生成的 exe 檔案中了。但是若使用 dll,該 dll 不必被包含在最終 exe 檔案中,exe 檔案執行時可以 動態 地引用和解除...