Page 1 of 1
Visual C++ Kernel
Posted: Sun Sep 23, 2007 2:49 pm
by OrOS
I noticed a mention of this on the wiki, and wanted to try it ( I must admit using VC++ never passed my mind before. ) Anyways, dies on link:
Code: Select all
LINK : error LNK2001: unresolved external symbol __CorExeMain@0
I'm not familiar with the bin layout VC generates, however I used the exact configuration and source from the wiki.
Anyways, does anyone have a working project + config that does nothing but jump into an infinite loop?
p.s compiling with these flags:
Code: Select all
cl /Gd
/Fokernel.obj
/Fm
/TC
/c
kernel.c
link /safeseh:no
/filealign:0x1000
/BASE:0x100000
/MAP: kernel.map
/ENTRY:__multiboot_entry__ kernel.obj
/NODEFAULTLIB:LIBC
/SUBSYSTEM:CONSOLE
/OUT: kernel.exe
Posted: Sun Sep 23, 2007 3:06 pm
by piranha
I'm not familiar with the bin layout VC generates
I am not completely sure, but isn't it EXE?
-JL
Posted: Sun Sep 23, 2007 3:09 pm
by OrOS
lol sorry, don't know what I was thinking atm. I meant the calling convention. I have no idea what __CorExeMain@0 does. Is it a wrapper around the main function to init runtime features? No idea.
Posted: Sun Sep 23, 2007 4:18 pm
by kataklinger
Well, I guess you didn't exclude _all_ standard libraries...
Try this:
instead of:
Posted: Sun Sep 23, 2007 4:38 pm
by OrOS
fixed, thanks. I'll post a zip with a working VC++ project for others to use.
Posted: Mon Sep 24, 2007 12:12 am
by OrOS
Oh forgot to mention, you were right it was the lib flag. I removed all libs works fine.
Posted: Wed Sep 26, 2007 4:21 pm
by Jeffrey
Are you sure you are not compiling a .NET application, because I know that __CorExeMain is an export from .NET for use by executables.
Did you create an empty new project, and not one form a template? If you did, then you may want to go ahead and create a new empty project, because you may run into problems down the road.
Also, depending on how you design your system, it may be in your best interest to compile using build scripts, instead of relying on the IDE to do it for you. Say for instance, you suddenly want to move over to MinGW/Cygwin, you basically have nothing but what is in the configuration dialog. Just my opinion..
Posted: Wed Sep 26, 2007 9:04 pm
by OrOS
fixed, thanks. I'll post a zip with a working VC++ project for others to use.
Guess you didn't see that...anyways, I DONT use their ide, just cl and link.
I use my own IDE:
Supports ASM, Java, C/C++, Objective-C, Ruby[/wiki]
Posted: Sat Sep 29, 2007 12:03 pm
by OrOS
*cough* Am I missing something? VC++ won't work with more then 16 bits in a char pointer?
char *Hello = "Hello World! How are you"
or any variation in there will always compile as if it were:
char *Hello = "Hello World! Ho"
Am I missing something VC++ needs on runtime?
EDIT:: Yeap, I missed something. VC++ calls ___security_cookie before and after all arrays and memory pointers.
Posted: Thu Oct 04, 2007 3:46 pm
by kataklinger
OrOS wrote:
EDIT:: Yeap, I missed something. VC++ calls ___security_cookie before and after all arrays and memory pointers.
Just disable buffer security check. Switch /GS-
Posted: Wed Oct 10, 2007 12:08 am
by AndrewAPrice
This isn't about the Visual C++ compiler, but I have kernel compiling with Cygwin within the Visual Studio/C++ IDE.
What to do to repeat what I did:
- Create a new project. Make it a Visual C++>General>Makefile Project.
- Set your build/rebuild/clean command to build.bat (or whatever batch file you want to use).
- Set your output file to anything (I think VC++ might check to see if this file exists to see if it compiled correctly?)
- Create build.bat and other batch files (my build.bat set's up Cygwin's paths, then calls build.sh using bash. Build.sh does the actual compiling and puts the disk image togeather.)
- Go to your kernel project properties>Configuration Properties and set your emulator properties here. I set the command to:
C:\Program Files\InnoTek VirtualBox\VBoxManage.exe
and the command arguments to:
startvm "Perception Kernel"
There might be away to get the bochs debugger to interact directly with VS but I haven't discovered how to yet. You could use different configurations for different emulators.
Now you should be able to build your kernel, start the emulator, and use handy features like IntelliSense from within the IDE. I don't know how, but Visual Studio seems to be able to intercept GCC's compile errors and display messages like "4 errors and 2 warnings". Unfortunately, you can't double click the error to take you to the line of code like when using the MS compiler.