Jump to content


Photo

How to compile OpenXDK's with M$ Visual C++


  • Please log in to reply
27 replies to this topic

#1 bob1122

bob1122

    X-S Member

  • Members
  • Pip
  • 125 posts

Posted 19 December 2004 - 04:33 AM

ok well first off if this is worthy of a pin then i will edit it to make it more clear but if not than f#@$ it ....

Requirments:

/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
MS Visual Studio 6 with C++
OpenXDK BINARIES (version 5 worked for me in this tutorial but as i said if it is pinned i will try to figure out for 6 yay ) http://openxdk.sourceforge.net/ we love u caustik beerchug.gif and edward beerchug.gif
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

Allright well this is actually quite easy to do and i cannot believe that other people have not figured it out before me! but you dont care so here's the guide

1. Get your good 'ol "M$ Visual Studio 6.0 " in Visual C++ mode (must have c++ installed and working beerchug.gif )

2. up on top u have ur menus click the Tools scroll down one then get yourself into Options

3. You have your options up right ... well click the Directories tab.

4. now for you to get to work...
make sure that

Platform : is Win32.... ( if u have xbox then you dont need to read this! )
and it says Show Directories For: Include Files

now what your gonna do is click the weird box thingy beside the X (its tag's New)
then in the box that just appered your gonna put the directory of the all the folders in the OpenXDK BINARIES folder that u extracted from the version 5 release of openxdk binaries it to.... im to lazy to specify which ones but when i put all off them it worked fine for me.....

5. now test it out then use cxbe (instructions for cxbe are at http://www.openxdk.org/ ) to make it a Xbe

6. Have fun programing and Support OpenXDK

Note : Check my signature i know it works for that kind of xbox

Please note : if your having problems running it on your xbox its probably because your using x2 bios ..... iND-BiOS works for me and m7 works for other people to ....

Have fun coding and if you like this tutorial and your a code programer y doesnt someone make a good DISC player with it or a DISC Ripper. That should get some more people going to the OpenXDK side of things smile.gif



#2 bob1122

bob1122

    X-S Member

  • Members
  • Pip
  • 125 posts

Posted 19 December 2004 - 04:36 AM

could a moderator rename the title to


"How to compile OpenXDK's with M$ Visual C++"
and the Details as " A little Tutorial"

Thanks allot

#3 HoRnEyDvL

HoRnEyDvL

    Nexgen Developer

  • Head Moderators
  • PipPipPipPip
  • 906 posts
  • Gender:Male
  • Location:Australia
  • Xbox Version:v1.0
  • 360 version:v1 (xenon)

Posted 19 December 2004 - 06:31 AM

Pinned smile.gif nice guide, Also renamed. Hope to see some open source legal apps been developed now.

Edited by HoRnEyDvL, 19 December 2004 - 06:55 AM.


#4 bob1122

bob1122

    X-S Member

  • Members
  • Pip
  • 125 posts

Posted 19 December 2004 - 06:42 PM

thanks and 50% of the reason for me writing this is because i could not get cygwin working and didnt feel like running linux again .... so i figured out how to do it for M$ compilers yay.... Now all those genius brains out there can go to work laugh.gif

#5 Flocool

Flocool

    X-S Enthusiast

  • Members
  • 10 posts

Posted 20 December 2004 - 02:33 PM

Very nice work, thank you smile.gif

I think the directories to add in the options for include files are "[OpenXDK Folder]\include" and "[OpenXDK Folder]\i386-pc-xbox\include". Also you have to add the libary files I think, "[OpenXDK Folder]\lib" and "[OpenXDK Folder]\i386-pc-xbox\lib". The problem for me is, I don't know which libaries I have to link. I included "hal/xbox.h" and use the function "XReboot()". The libaries I linked are "libhal.a libopenxdk.a libxboxkrnl.a" and I get those errors:

CODE

libxboxkrnl.a(d000065.o) : warning LNK4078: Mehrfache ".text"-Abschnitte mit unterschiedlichen Attributen (E0000020) gefunden
libopenxdk.a(openxdk.o) : error LNK2001: Nichtaufgeloestes externes Symbol ___getreent
LIBCD.lib(crt0.obj) : error LNK2001: Nichtaufgeloestes externes Symbol _main
Debug/Test.exe : fatal error LNK1120: 2 unaufgeloeste externe Verweise


I know those are german, but I don't know the translation for it, maybe you can guess what they mean. Thanks in advance, and sorry for my bad English and the German error-messages. biggrin.gif

Edited by Flocool, 20 December 2004 - 02:35 PM.


#6 freakdave

freakdave

    X-S X-perience

  • Dev/Contributor
  • PipPip
  • 472 posts
  • Location:Europe
  • Interests:PROGRAMMING,XBOX...
  • Xbox Version:v1.0
  • 360 version:v1 (xenon)

Posted 24 December 2004 - 12:13 AM

It would be very cool if someone would post a (noob-proof) step by step tutorial and a download with a little code sample(preferably some very simple SDL examples) including all corresponding/appropriate project files.

Okay,so here's my problem:
I've started a win32 project > console application > empty project (I'm using the latest VS.net)
Code Generation : Single Threaded
All includes and libraries are properly set up in the options.
I've already fixed the 'typedef int bool' bug in types.h
Oh,and i'm using OpenXDK 0.06 (i hope this ain't the problem)..

