Tech Off Thread

4 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

.

Back to Forum: Tech Off
  • User profile image
    evildictait​or

    .

  • User profile image
    littleguru

    evildictaitor wrote:
    When the Visual Studio C/C++ compiler is given the following options:

    /Od /Oy /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Gm /MD /GS- /Za /J /Zc:wchar_t- /GR- /FAcs /Fa"Debug\\" /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W3 /nologo /c /TC /errorReportrompt

    It outputs a file that doesn't run under windows, and has a 512 block of headers followed by the executable code on the next 512 byte align, 0-padded to the 512 byte align after that. It looks therefore like you can just strip off the first 512 bytes of the outputted file, lose the last zeros (this doesn't actually help, because of 512 byte block-aligning on disks) and then exporting that.


    I was so sure that you can't create a compiled file with the VC++ compiler that would have no PE header... Would that output run in MSDOS?

    Have you tried the gcc?

  • User profile image
    littleguru

    evildictaitor wrote:
    Edit: looks like the guys inside Microsoft didn't have it all nice 'n' breezy either - link


    That video is nice as an introduction or general overview Smiley

  • User profile image
    jolson88

    Sven Groot wrote:
    
    evildictaitor wrote:
    You suggest that a compiler for operating-system-less environments must be done via a cross-compiler or from within the environment. This is not true. From 32bit windows you can create IL code and x64 code, neither of which will run* on your 32bit windows, but both of which can be created from 32 bit windows

    Which is the definition of a cross compiler.

    What you need is a compiler capable of creating a binary for your operating-system-less environment. Visual C++ cannot do that. That's unfortunate, but there's not much you and I can do about it.

    EDIT: It doesn't make a difference whether you are using C or C++. If you use Visual Studio, it uses the same compiler, cl.exe. If you run it from the command line you'll see it says "Microsoft C/C++ Optimizing Compiler".

    Writing your code in Visual Studio is fine, but you will need a different compiler.


    Not true, you can _absolutely_ use Visual C++ to do your own OS development. I have some links about this on my blog. Specifically, there is this two part series that shows how to write multiboot PE kernels using Visual C++.

    One of the switches you are looking for is "/nodefaultlib:libc" which will avoid linking all the C Runtime Library. So you could define functions like "memcpy" in your own code (which is kind of necessary when writing your own kernel since there is no C runtime library to use (unless you build your own of course)). There are also several other switches that should get you closer.

    I don't know how many of these switches are depracated (if any) in VS2008 though.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.