Before you begin

Use the source or a DLL?
RakNet includes the source and a pre-made DLL, along with sample projects to make a DLL, use a DLL, and use the source. You may use either in your game. During development, you will probably want to use the source so you can trace into the code for better control. During release, you will probably want to use a DLL so you don't have to make your game multithreaded, and for easier patching.

Project files are included for .net and vc6 in the root directory:
The DLL and the sample projects were created using Microsoft Visual Studio .net 2003. Users of other compilers will have to make their own DLL.

DLL Users

Creating a DLL

1. Create a DLL project. I'll assume you know how to do this. In MSVC 7 you would create an empty project, then under Application Settings you check DLL and empty project.
2. Add the source files under the /Source directory to the project. If you don't plan to use voice capabilities, leave out everything with "RakVoice" in the filename.
3. If you want to use voice capabilities, add the source files under the speex-1.1.4\libspeex directory except the four that start with test, speex_preprocess.h, and preprocess.c.
4. Add to "Additional Include Directories" your directory with the source files.
5. Import ws2_32.lib, or wsock32.lib if you don't have Winsock 2 installed. In MSVC 7 you can right click on the project, select configuration properties / linker / input / additional dependencies and type "ws2_32.lib" in there.
6. Set your project to use multi-threaded runtime libraries. In MSVC 7 you can right click on the project, select configuration properties / C/C++ / Code Generation / Runtime Library and change it to Multi-threaded (/MT).
7. Optionally set your preprocessor directives.
8. Then hit F7 or the equivalent to build your DLL and Lib.

Creating an empty DLL project in .net 2003

Setting Multithreaded debug in .net 2003

Including ws2_32.lib in .net 2003

Game Setup

1. Copy the DLL you just created to your game in the same directory as the exe. The lib can be in any directory you want.
2. Add the .lib to your project
3. Add the required source files to your project:

- NetworkStructures.h (Optional - if you want to define packet structures)
- Source/Optional/* (Optional - to use distributed objects and/or the multiplayer class)
- SHA1.cpp (Optional - if you do file verification as in the sample)
- GetTime.h/.cpp (Helper class, also required if you include Source/Optional/*)
- BitStream.h/.cpp (Helper class, also required if you include Source/Optional/*)
- RakNetworkFactory.h
- RakClientInterface.h
- RakServerInterface.h
- RakPeerInterface.h
- NetworkTypes.h

If you get any linking errors related to a bitstream, you should also include Bitstream.cpp and Bitstream.h
If you want to jump right in, refer to the Basic code tutorial
For more detail, refer to Detailed Implementation

Source users

Game Setup

1. Add the source files under the /Source directory to the project. While not all of these are strictly necessary, the ones you don't use won't hurt you. However, if you don't plan to use RakVoice, you should not include anything with RakVoice in the filename or otherwise you will have to include all the speex files.
2. If you plan to use RakVoice, add the source files under the speex-1.1.4\libspeex directory except those that start with test, speex_preprocess.h, and preprocess.c.
3. If you plan to use RakVoice, add to "Additional Include Directories" ..\..\..\Source;..\..\..\speex-1.1.4\libspeex
4. Import ws2_32.lib, or wsock32.lib if you don't have Winsock 2 installed. In MSVC 7 you can right click on the project, select configuration properties / linker / input / additional dependencies and type "ws2_32.lib" in there.
5. Set your project to use multi-threaded runtime libraries. In MSVC 7 you can right click on the project, select configuration properties / C/C++ / Code Generation / Runtime Library and change it to Multi-threaded (/MT).
6. Set an additional include path to include the RakNet source (if you copied the source files to a different directory).
7. Optionally set your preprocessor directives.

Setting Multithreaded debug in .net 2003

Including ws2_32.lib in .net 2003

See Also

Index Introduction System Overview Detailed Implementation Tutorial