Code::Blocks Forums
User forums => General (but related to Code::Blocks) => Topic started by: speedreadersteve on August 13, 2019, 06:31:31 am
-
c++ source file creates a .o in windows 10. The .exe still works, but the book I'm reading 'Programming Principles and Practice' (the Bjarne one) says that .o is used by Unix, not windows.
So anyway, I'm wondering if either that's changed, or if it's no problem for linking on codeblocks, or... is there a history behind this, and why this still works this way?
Probably a complex question, or probably not. Anyway, I thought I'd ask. Thanks!
-
CodeBlocks was primarily originated by Linux developers.
It uses the a default GNU gcc compiler toolchain (from Linux), so it outputs object files with extension .o rather than MSVC object extension of .obj.
You can, if you wish, install and use the MSVC compiler with CodeBlocks as the IDE (Integrated Development Environment) in which case you'll get an .obj file.
http://wiki.codeblocks.org/index.php/Installing_a_supported_compiler
(http://wiki.codeblocks.org/index.php/Installing_a_supported_compiler)
-
You can, if you wish, install and use the MSVC compiler with CodeBlocks as the IDE (Integrated Development Environment) in which case you'll get an .obj file.
This is correct. I have done that for years and still use the MSVC compiler with Code::Blocks on Windows. The .obj vs. .o is not a question of operating system, but which C++ compiler is being used.
My C::B project files have 4 build targets, 2 for MSVC (MSVC_Debug/MSVC_Release) and 2 for GNU gcc (GCC_Debug/GCC_Release). The reason for using MSVC on windows is that I need to be compatible with external MSVC-built libraries, plus I prefer the MSVC debugger. Still, most of my projects build and run with GCC under linux, under C::B.
Code::Blocks offers a lot of flexibility!
-
So it appears my programs still work on windows. Any guess why?
-
Please the rules for this website!
http://forums.codeblocks.org/index.php/topic,9996.0.html (http://forums.codeblocks.org/index.php/topic,9996.0.html)
-
No, I'm confused because it seems that the mingw32 g++ toolchain of GCC creates .o objects for linux, yet they still run in windows10?
-
No, I'm confused because it seems that the mingw32 g++ toolchain of GCC creates .o objects for linux, yet they still run in windows10?
I your are using a minGW compiler, it creates .o files for windows.
And links agains windows libs.