My code :
CODE

#pragma comment(lib, "libhal.a")
#pragma comment(lib, "libopenxdk.a")
#pragma comment(lib, "libSDL.a")
#pragma comment(lib, "libSDL.la")
#pragma comment(lib, "libSDLmain.a")
#pragma comment(lib, "libusb.a")
#pragma comment(lib, "libxboxkrnl.a")

#pragma comment(lib, "crt0.o")
#pragma comment(lib, "libc.a")
#pragma comment(lib, "libg.a")
#pragma comment(lib, "libm.a")
#pragma comment(lib, "libnosys.a")

#include <openxdk.h>

void XBoxStartup()

{
   HalReturnToFirmware(ReturnFirmwareFatal);
   return;
}


Compiling this sample gives me this error:

CODE
OXDK_TEST error LNK2019: Nicht aufgelöstes externes Symbol '_main', verwiesen in Funktion '_mainCRTStartup'

OXDK_TEST fatal error LNK1120: 1 unaufgelöste externe Verweise

in english : unresolved external symbol in function and 1 unresolved external reference(XBoxStartup?)
So how can i fix this ?
Any help would be greatly appreciated.

Edited by freakdave, 24 December 2004 - 12:15 AM.


#7 d0wnlab

d0wnlab

    X-S Expert

  • Moderator
  • PipPipPip
  • 557 posts
  • Xbox Version:unk

Posted 24 December 2004 - 07:41 AM

It's 2am but I might as well post the best hint I have..

I'm pretty sure what happens in the xbe startup is that,

crt0 contains the actual startup main() function (edit: or, actually, WinMainCRTStartup.. look at the linker options below..) . It calls your provided XBoxStartup() after setting up the environment. So, the corresponding error is that crt0 not linking to your current code properly, or that your linker is looking for a main() (which prolly doesn't exist) instead of a WinMainCRTStartup() (which exists in crt0.a) Check your project linker options? I dunno, the translation is kinda vague.

why this is? beyond my knowledge, I don't use VC or windows or.. anything like that.. so..

Just a question.. is anyone sure this works? When I'm using mingw32 gcc I include parameters such as:

(cflags) -ffreestanding -nostdlib -fno-builtin -fno-exceptions -mno-cygwin -march=i386
(linker flags)

CLINK = -nostdlib
ALIGN = -Wl,--file-alignment,0x20 -Wl,--section-alignment,0x20
SHARED = -shared
ENTRYPOINT = -Wl,--entry,_WinMainCRTStartup
STRIP = -Wl,--strip-all
LD_FLAGS = $(CLINK) $(ALIGN) $(SHARED) $(ENTRYPOINT) $(STRIP)
LD_DIRS = -L/usr/local/openxdk/i386-pc-xbox/lib -L/usr/local/openxdk/lib
LD_LIBS = $(LD_DIRS) -lSDL_image -lSDL -lm -lopenxdk -lhal -lc -lhal -lc -lusb -lxboxkrnl

(for an exact copy check the makefile in the samples src directory in the openxdk tree)

I'm just wondering if you're really going to get this working without realigning your startup and whatnot..

also freakdave just fyi, C++ isn't fully supported yet, there's no new and delete operators. You should be able to compile with a c++ compiler anyways just stay in C. Might help to pragma "C" around it all too or whatever.. I dunno. Good luck, I'm interested in how it goes..

also imho, it's easier just using cygwin or mingw32 & msys (msys rocks; native bash for windows)..

Edited by d0wnlab, 24 December 2004 - 07:47 AM.


#8 TNHitokiri

TNHitokiri

    X-S Senior Member

  • Members
  • PipPip
  • 176 posts
  • Xbox Version:v1.4
  • 360 version:v1 (xenon)

Posted 24 December 2004 - 07:13 PM

Is there a way to make this work with Visual Studio .Net ?

#9 bob1122

bob1122

    X-S Member

  • Members
  • Pip
  • 125 posts

Posted 26 December 2004 - 04:54 PM

QUOTE(TNHitokiri @ Dec 24 2004, 07:44 PM)
Is there a way to make this work with Visual Studio .Net ?

View Post



yes there is a way to compile in MS Visual Studio .NET... sorry i assumed that most people allready new how to compile with it and i was just specifing for the translation to Visual 6

but ill post a link to the VS .NET tutorial for it. i guess i will revive this with those steps included. sorry for the misconvienence.

P.S. please translate your errors thanks... (just like freakdave did.) unless it in chinese/korean/japanese/english/ i can translate that myself smile.gif

ok here's the upload (I DID NOT WRITE ANY OFF IT ALL CREDITS GO STRAIGHT TO http://www.xbdev.net.../donations.php)



#10 bob1122

bob1122

    X-S Member

  • Members
  • Pip
  • 125 posts

Posted 26 December 2004 - 05:01 PM

aww ..... i cant upload .... hey hornydevil can i be a a leader here?

#11 NeoXTC

NeoXTC

    X-S Enthusiast

  • Members
  • 4 posts

Posted 06 January 2005 - 06:34 AM

would this work with Visual Studio .NET??

#12 bitblaster

bitblaster

    X-S Member

  • Members
  • Pip
  • 101 posts

Posted 09 January 2005 - 02:58 PM

he just said yes it will work with .NET

My question:

Can I compile .XBE's with just my PC alone or do I need that second tool?

#13 bob1122

bob1122

    X-S Member

  • Members
  • Pip
  • 125 posts

Posted 28 January 2005 - 03:53 AM

allright u shaddy obisities, here ya go

how to compile xbe with .net

--------------------------------------------------------------------
OpenXDK - MS Visual Studio .NET - Installation Instructions
--------------------------------------------------------------------

This document describes the process which should be used if you
wish to develop "homebrew" software for the XBox using OpenXDK.

Information is as precise and correct as I can make it, but feel
free to submit suggestions. After all, OpenXDK is an open source
project, and our success relies on community contributions.

------------------------------------------------------------------
Table of Contents
------------------------------------------------------------------

1) Installation

