开发者

Why x86 folder for in c# project directory?

why x86 folder exist in obj folder in c Sharp project file?

My project file structure is

ProjectOne

----------Bin

--------------Debug

--------------Release

----------Obj

--------------x86 //Why this?

-------------------Debug

-------------------Releas开发者_如何学运维e

----- My source files.

Why my file current Directory is bin\debug, not projectOne (where my source file exists)?


When executing, the current directory will default to wherever the executable is - which will be in your bin/debug directory.

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).

As for the contents of the obj directory - you can pretty much ignore the whole directory. 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.


The x86 folder refers to the target platform for your build in your build configuration manager. It allows you to build 32 bit applications on a 64 bit OS. As Cody and Jon say you can ignore the obj directory.


The bin folder contains your application's binary files (that is, your executables). It is subdivided into two (or more) folders—typically Debug and Release. 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.

If you wish, you can change where Visual Studio outputs your executable files during a compile using your project's Properties window.

The obj directory contains intermediate (or object) files that Visual Studio builds when compiling your application. 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.


Object files (the files stored in Obj) are compiled binary files that haven't been linked. 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). 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.

The people who wrote your compiler obviously liked the idea of a separate Obj directory so they made it the default configuration of projects. 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.


* 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