C ++项目文件????? [英] C++ Project Files?????

查看:64
本文介绍了C ++项目文件?????的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我目前所知道的:


你有一个C ++项目。你有源文件。当你去编译它时,预处理器首先将头文件粘贴到

每个源文件中。


所以现在你有你的.cpp文件全部准备好,没有任何#include

或#define在它们中。


让我们假设这个项目中有2个源文件,a.cpp。并且

" b.cpp"。

2个源文件是单独编译的,指的是函数

和全局变量彼此之间通过外部相互作用。语句通常在头文件中。

。例如,a.cpp和a.cpp。可以在b.cpp中调用函数

只需拥有一个功能原型。


所以你的.cpp都是文件是____________到目标文件中。 (什么
我应该在空白处使用
字?编译?)
所以现在链接器将目标文件连接在一起,现在将wallah连接起来

" a.cpp"和b.cpp分享它们的功能,类定义,

全局变量。


所以我们所看到的是这样的:


..cpp& .hpp - > .cpp - > .o - > .exe

每个源文件都有它的标题放入其中,然后它变成了一个目标文件,然后链接器会收集所有对象文件和

生成一个可执行文件。


----


问题:


库文件到底是什么?我听说一旦你的源文件已被转换为目标文件,链接器就会添加

库文件,然后将其转换为可执行文件。那么到底是什么地方

是库文件?!


----


有人可以请给我是与C ++项目相关的所有

不同文件类型的完整列表,例如:


..cpp源代码文件

..hpp头文件

..o对象文件

我从一本书中学到了C ++,现在我已经掌握了它,

但除了一件事之外,这本书里面没有任何关于C ++项目的实际形式的信息,即。怎么有源文件和头文件

以及链接器如何链接目标文件。

感谢你的时间分配。

-JKop

解决方案

>什么是图书馆文件?我听说一旦你的源

文件被转换成目标文件,链接器就会添加库文件,然后把它变成可执行文件。那么到底是什么
是一个库文件?!




库文件只不过是几个目标文件分组

。一起。


-

Peter van Merkerk

peter.van.merkerk(at)dse.nl


> >什么是图书馆文件?我听说过一旦你的源

文件已经变成目标文件,链接器就会添加库文件,然后把它变成一个可执行文件。那么到底是什么
是库文件?!


库文件只不过是一起分组的几个目标文件。




补充此声明:有两种类型的库:静态

和动态/共享库。彼得写了关于静态的。如果你的系统支持

动态链接,那么还存在第二种类型,它带有比静态更多的信息,特别是它可以指向其他的

它依赖的共享库。从这个意义上说,共享库与可执行文件更相似,可以携带相同类型的信息,比静态库更多.b $ b。这是另一个链接器(运行时链接器)的工作,

加载这些动态库。


库的使用是另一回事。两种库的使用

的设计尽可能相似,特别是对于Unix操作系统。


共享库有另一个有用的属性。它们不仅可以链接编辑(你称之为链接),也可以从你的代码中加载

(Unix: " dlopen()",MS Win32" LoadLibrary()")到
实现通常被称为插件的东西。


干杯,

Philipp。


文章< Gy ********* *********@news.indigo.ie> ;, JKop< NU ** @ NULL.NULL>

写道:

到目前为止,这就是我所知道的:

你有一个C ++项目。你有源文件。当你去编译它时,预处理器首先将头文件粘贴到每个源文件中。

现在你有了你的.cpp。文件全部准备好,没有任何#include
或#define在他们中。


这是一个翻译单位了解这一点非常重要因为

有些东西是可以的,而且有些东西无法在外部访问

翻译单元。

让我们假设这个项目中有2个源文件,a.cpp。和/或b.cpp。

2个源文件是单独编译的,通过extern引用函数
和彼此之间的全局变量。通常在头文件中的语句。例如,a.cpp和a.cpp。可以在b.cpp中调用函数
只需拥有一个功能原型。

所以你的.cpp都是如此。文件是____________到目标文件中。 (我应该在空白处使用什么词?"编译"?)


一般来说它们只是被称为目标文件。

所以现在链接器将目标文件链接在一起,而wallah,现在是a.cpp。和b.cpp分享它们的功能,类定义,全局变量。

所以我们所看到的是这样的:

.cpp& .hpp - > .cpp - > .o - > .exe


源文件includes包含标题,但是这基本上是正确的

我会说...


source - >对象

