Jump to content


Photo

Source Code Help


  • Please log in to reply
3 replies to this topic

#1 Pulsemasta

Pulsemasta

    X-S Expert

  • Members
  • PipPipPip
  • 725 posts
  • Xbox Version:v1.1
  • 360 version:unknown

Posted 09 January 2010 - 10:51 AM

Can someone tell me how exactly you compile source code into a working program? Say for instance I have the source code for Beats of Rage.... I open it up in Visual Studio and press "build", hundreds of compile errors come up.... shouldn't the source from xbins be the final product with no errors? Also does this have anything to do with the games media content (of which I couldn't find any)? Does the Xbox render the game entirely from code??

any help would be appreciated.

#2 obcd

obcd

    X-S Hacker

  • Moderator
  • PipPipPipPipPipPip
  • 2,737 posts
  • Xbox Version:v1.0
  • 360 version:none

Posted 09 January 2010 - 11:21 AM

Build is a 2 step thing.
In step 1, the source code c and c++ files will be compiled to object files. Most errors that appear are missing header files. In visual studio 2003 under the option tab, you have to tell the ide where it should search for include files. If the path setting isn't there, it will not find the include file. If you install your sources in a different folder, the include files will also exist in a different folder. I am even unsure that the include path settings are stored in the project file. I think they are global for the ide.

In step 2, the object files generated in step one are linked together.
They are also linked to a number of libraries. libraries are files that contain usable functions.
Those functions are usually defined in the header files.
Again, the ide needs to know where to search for the libraries.
If a library is missing, you will get a number of unresolved external errors.
This is due to library function calls in the code. If the function doesn't exist, the linker can't resolve the function call.

It's usually a good practice to install the existing version of your program (emulator) first. That way, you will be sure to have the correct artwork and font files for your program to run. Sometimes a downloaded source package only contains the source files to create the main xbe, and the artwork is not included as it usually hardly changes.

In case of the xbox, most programs are created using the xdk. This means that the code cam functions from the xdk library. There are several versions of that library, and some function calls can be missing in older xdk library versions. In that case, you will get an unresolved external as well during linking.

So basically, it's best to start with one C file at a time and just compile it instead of starting the full build. If it compiles without errors, you can jump to the next file. It's not possible to rush things, it simply won't work.

When all C code compiles, you can start the linking.

In the beginning, the number of errors will decrease fast. The last ones appearing are the most difficult.

Good Luck.




#3 Pulsemasta

Pulsemasta

    X-S Expert

  • Members
  • PipPipPip
  • 725 posts
  • Xbox Version:v1.1
  • 360 version:unknown

Posted 09 January 2010 - 12:38 PM

QUOTE(obcd @ Jan 9 2010, 11:21 AM) View Post

Build is a 2 step thing.
In step 1, the source code c and c++ files will be compiled to object files. Most errors that appear are missing header files. In visual studio 2003 under the option tab, you have to tell the ide where it should search for include files. If the path setting isn't there, it will not find the include file. If you install your sources in a different folder, the include files will also exist in a different folder. I am even unsure that the include path settings are stored in the project file. I think they are global for the ide.

In step 2, the object files generated in step one are linked together.
They are also linked to a number of libraries. libraries are files that contain usable functions.
Those functions are usually defined in the header files.
Again, the ide needs to know where to search for the libraries.
If a library is missing, you will get a number of unresolved external errors.
This is due to library function calls in the code. If the function doesn't exist, the linker can't resolve the function call.

It's usually a good practice to install the existing version of your program (emulator) first. That way, you will be sure to have the correct artwork and font files for your program to run. Sometimes a downloaded source package only contains the source files to create the main xbe, and the artwork is not included as it usually hardly changes.

In case of the xbox, most programs are created using the xdk. This means that the code cam functions from the xdk library. There are several versions of that library, and some function calls can be missing in older xdk library versions. In that case, you will get an unresolved external as well during linking.

So basically, it's best to start with one C file at a time and just compile it instead of starting the full build. If it compiles without errors, you can jump to the next file. It's not possible to rush things, it simply won't work.

When all C code compiles, you can start the linking.

In the beginning, the number of errors will decrease fast. The last ones appearing are the most difficult.

Good Luck.



Thanks for the reply!

I will have to play around with it more, keeping your tips in mind.

Just to clarify, once I get the code to compile with 0 errors I should be able to take the XBE and put it in the file with the media files and the program should run?

#4 obcd

obcd

    X-S Hacker

  • Moderator
  • PipPipPipPipPipPip
  • 2,737 posts
  • Xbox Version:v1.0
  • 360 version:none

Posted 09 January 2010 - 09:24 PM

Yes, if you replace the default.xbe in the package with the one you just compiled, it should run on the xbox.

If you have a dual retail / debug bios, you can use the debug dash to test things out.
Visual Studio 2003 transfers the file over the network to the xbox and launches it there.
You can even set a breakpoint in the sources.
If the code execution arrives at the breakpoint, it will stop it's execution so that you can examine your variables. You develop much faster that way.

PS. You can only use it if you can use the xdk together with Visual Studio.

regards.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users