当您创建 C++ 时共享库是否只需要附加您的库所依赖的标头?
所以我创建了一个库。我想使用共享的 ffmpeg 库。在带有 xcode 的 mac 操作系统上。我使用 premake4 创建项目文件。我应该将共享库连接到我的项目还是只连接包含?
So I create a library. I want to use shared ffmpeg libs. On mac os with xcode. I create project file with premake4. Shall I connectshared libs to my project or shall I only connect includes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我正确理解您的问题,您是在问您是否需要共享库和标头,或者仅需要标头才能使您的项目正常工作。
你两者都需要。库通常是头文件中声明的函数和类的实际代码。您的项目将在仅存在标头的情况下编译得很好,但除非库或共享库中有相应的代码,否则您可以指望链接器错误。
我不得不说我不熟悉 OS X 上的实际构建过程,但我相信上述内容是任何 C/C++ 项目所固有的,无论操作系统如何。
另外,由于您可能正在使用标准库,因此您可能会觉得您所做的只是
#include
标头(iostream
、stdio.h)。 h
等),但库仍然存在,并且已由您的 IDE 默认添加。If I understand your question correctly, you're asking if you need both the shared libraries and the headers, or just the headers, for your project to work.
You need both. The libraries are generally were the actual code for the functions and classes declared in the headers lives. Your project will compile just fine with only the headers present, but unless there is corresponding code in a lib or shared lib, you can count on linker errors.
I have to say I'm not familiar with the actual build process on OS X, but I believe the above is inherent to any C/C++ project regardless of OS.
Also, since you're probably working with the Standard Library you might have the impression that all you're doing is
#include
ing headers (iostream
,stdio.h
, etc), but the libraries are still there and have been added by default by your IDE.