a) Download
cool.gif Unzip
c) Build

2) Development

a) Creating a New Project
cool.gif Removing "Debug" Configuration
c) Setting Compiler and Linker Options
d) Setting Required Directories
e) Configuring CXBE for Custom Build
f) Adding XBoxStartup
g) Building Your Project

------------------------------------------------------------------
Information
------------------------------------------------------------------

1) Installation

a) Download

To download the latest OpenXDK files, go to the OpenXDK web site
displayed below, and locate the appropriate download file(s).

http://openxdk.sourceforge.net/

Hint: You want "OpenXDK" and perhaps one of the Samples.

cool.gif Unzip

OpenXDK is distributed in .zip format. After downloading OpenXDK,
the next step is to decompress the .zip file into a directory of
your choice. The preferred directory is C:\OpenXDK, but you may
put these files wherever you wish. The only requirment is that
you must remember where this directory is.

c) Build

Building OpenXDK is very easy. The decompressed folder (C:\OpenXDK)
contains a file called OpenXDK.sln. To build OpenXDK, simply open
this workspace with MS Visual Studio .NET, and then build the
projects.

Note: To build, click Build->Build Solution.

2) Development

a) Creating a New Project

There are some specific steps that must be taken when creating a
project for use with OpenXDK. Primarily, Compiler and Linker options
must be tweaked, and 3 directories must be added to the compiler's
search path. The details on how to configure these options are
explained in detail below.

The first step is to create a new project. This can be done by
opening MS Visual Studio .NET and creating a new Win32
project and workspace. This can be done via File->New->Project.
The type of project you will want to create is "Win32 Project".
It does not matter where you put your project files, as we will add
the necessary directories for includes, lib, and binaries later
in this tutorial.

After you click OK, you will be asked what type of windows
application you would like to create. You should click on the tab
marked "Application Settings", and make sure "Windows Application"
in chosen, then check the box next to "Empty Project". Then, click
"Finish".

Now that you have a new project, you will need to modify a few of
the default options before your .exe will relink correctly. The
exact options that need to be changed are described next.

cool.gif Removing "Debug" Configuration

Since you can not use "Debug" configuration with OpenXDK, it is
recommended that you remove this configuration completely. To do
this, use the menu Build->Configuration Manager, and in the drop
down boxed titled "Active Solution Configuration", choose "<Edit...>"
In the window that comes up, select "Debug", and push "Remove".
Then click Yes on the confirmation dialog that comes up next. Once
this is done you can close the "Edit Solution Configurations" dialog,
and the "Configurations Manager" dialog.

c) Setting Compiler and Linker Options.

