为什么必须链接库并设置包含目录

发布于 2024-11-18 03:39:19 字数 222 浏览 3 评论 0原文

嘿,所以我有点困惑为什么,在 msVS++ 2010 中,当所有头文件和 cpp 文件都位于静态库静态库项目中时,您必须包含目录就我而言。

我用 cmake 制作了静态库项目,我被告知将其设置为的源文件与我现在被告知制作包含目录的源文件相同...似乎我有 2 个相同的 cpp 和头文件...除了我的解决方案中静态包含的头文件...为什么?

Hey so i'm a little confused on why, in msVS++ 2010 you have to have include directories when all the headers and cpp files are inside the static libray or static library project in my case.

I made the static library project with cmake, and the source file i was told to set it to is the same i'm now told to make the include directory... it seems like I have 2 of the same cpp and header files.. except ones included statically in my sollution... WHY?

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

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

发布评论

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

评论(2

心欲静而疯不止 2024-11-25 03:39:19

因为VS++在抽象底层实现的同时并没有完全隐藏它。

包含目录和库针对过程的不同阶段,传统上由不同的程序处理。包括预处理器的目录、链接器的库。这些程序现在被称为(或一部分?)VC++,但其界面仍然显示底层结构。

有些系统允许使用编译指示在源代码(以及头文件)中标记所需的库。它们有几个缺点:

  • 非标准

  • 您不能轻松地用另一个库替换库(例如调试/检测/发布、单线程/多线程,...)

Because VS++ while abstracting the underlying implementation does not hide it completely.

Include directories and libraries are targeted at different phase of the process, which are traditionally handled by different programs. Include directories by the preprocessor, libraries by the linker. Those programs are now called (or part of?) VC++, but its interface still shows the underlying structure.

There are systems which allows to mark the needed libraries in the source code (and thus in the header) by the use of pragmas. Those have several disadvantages:

  • non standard

  • you can't as easily substitute libraries by another (say debug/instrumented/release, single thread/multi thread, ...)

你对谁都笑 2024-11-25 03:39:19

头文件告诉您您正在调用的函数。

静态库包含您正在调用的函数的代码,但不包含有关如何调用它们的信息。

Header files tell you about the functions you're calling.

Static libraries include the code of the function you're calling, but not information about how to call them.

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