問題描述
C++ GUI 教程:對 TextOut 的未定義引用
我有同樣的問題,但我是編程和 Code::Blocks 的新手,我想使用 GDI32 庫.我該如何安裝它?我很困惑,因為我可以使用 windows.h 標頭,但是諸如 TextOut
之類的某些功能不可用.
I have the same problem, but I'm new to programming and Code::Blocks, and I want to use the GDI32 library. How can I install it? I'm very confused because I can use the windows.h header, but some functions like TextOut
aren't available.
推薦答案
gdi32 庫已經安裝在您的計算機上,沒有它,很少有程序可以運行.您的編譯器(如果安裝正確)通常會附帶一個導入庫,鏈接器使用它來在您的程序和系統中的文件之間進行綁定.(萬一您的編譯器沒有為系統庫提供導入庫,您將需要下載 Microsoft Windows 平臺 SDK.)
The gdi32 library is already installed on your computer, few programs will run without it. Your compiler will (if installed properly) normally come with an import library, which is what the linker uses to make a binding between your program and the file in the system. (In the unlikely case that your compiler does not come with import libraries for the system libs, you will need to download the Microsoft Windows Platform SDK.)
與 gdi32 鏈接:
To link with gdi32:
這將可靠地與 MinGW-gcc 一起用于所有系統庫(如果您也使用任何其他編譯器,它應該可以,但我不能談論我沒有嘗試過的東西).你也可以寫出庫的全名,但是寫libgdi32.a
與gdi32
相比沒有任何優勢,除了更多類型的工作.
如果由于某種原因它不起作用,您可能需要提供一個不同的名稱(例如,對于 MSVC,該庫被命名為 gdi32.lib
).
This will reliably work with MinGW-gcc for all system libraries (it should work if you use any other compiler too, but I can't talk about things I've not tried). You can also write the library's full name, but writing libgdi32.a
has no advantage over gdi32
other than being more type work.
If it does not work for some reason, you may have to provide a different name (for example the library is named gdi32.lib
for MSVC).
對于位于一些奇怪位置或項目子文件夾中的庫,您需要提供正確的路徑名(單擊..."按鈕打開文件選擇對話框).
For libraries in some odd locations or project subfolders, you will need to provide a proper pathname (click on the "..." button for a file select dialog).
這篇關于如何使用 Code::Blocks 鏈接到庫?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!