For testing, we're going to use the sample "Chat Example" provided with the Raknet. You can find it the "Samples/Chat Example" folder.
This sample has 2 source files, named "Chat Example Server.cpp" and "Chat Example Client.cpp".
We are going to create two projects from those files (one project for the Server, and another for the Client).
Inside the folder where you have your workspace, create another folder named Samples,
and copy "Chat Example Server.cpp" and "Chat Example Client.cpp" into that folder.
- Create a Command Line Tool project for the Server:
In the next window where it asks for the options for your new project, name it ChatExampleServer,
leave Type as C++, and "Use Automatic Reference Counting" unchecked.
Save the project inside your Samples folder.
-
Inside the newly created ChatExampleServer, you should have a group named ChatExampleServer.
Delete the main.cpp you'll find inside that group, and add the "Chat Example Server.cpp" file
-
Specify where to look for the RakNet header files, by changing the Build Settings of the ChatExampleServer project.
This can be done in the Header Search Paths option, under the Search Paths section:
If your folder structure is exactly the same as the one used for this tutorial, then the search path
should be what you see in the above image. If not then you need to adjust it accordingly.
NOTE: The search path is relative to the project file's location.
-
Link ChatExampleServer project with our RakNet static library, by going to Build Phases, section
Link Binary With Libraries, clicking the '+' button and picking our RakNet library as shown:
-
You should be able to successfully build and run the Server now.
The steps to create the client project are the same as the ones for the Server:
- Create a "Command Line Tool" project, and name it ChatExampleClient
- Delete the file main.cpp and add the file "Chat Example Client.cpp"
- Change the C/C++ compiler to LLVM GCC
- Set the header search paths
- Add RakNet library to the list of libraries to link with.
You should now have 2 products ready to run (ChatExampleClient and ChatExampleServer). You can run
one of them from inside Xcode, and run the other externally by right-clicking on it and selecting
"Open With External Editor".
|