News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

what happened to the .obj format?

Started by speedreadersteve, August 13, 2019, 06:31:31 AM

Previous topic - Next topic

speedreadersteve

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!

Pecan

#1
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

cacb

Quote from: Pecan on August 13, 2019, 07:26:12 AM
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!

speedreadersteve

So it appears my programs still work on windows.  Any guess why?

stahta01

C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

speedreadersteve

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?

Pecan

Quote from: speedreadersteve on August 14, 2019, 02:19:01 AM
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.