Compiler options are accessed through the menu Project->Properties.

The first set of options we are concerned about are located under
the "C/C++" folder. First, switch to the category titled "Code Generation"
and set "Enable C++ Exceptions" to "no". Then, set "Buffer Security ChecK"
to "no". Optionally, you might want to go to the category marked
"Optimization" and switch "Optimize for Processor" to "Pentium Pro and Above".

The next set of options we need to change are located under the
"Linker" folder. Switch to the category titled "Input". You will need
to set the box marked "Ignore All Default Libraries" to "Yes". Then,
under "Additional Dependencies", you should paste the following:

xboxkrnl.lib xlibc.lib xhal.lib xvga.lib

Next, you will need to add a few linker options by switching to the
category titled "Command Line" and typing directly into the box marked
"Additional Options". Add the following text to the very end of the
existing text:

/align:0x20 /driver /fixed:no

Failure to do this correctly will result in linker errors, and you
will not be able to compile your .xbe correctly. You can copy and
paste the text exactly as it is above, but you must be absolutely
certain to paste the text at the very end of the text in the box.

After you have added these settings, just click "OK".

d) Setting Required Directories

In order for your code to compile and link correctly, you will need
to add a few paths to your configuration. To add these directories,
you can use the menu Tools->Options. Then, click over to the folder
named "Projects". Click on the category marked "VC++ Directories" and
add the following paths to the appropriate directory list. (You change
between directory lists using the drop down under "Show Directories for:"

"Include files" -> C:\OpenXDK\include\
"Library files" -> C:\OpenXDK\lib\
"Executable files" -> C:\OpenXDK\bin\

You must be sure to add these directories to the correct choice under
the drop down box titled "Show directories for:". Your paths may be
different, depending on where you chose to unzip the OpenXDK files.

After you have added these settings, just click "OK".

e) Configuring CXBE for Custom Build

Now, you must configure your project to use CXBE as a custom build step.
This is the process that is used to convert your .exe file to an .xbe
file that is compatible with the XBox. To configure this setting, you can
use the menu Project->Properties, then switch to "Custom Build Step".

Inside the box marked "Description", you can put whatever you like, but
I usually use the following text:

Relinking $(InputName).exe -> default.xbe

Inside the box marked "Command Line" you will need to use the following text:

cxbe -TITLE:"CXBX Demo" -OUT:"$(TargetDir)default.xbe" "$(TargetPath)"

You will probably want to replace the phrase "CXBX Demo" with the title
you want to use for your program.

Inside the box marked "Outputs" you will need to use the following text:

$(TargetDir)\default.xbe

After you have added these settings, just click "OK".

f) Adding XBoxStartup

The last requirement to complete your project configuration is to include
a valid entry point for your application. Typically, the below code is a
good place to start development from:

#include <openxdk.h>

void XBoxStartup()
{
HalReturnToFirmware(ReturnFirmwareFatal);
return;
}

Note: After you run the above code, your xbox will go to the "fatal" boot
screen. It is ok, nothing is harmed, it is simply a demonstration of what
OpenXDK can do. (Your Xbox will be back to normal after rebooting).

g) Building Your Project

If everything went well, you now have a valid project, and you can
immediately start developing. Try building your project containing
only the simple entry point as shown above, and if all goes well,
your build will succeed and the file "default.xbe" will be created.

You should be able to run this executable on a modded xbox.








bob1122 have fun reading . and someone let me edit my post

#14 d0wnlab

d0wnlab

    X-S Expert

  • Moderator
  • PipPipPip
  • 557 posts
  • Xbox Version:unk

Posted 28 January 2005 - 04:19 AM

see bob this is why i disliked you posting this in the first place.

the above information is totally wrong, and will not work. All it does is gets peoples hopes up to use openxdk with visual studio and it won't work, and then they don't bother trying cygwin because they already tried and failed with visual studio. to begin with there is no .sln project file in openxdk anymore, hasn't been for a long time. Namely, it was gotten rid of when the openxdk moved from Visual Studio to gcc toolchains. Long since gone. Check the cvs. It ain't there.

your libraries are all wrong too.. we don't use the xlib* libs anymore (if ever, im unsure..)

In fact I'm pretty sure you cut and pasted this from somewhere else because quite simply I've never seen you make sentences this well, and most of it matches info from years ago.

#15 nangsyde

nangsyde

    X-S Young Member

  • Members
  • Pip
  • 36 posts

Posted 28 January 2005 - 09:42 AM

QUOTE(d0wnlab @ Jan 28 2005, 04:50 AM)
In fact I'm pretty sure you cut and pasted this from somewhere else because quite simply I've never seen you make sentences this well

View Post


Harsh...but pretty funny




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users