对象+运行时 - >可执行文件(不仅是.exe而且还有dll')


问题:

库文件到底是什么?


有两种类型的库,一种是源库,只有一个

的模板和函数集合,你可以在很多来源中使用

根据需要添加到您的项目中。 STL是一个源库


另一个通常被称为静态库它是一个目标代码文件,

通常带有.lib或.o extensio 。这是源代码文件

编译成目标代码但未处理可执行格式。

即没有使用未使用的代码。

我听说一旦你的源文件变成目标文件,链接器就会添加库文件,然后把它变成可执行文件。那么到底是什么
是一个库文件?!




只是一个普通的目标文件,但有一个库,你可以添加或删除
$ b来自它的$ b文件/功能。通过使用库,它可以节省大量时间

,因为假设库是经过完全测试的代码。它不需要

来调试它不需要再次编译,等等。


希望这有帮助,


Ron


-

免费下载 - 新版本发布

CodeWarrior开发工作室for HC(S )12微控制器v3.1

提供类似仿真器的功能。调试支持HCS12衍生物
http:/ /www.metrowerks.com/MW/Develop...12/Default.htm

Ron Liechty - MW *** @ metrowerks.com - http://www.metrowerks .com


Here''s what I know so far:

You have a C++ project. You have source files in it. When you go to
compile it, first thing the preprocessor sticks the header files into
each source file.

So now you have your ".cpp" files all ready, without any "#include"
or "#define" in them.

Let''s assume that there''s 2 source files in this project, "a.cpp" and
"b.cpp".

The 2 source files are compiled seperately, referring to functions
and global variables in each other via "extern" statements, which are
usually within header files. For instance "a.cpp" can call a function
in "b.cpp" simply by having a function prototype.

So both your ".cpp" files are ____________ into object files. (what
word should I use in the blank? "compiled"?)

So now the linker links the object files together, and wallah, now
"a.cpp" and "b.cpp" share they''re functions, class definitions,
global variables.

So what we''re looking at is something like this:

..cpp & .hpp -> .cpp -> .o -> .exe
Each source files has it''s headers put into it, then it''s turned into
an object file, then the linker gathers up all the object files and
makes an executable file.

----

QUESTIONS:

What the hell is a library file? I''ve heard that once your source
files have been turned into object files, the linker then adds
library files, and then turns it into an executable. So what the hell
is a library file?!

----

Could someone please give me a full complete list of all the
different file types associate with a C++ project, eg.:

..cpp Sourcecode File
..hpp Header File
..o Object File
I learned C++ from a book and I pretty much have it by the reins now,
but except for one thing, the book had nothing in it about the actual
form of a C++ project, ie. how there''s source files and header files
and how the linker links object files.
Thanks allot for your time.
-JKop

解决方案

> What the hell is a library file? I''ve heard that once your source

files have been turned into object files, the linker then adds
library files, and then turns it into an executable. So what the hell
is a library file?!



A library file is nothing more than a couple of object files grouped
together.

--
Peter van Merkerk
peter.van.merkerk(at)dse.nl


> > What the hell is a library file? I''ve heard that once your source

files have been turned into object files, the linker then adds
library files, and then turns it into an executable. So what the hell
is a library file?!

A library file is nothing more than a couple of object files grouped
together.



To supplement this statement: There are two types of libraries: Static
and dynamic / shared ones. Peter wrote about static ones. If your system supports
dynamic linking, there also exists the second type, which carries much
more information with it than the static ones, especially it can point to other
shared libraries it depends on. In this sense, shared libraries are more similar
to executables, which can carry the same kind of information with them,
than to static libraries. It''s the job of another linker, the run-time linker, to
load these dynamic libraries.

The usage of libraries is a different story. The usage of both kinds of libraries
is designed to be as similar as possible, especially with Unix operating systems.

Shared libraries have another, useful property. They not only can be
link-edited (what you''ve called "linked") against, they can also be loaded
from within your code (Unix: "dlopen()", MS Win32 "LoadLibrary()") to
realize what often is referred to as "plugins".

Cheers,
Philipp.



In article <Gy******************@news.indigo.ie>, JKop <NU**@NULL.NULL>
wrote:

Here''s what I know so far:

You have a C++ project. You have source files in it. When you go to
compile it, first thing the preprocessor sticks the header files into
each source file.

So now you have your ".cpp" files all ready, without any "#include"
or "#define" in them.
This is a translation unit It is important to understand this because
some things can be and some can not beaccessed externally to the
translation unit.
Let''s assume that there''s 2 source files in this project, "a.cpp" and
"b.cpp".

The 2 source files are compiled seperately, referring to functions
and global variables in each other via "extern" statements, which are
usually within header files. For instance "a.cpp" can call a function
in "b.cpp" simply by having a function prototype.

So both your ".cpp" files are ____________ into object files. (what
word should I use in the blank? "compiled"?)
Generally they just are called object files.
So now the linker links the object files together, and wallah, now
"a.cpp" and "b.cpp" share they''re functions, class definitions,
global variables.

So what we''re looking at is something like this:

.cpp & .hpp -> .cpp -> .o -> .exe
The source file "includes" the headers but yes this is basically right
I''d say...

source -> object
object + runtime -> executable (not only .exe but also dll''s )

QUESTIONS:

What the hell is a library file?
There are two types of librarys one is a source library, just a
collection of templates and functions in a number of sources that you
add to your project as needed. STL is a source library

The other is often called a static library it is an object code file,
usually with a .lib or a .o extensio. This is the source code files
compiled into an object code but not processed for executable format.
i.e. it isn''t deadstripped for unused code.
I''ve heard that once your source
files have been turned into object files, the linker then adds
library files, and then turns it into an executable. So what the hell
is a library file?!



Just a normal object file but with a library you can add or remove
files /functions from it. By using libraries it saves a lot of time
since one assumes that a library is fully tested code. It does not need
to be debugged it does not need to be compiled again, and so on.

Hope this helps,

Ron

--
Free Download - New Version Released
CodeWarrior Development Studio for HC(S)12 Microcontrollers v3.1
offers "emulator-like" debugging support for HCS12 derivatives
http://www.metrowerks.com/MW/Develop...12/Default.htm

Ron Liechty - MW***@metrowerks.com - http://www.metrowerks.com


这篇关于C ++项目文件?????的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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