简体   繁体   English

为什么在C#项目目录中使用x86文件夹?

[英]Why x86 folder for in c# project directory?

why x86 folder exist in obj folder in c Sharp project file? 为什么c Sharp项目文件的obj文件夹中存在x86文件夹?

My project file structure is 我的项目文件结构是

ProjectOne 项目一
----------Bin ----------宾
--------------Debug --------------调试
--------------Release - - - - - - - 发布
----------Obj ---------- Obj
--------------x86 //Why this? -------------- x86 //为什么这样?
-------------------Debug -------------------调试
-------------------Release - - - - - - - - - -发布
----- My source files. -----我的源文件。

Why my file current Directory is bin\\debug, not projectOne (where my source file exists)? 为什么我的文件当前目录是bin \\ debug,而不是projectOne(存在我的源文件的地方)?

When executing, the current directory will default to wherever the executable is - which will be in your bin/debug directory. 执行时,当前目录将默认为可执行文件所在的位置-它将位于您的bin / debug目录中。

You can set where you want it to run from when you start it in Visual Studio though (in the project properties - if you need more details, please say exactly which version/edition of VS you're using). 不过,您可以在Visual Studio中启动它时设置运行它的位置(在项目属性中-如果需要更多详细信息,请准确说明所使用的VS版本/版本)。

As for the contents of the obj directory - you can pretty much ignore the whole directory. 至于obj目录的内容-您几乎可以忽略整个目录。 It's full of intermediate files that Visual Studio builds and then consumes - but you almost never need to use any files from there directly. 它充满了Visual Studio生成然后使用的中间文件-但是您几乎不需要直接使用那里的任何文件。

The x86 folder refers to the target platform for your build in your build configuration manager. x86文件夹在构建配置管理器中引用构建的目标平台。 It allows you to build 32 bit applications on a 64 bit OS. 它允许您在64位OS上构建32位应用程序。 As Cody and Jon say you can ignore the obj directory. 正如Cody和Jon所说,您可以忽略obj目录。

The bin folder contains your application's binary files (that is, your executables). bin文件夹包含应用程序的二进制文件(即可执行文件)。 It is subdivided into two (or more) folders—typically Debug and Release . 它分为两个(或多个)文件夹-通常为DebugRelease These correspond to your build configurations. 这些与您的构建配置相对应。 When your project is compiled, the executable files are placed into one of these folders, depending on which type of build you conducted. 编译项目时,可执行文件将放置在这些文件夹之一中,具体取决于您执行的构建类型。 If you want to run your executable outside of the development environment, you can click on the ".exe" file you find in one of these folders. 如果要在开发环境之外运行可执行文件,可以单击在这些文件夹之一中找到的“ .exe”文件。

If you wish, you can change where Visual Studio outputs your executable files during a compile using your project's Properties window. 如果需要,可以使用项目的“属性”窗口更改Visual Studio在编译过程中输出可执行文件的位置。

The obj directory contains intermediate (or object) files that Visual Studio builds when compiling your application. obj目录包含Visual Studio在编译应用程序时生成的中间(或目标)文件。 It's not really something you ever need to worry about or use the files from. 您实际上不必担心或使用其中的文件。

Finally, your source files are kept in the root directory, as displayed in your Solution Explorer window. 最后,源文件将保存在根目录中,如“解决方案资源管理器”窗口中所示。 You manage the locations of these files yourself; 您可以自己管理这些文件的位置。 they are not managed by Visual Studio. 它们不是由Visual Studio管理的。

Object files (the files stored in Obj) are compiled binary files that haven't been linked. 目标文件(存储在Obj中的文件)是尚未链接的已编译二进制文件。 Think of it as fragments of the final executable that will later be combined to make your executable. 可以将其视为最终可执行文件的片段,这些片段随后将组合成可执行文件。

When compiling your source code each source file will loosely be compiled to one object file. 编译源代码时,每个源文件都会被松散地编译为一个目标文件。 Why? 为什么? No reason*, just how your particular compiler was written. 没有理由*,只是您的特定编译器的编写方式。 There are other compilers in other languages that does not do this but instead compile everything into a single large binary in one step. 有其他语言的其他编译器不执行此操作,而是一步将所有内容编译为单个大二进制文件。 But the people who wrote your compiler decided to first compile to separate object files. 但是编写您的编译器的人决定首先编译为单独的目标文件。

Now, you can imagine that if each source file generate one object file then every time you compile code your source directory will end up being messy and be filled with lots of .obj files (and indeed a lot of C compilers traditionally did this). 现在,您可以想象,如果每个源文件生成一个目标文件,那么每次编译代码时,源目录最终都会变得混乱,并充满了许多.obj文件(实际上,很多C编译器通常都会这样做)。 Over time, developers working on large projects started to write compile script or configure their projects to collect all .obj files in a single directory to make the source directory less messy. 随着时间的流逝,从事大型项目的开发人员开始编写编译脚本或将其项目配置为将所有.obj文件收集在一个目录中,以使源目录的混乱程度降低。

The people who wrote your compiler obviously liked the idea of a separate Obj directory so they made it the default configuration of projects. 编写您的编译器的人显然很喜欢一个单独的Obj目录的想法,因此使它们成为项目的默认配置。 As for why there is an x86 subdirectory that's because your compiler also supports other CPUs like ARM (for Android, Win Phone 7 and iPhone) and also to differentiate between 32bit and 64bit. 至于为什么有x86子目录的原因是因为您的编译器还支持其他CPU,如ARM(适用于Android,Win Phone 7和iPhone),并且还可以区分32位和64位。


* note: There are actually some very good reasons to do this including making the compiler code more modular and to support incremental compilation but the fact that some people can do all that without generating separate obj files mean that it is mostly a design decision by the developers of the compiler more than it being a necessity. *注意:实际上有很多很好的理由来做到这一点,包括使编译器代码更具模块化并支持增量编译,但是某些人可以完成所有这些操作而无需生成单独的obj文件这一事实意味着,这主要是由设计决定的。开发人员不仅仅是必需的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM