Page 1 of 2

Visual C++ IDE Kernel Development - Flat Binary

Posted: Sat Nov 03, 2012 5:08 pm
by OdinVex
I've decided not to spend so very much time writing my Kernel in Assembler...it's taking too long. ;) So I've decided to use Visual C++ IDE, and I've followed the Wiki's advice on how to prepare a project except I'm trying to produce a flat binary. How can I produce the flat binary? What can strip the headers, is this possible without any sort of sacrifice? What would change?

Re: Visual C++ IDE Kernel Development - Flat Binary

Posted: Sat Nov 03, 2012 5:10 pm
by Griwes
Do yourself a favor, switch to *nix for OS development and use GCC or Clang (preferably the latter - it's easier to set up).

Re: Visual C++ IDE Kernel Development - Flat Binary

Posted: Sat Nov 03, 2012 5:20 pm
by OdinVex
I'd love to but I just...eh, been babied too much with MS IDEs. It'd be a hassle to switch between VM and Windows all the time. Without trying to start a war here, I just don't like messing with GCC as far as libraries and (stringy...goodness?) goes..

*Edit* I might just deal with PE Format. Meh.

Re: Visual C++ IDE Kernel Development - Flat Binary

Posted: Sat Nov 03, 2012 7:03 pm
by Hoozim
What you can do is to use GCC over cygwin in windows. Then you can create your makefile scripts that will build your code. You can still use VC++ to write your code. If you hook VC++ up to the makefile, then VC++ can even start the build process for you.

Hoozim

Re: Visual C++ IDE Kernel Development - Flat Binary

Posted: Sun Nov 04, 2012 10:30 am
by Owen
You can build GCC under MinGW as well; this tends to be more reliable

Re: Visual C++ IDE Kernel Development - Flat Binary

Posted: Tue Nov 06, 2012 5:40 am
by Creature
As Owen says, you don't need Cygwin or a *NIX OS at all to use GCC, there are plenty of ports available. If you're interested, you can take a look at TDM-GCC or just plain MinGW. The latter (I'm not sure about the former) also ships (if you use the installer, that is) with a copy of mingw32-make so you can build makefiles. If you do need a simple *NIX-like environment, you can also try MSYS (same site as MinGW), which is a lot less bulky and "radical" than Cygwin. If you want to stay on Windows, you can also consider using a GCC-based IDE (I believe you can combine with Visual Studio, but it's probably going to be a pain) on Windows. I believe there are also clang binaries for Windows, but last time I checked they were always a couple of versions behind on the other OS', but it may have changed now.

Also, if you want to use Visual Studio, I believe BrokenThorn's tutorials are entirely focused on using VC++ for OS development, although IIRC he uses the PE format and not a flat binary.

Re: Visual C++ IDE Kernel Development - Flat Binary

Posted: Tue Nov 06, 2012 12:41 pm
by bewing
Stripping to a flat binary is done in the final link phase. I forget which default linker is used by cl, but I'm sure it has a "flat binary" output mode -- you would need to look up the documentation for the flag, and stick it in the linker options. Otherwise, you can use jloc for a linker -- it supports PE input object files. However, if you strip the output binary then the MSVC IDE will no longer work -- which defeats your purpose, I think. In fact I am not sure if it's even possible to get an OS to pretend to boot, and still have the IDE work ... it will be tricky at least. And AFAIK, MSVC has language in the EULA that says you are not supposed to use it for OS development, so that's naughty, too.

Re: Visual C++ IDE Kernel Development - Flat Binary

Posted: Tue Nov 06, 2012 7:41 pm
by neon
Hello,

The compiler provided by the MSVC IDE, cl.exe uses link.exe by default, both which are provided by the SDK. The linker does not support flat binary output; if you want to support flat binary with the MSVC tool chain you will need an alternative linker. It is easy enough to configure the environment using makefiles and build scripts to execute another linker instead of the default linker. I can suggest ld.exe as it supports what you want (and also gives you more control with how the image sections are built using linker scripts.) I can also assert that using MSVC for operating system development is legit based on its usage in ReactOS as an alternative build environment.

Whether or not one should use the IDE as more then just an editor has been discussed a lot on the forums and I encourage reading those posts to get some insight--if it may cause problems for your specific design needs.

I am unsure if you can configure the IDE to not execute the default linker. In other words, if you want to go flat binary with MSVC you may have to use it as an editor with build scripts or make files. I would be interested to see if anyone knows of a way though.

Re: Visual C++ IDE Kernel Development - Flat Binary

Posted: Sun Dec 30, 2012 7:38 am
by OdinVex
My apologies on not following up, I'd had a little rough weather and economic trauma here in New York. I love the IntelliSense and working environment of Visual Studio IDE, and I'd like to use it as it'd be most comfortable for me. Essentially I'd like to find a way to produce flat binaries transparently with Visual C++, though I'd prefer to be as clean as possible for sanity sake. If anyone has any insight on this etc I'd appreciate it. I don't want to go with GCC, trying to go completely bare on it. :]

*Edit* I'd consider another IDE if it had anything similar to 'IntelliSense' and of course syntax highlighting. Please suggest only Windows IDEs. I'd prefer not having to write so many scripts but eh...Might need to. >_>; Hopefully one with inline asm.
neon wrote:In other words, if you want to go flat binary with MSVC you may have to use it as an editor with build scripts or make files. I would be interested to see if anyone knows of a way though.
I think I could live with that. Hm.

Re: Visual C++ IDE Kernel Development - Flat Binary

Posted: Sun Dec 30, 2012 10:23 am
by bluemoon
I love IntelliSense too, until it occasionally messed up itself and require the deletion of its database, and the ability to "one-click to build sub-project" is lack on other major IDE (xcode, codeblock and kdev - they require switch active project in a menu, then click build - not that convenient when you have multi-project under the workspace)

Anyway, I use code block under Linux, if you spend a day to tweak the project setting it works extremely well with Makefile, and it got major feature you would expect on an modern IDE - and it got windows version.

For absolutely control freak, get vim :P

Re: Visual C++ IDE Kernel Development - Flat Binary

Posted: Sun Dec 30, 2012 8:57 pm
by OdinVex
hm, I've never had an issue with IntelliSense. I don't mind context-switching (I don't mind editing a batch file to run compilation per project), but I don't want to waste so much time with build scripts, makefiles, and I don't do cross-compilation...Just want to be fresh, unique, original on this. Just kinda want to product flat binaries or at least the ability to write inline ASM. VIM the text editor? Code::Blocks isn't viable, now looking at it, because I don't want to use GCC etc. X_x;

Re: Visual C++ IDE Kernel Development - Flat Binary

Posted: Mon Dec 31, 2012 12:38 am
by bluemoon
Believe me, you won't think it's waste of time for seriously writing a Makefile.
It may take a few days reading reference and tutorials, but after that you will be good, the benefit and flexibility out-weight those few days of work.

Re: Visual C++ IDE Kernel Development - Flat Binary

Posted: Mon Dec 31, 2012 12:48 am
by OdinVex
So can Visual C++ produce flat binaries (64-bit) using makefiles then?

Re: Visual C++ IDE Kernel Development - Flat Binary

Posted: Mon Dec 31, 2012 1:24 am
by bluemoon
The usual notation of "Visual C++" comes in three parts: IDE, Toolchain (Compiler, Linker, nmake, etc), Extra Tools(Profiler, malloc debug, etc)
The toolchain comes with VC(and Platform SDK) cannot directly produce 64-bit flat binary.
The Extra Tools are not intended for use with OS developement and out of this discussion.

For the purpose of OS development (and produce 64-bit flat binary), you may do:
1. Configure the IDE to work with Makefile and invoke external toolchain that can produce the desire output (and probably cross compiler)
2. Use the IDE & Toolchain from VC to produce PE64, and invoke external utility to convert such PE64 into flat binary, to automate the process you may setup post-build scripts; or end up using Makefile...then there is less reason to use the shipped toolchain.

Re: Visual C++ IDE Kernel Development - Flat Binary

Posted: Mon Dec 31, 2012 1:26 am
by OdinVex
Yeah I'd like to find a way to just convert to flat binaries from PE64, my output is a PE64 DLL. Hm, might just keep developing in ASM.