DLL那些事兒(一)

2021-10-18 21:01:37 字數 984 閱讀 3289

我們將討論:

我們不討論:

什麼是動態庫:

大多數動態庫的副檔名都是 「.dll」

// hello.cpp

extern "c" char const* __cdecl getgreeting()

使用vs構建工具進行編譯和鏈結,我們使用/c選項告訴編譯器只進行編譯

使用/dll選項告訴鏈結器不要構建exe(預設選項)而是構建乙個dll, 使用/noentry選項使得鏈結時去掉一些不必要的東西,簡化匯出的dll,使用/export選項告訴鏈結器「getgreeting」是dll中公開的介面

f:\learning\vsproject\dllproject>cl /c hello.

cpphello.

cppf:\learning\vsproject\dllproject>link hello.obj

/dll

/noentry

/export:getgreeting

正在建立庫 hello.lib 和物件 hello.exp

這樣我們就得到了hello.dll,接下來我們使用這個動態庫

// printgreeting.cpp

#include #include int main()

編譯並執行這個cpp,我們看到這個程式正常工作,並且輸出了「hello, c++ programmers!」

f:\learning\vsproject\dllproject>cl printgreeting.

cpp/out:printgreeting.exe

printgreeting.obj

f:\learning\vsproject\dllproject>printgreeting.exe

hello, c++ programmers!

SQL那些事兒(一)

比如這樣 insert into student id,code,name,sql values 1 001 張三 insert into student id values 1 where name 李四 這樣肯定會報錯,因為 會影響外面sql語句 這時我們要修改為這樣 insert into s...

vue那些事兒(一)

開發環境版本,包含了有幫助的命令列警告 script 或者 生產環境版本,優化了尺寸和速度 script 每個vue應用都需要通過例項化vue來實現 語法格式如下 var vm newvue 舉例 vue det site h1 url h1 h1 div var vm newvue methods...

筆試的那些事兒(一)

今天學校組織了2011屆畢業生招聘會,到會公司有天津企業將近300家,非天津企業將近200家。雖然看數字挺龐大的,其實裡邊沒有多少好公司。去了以後有點後悔沒有籤富士康,這個就不提了。還是講講今天招聘會吧!早晨7點起床,洗漱完畢後,重新去列印了10份簡歷。8點坐649 學校比較偏,算是校車吧 去本部南...