如何使用Code :: Blocks链接到库? [英] How do I link to a library with Code::Blocks?

查看:423
本文介绍了如何使用Code :: Blocks链接到库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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 Platform 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 工作。

如果因为某些原因不能工作,您可能需要提供一个不同的名称(例如,库名为 gdi32.lib for MSVC)。

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链接到库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