简体   繁体   中英

Files related to C++

I program in C++. When I see the folder in which .cpp file is saved I found some files like cpp, o and exe.

Are there any other files also related when the program is run, such as bak, tds? What is the difference between them and when are they made. I mean I am in the impression that cpp is formed when we save, object file when we compile. When are the bak and exe files are made? Or correct me.

Now, unless you created the file yourself it's most likely somehow related to your toolset.

*.cpp, *.h => Source files. These are the ones you'll edit to do your programming.

*.o, *.obj => Object-files. These are the translated version of the source files (the *.cpp files to be more precise) and are the raw material for the Linker.

*.exe => The executable. After the Linker is through with your object files it chains all of them together to create the actual executable which can be run by your OS.

*.bak => Typically a 'backup' file, which is often used if there's a risky operation going on, so it will be easy to restore damage.

*.tds => I know this one as Turbo Debugger-File. It is required by the IDE to allow stepping through the compiled code, keeping symbols etc.

.cpp files are for source code

.h files are for headers

there may be also other files with various extensions which contain resources, project definition, build definitions, make-files - it depends on the development environment / compiler.

the .o files are binaries generated from the source code

the .exe file is windows executable - this is probably the single file, you want to run the program. and this files are created during build from all libraries and .o files.

.bak files are only backup of some previous version of .cpp or .h files. The creation depends on the development environment.

bak tends to indicate backup files of some sort, probably made by an editor when you edit the files. I had no idea initially about tds files but a cursory web search turned up the fact that they are likely files produced for Borland Turbo Debugger ( tds stands for Turbo Debugger Symbols).

You may want to consider upgrading to a compiler that's been updated sometime in the last fifteen years. There's rarely an excuse for using technology that dated when there are far better (and free) alternatives available.

Generally, you write the cpp files and the compiler compiles them. o files are usually files that have been compiled to objects and these are then combined into an exe executable file.

Note that this all depends on your environment of course. For example, UNIX compilers rarely produce exe files since that's a DOS/Windows-ism.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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