Author Topic: what happened to the .obj format?  (Read 4882 times)

Offline speedreadersteve

  • Multiple posting newcomer
  • *
  • Posts: 17
what happened to the .obj format?
« 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!

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2750
Re: what happened to the .obj format?
« Reply #1 on: August 13, 2019, 07:26:12 am »
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
« Last Edit: August 13, 2019, 07:33:21 am by Pecan »

Offline cacb

  • Lives here!
  • ****
  • Posts: 536
Re: what happened to the .obj format?
« Reply #2 on: August 13, 2019, 08:26:24 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!

Offline speedreadersteve

  • Multiple posting newcomer
  • *
  • Posts: 17
Re: what happened to the .obj format?
« Reply #3 on: August 13, 2019, 06:19:46 pm »
So it appears my programs still work on windows.  Any guess why?

Online stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: what happened to the .obj format?
« Reply #4 on: August 13, 2019, 08:02:42 pm »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline speedreadersteve

  • Multiple posting newcomer
  • *
  • Posts: 17
Re: what happened to the .obj format?
« Reply #5 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?

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2750
Re: what happened to the .obj format?
« Reply #6 on: August 14, 2019, 06:49:35 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.