安装 C/C++ Windows 上的库

发布于 2024-08-19 14:52:21 字数 454 浏览 10 评论 0原文

我现在正在学习(好吧,正在尝试)C,但我仅限于在 Windows XP 中工作。我已经成功地设置并学习了如何使用 Emacs,并且可以使用 gcc 编译简单的 C 程序(同样来自 Emacs!),但我已经到了想要安装 SDL 之类的东西来玩的地步与它。

事实是,SDL 的安装说明表明,在使用 MingW 的 Win32 环境中,我需要使用 MSYS 运行 ./configure 和 make/make install 来安装 SDL,就像在 Linux 上所做的那样。我注意到,当我解压 SDL-dev 包时(抱歉,忘记了确切的名称),其中有与 MinGW 目录中的文件夹相对应的文件夹(SDL/include -> MinGW/include)。

我是否正确地说所有 ./configure 和 make 命令所做的都是将这些文件从一个目录移动到另一个目录?我难道不能手动移动这些文件,从而省去安装和配置 MSYS 的麻烦(说实话,这让我很困惑)吗?

I'm studying (well, trying to) C right now, but I'm limited to working in Windows XP. I've managed to set up and learn how to use Emacs and can compile simple C programs with gcc (from Emacs no less!), but I'm getting to the point where I'd like to install something like SDL to play around with it.

The thing is that the installation instructions for SDL indicate that, on a Win32 environment using MingW, I would need to use MSYS to run ./configure and make/make install to install SDL, like one would do on Linux. I noticed that when I unzipped the SDL-dev package (forgot the exact name, sorry) there were folders there that corresponded to a folder in the MinGW directory (SDL/include -> MinGW/include).

Am I right in saying that all the ./configure and make commands do is move these files from one directory to another? Couldn't I just move those files by hand and spare myself the trouble of installing and configuring MSYS (which, to be honest, confuses me greatly)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

把梦留给海 2024-08-26 14:52:21

构建过程通常是这样工作的:配置脚本找到适当的编译设置(例如要启用哪些功能、所需库的路径、要使用哪个编译器等)并相应地创建一个 Makefile。然后 make 将源代码编译为二进制文件。 make install 将创建的二进制文件、标头和属于库的其他文件复制到适当的位置。

您不能只从源存档中复制文件,因为源存档不包含二进制文件(或在 make 步骤中创建的任何其他文件),因此您要复制的只是标头,它们是还不够使用图书馆。

The build process usually works like this: the configure script finds the appropriate settings for the compilation (like which features to enable, the paths to the required libraries, which compiler to use etc.) and creates a Makefile accordingly. make then compiles the source code to binaries. make install copies the created binaries, the headers, and the other files that belong to the library to the appropriate places.

You can't just copy the files from the source archive, because the source archive does not contain the binary files (or any other files that are created during the make step), so all you'd copy would be the headers, which aren't enough to use the library.

嘴硬脾气大 2024-08-26 14:52:21

在大多数情况下,configure 和 make 将发现您机器的编译器/环境并分别构建合适的二进制文件。因此,不幸的是,将头文件移动/复制到新位置并不容易。

但是,在某些情况下,该库可以是“仅标头”库。这意味着您只需要头文件即可使用它。

我没有使用 MSYS 和 SDL 的经验。但配置和制作的基础知识值得学习(特别是如果您要在非 Windows 环境中编写任何 C/C++ 程序的话。)

In most case, configure and make will discover the compiler/environment of your machine and build the suitable binary, respectively. Therefore, unfortunately, it will not be easy as moving/copying header files to new locations.

However, in some cases, the library can be the "header only" library. Which means you need only header files to use it.

I have no experience with MSYS and SDL. But the basics of configure and make is worth learning (especially if you are going to program any C/C++ in non-Windows environment.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文