在另一个库(SDL和Eclipse)的基础上构建一个新的库 [英] Building a new library on top of another library (SDL and Eclipse)

查看:207
本文介绍了在另一个库(SDL和Eclipse)的基础上构建一个新的库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用SDL开发一个项目。我觉得很多我的代码可以/应该可以重用于任何其他项目,我可以采取。

I am working on a project with SDL. I feel like a lot of my code could/should be reusable for any other projects I might want to take on.

我要开始一个库项目,但我不知道如何链接到SDL库。

I was going to start a library project, but I don't know how to go about linking to the SDL libraries.

通常,我去项目设置并编辑Mingw32链接器包括库(ming32,SDLmain和SDL)。但是链接器不会显示在设置中。

Usually, I go to Project Settings and edited Mingw32 Linker to include the libraries (ming32, SDLmain, and SDL). But the linker does not show up in the settings.

所以我的问题:

因为构建库只是一个编译操作?

Is there no linker settings because building a library is only a compiling operation?

一般来说,是否可以在现有库之上构建库?也就是说,使用SDL函数和stucts写我的库。

And in general, is it possible to build a library on top of the existing libraries? That is, write my library using SDL functions and stucts. Or would I have to get the source code and rebuild entirely with my code included?

还有,在这个实例中共享与静态的建议?

Also, advice on shared vs. static in this instance?

(另外,关于学习更多关于编译器和链接器等的信息的任何建议,我通过学校中的数据结构,但不能更远)

(Also, any advice for where to go about learning more about compilers and linkers and such. I got through data structures in school but no farther)

推荐答案

作为介绍,你必须区分非常好的静态库和动态库,他们是完全不同的野兽...说,对你的问题:

As an introduction, you have to distinguish very well static library from dynamic ones, they are completely different beasts... said that, to your questions:


是否没有链接器设置,因为构建库只是一个编译操作?

Is there no linker settings because building a library is only a compiling operation?

我想你在这种情况下创建一个静态库。静态库只是在构成源代码树的所有单个目标文件(即由编译器生成的 .o 文件)的单个目标文件中的集合。

I guess you are creating a static library in this case. A static library is simply the collection in one single object file of all the individual object files (i.e., the .o files produced by the compiler) that make up your source tree. No more, no less.

使用静态库,您不需要指定哪些是依赖项,因为可以理解它是在编译最终可执行文件时您的库将与其依赖的所有其他库链接。因此,只有在那个时候(最终可执行构建),将检测到任何缺少的符号,并且所有其他库必须可用。

With a static library you don't need to specify which are the dependencies, since it is understood that it is when compiling the final executable that your library will be linked with all the other libraries that it depends upon. Therefore it is only at that time (final executable build) that any missing symbol will be detected, and all other libraries must be available.

共享库),是一个可执行文件,嵌入它依赖的所有静态库。它也可以有其他共享库的外部依赖,不会被嵌入。

A shared library (also dynamic library), is an executable file that embeds all the static libraries that it depends upon. It can also have external dependencies with other shared library, which would not be embedded.


一般来说,在现有的图书馆之上?也就是说,使用SDL函数和stucts写我的库。或者,我必须获取源代码,并完全重新编译我的代码吗?

And in general, is it possible to build a library on top of the existing libraries? That is, write my library using SDL functions and stucts. Or would I have to get the source code and rebuild entirely with my code included?

这是完全可能的,无论是静态和动态图书馆。

It is perfectly possible, both for static and dynamic libraries.


此外,此实例中的共享与静态建议吗?

Also, advice on shared vs. static in this instance?

在这种情况下,不可能建议,因为你没有指定足够的信息。
看看这个:何时使用动态库和静态库< a>和,以制定一种指南。

In this instance it is not possible to advice, because you don't specify enough information. Look at this: When to use dynamic vs. static libraries, and this, to have a sort of guideline.

(另外,关于学习更多关于编译器和链接器等的信息的建议,我在学校通过了数据结构,但不能更远)

(Also, any advice for where to go about learning more about compilers and linkers and such. I got through data structures in school but no farther)

我认为上面的两个链接给你足够的信息。如果您想进一步了解详情,可以从此维基百科文章开始,从那里浏览。

I think that the two links above give you plenty of information. If you want to further go into details, you could start from this wikipedia article and browse from there.

这篇关于在另一个库(SDL和Eclipse)的基础上构建一个新的库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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