How to compile and debug ddnet on Windows in Visual Studio

Read tips and guides about teeworlds-related subjects (mapping, compiling, ..).
milk
Posts: 207
Joined: Mon May 05, 2014 5:25 pm
Player profile: http://ddnet.tw/players/milk/

How to compile and debug ddnet on Windows in Visual Studio

Post by milk »

How to compile and debug ddnet on Windows in Visual Studio
written by milk

There are already some teeworlds compiling tutorials for Windows (1, 2) but they are a bit outdated and not really friendly for newcomers with not quite good programming skills. I tried to make my own tutorial based on these but more extended and intuitive.
I hope this tutorial will help someone and save some time.
  • Let's start.
    You'll need Windows 7,8 or 10, 32/64 bit. Probably it should work on Windows XP SP3 too.

    1. Install Visual Studio 2. Get ddnet sources
    • 2.1 Download archive with ddnet sources from https://github.com/ddnet/ddnet using "Download zip" button.
      2.2 Extract it wherever you want (For example to "C:\ddnet\"). This is will be your project directory.
      SpoilerShow
      scr1.png
      scr1.png (55.53 KiB) Viewed 14263 times
    3. Install Python 4. Compile and install bam
    • 4.1 Download bam from https://github.com/matricks/bam using "Download zip" button.
      4.2 Extract it wherever you want (For example to "C:\bam\").
      4.3 Execute the file make_win32_msvc.bat, bam will compile itself.
      4.4 Copy the compiled file bam.exe to your project directory (For example to "C:\ddnet\").
    5. Setup Visual Studio project
    • 5.1 Download ddnet_visual_studio_project.zip and extract it to your project directory (For example to "C:\ddnet\").
      ddnet_visual_studio_project.zip
      (2.07 KiB) Downloaded 571 times
      5.2 Run the file ddnet.sln and Visual Studio will open your project.
      5.3 Press button "Show all files", right click on "src" folder and press "Include In Project".
      SpoilerShow
      scr2.png
      scr2.png (31.15 KiB) Viewed 14261 times
      5.4 Now you can start to edit sources, compile and debug! There are 6 project configurations:
      SpoilerShow
      scr3.png
      scr3.png (29.91 KiB) Viewed 14263 times
      • 5.4.1 Select client_release or server_release and press Debug->Build Solution in menu (or F7) to build client or server releases.
        If everything is ok, compiled files will appear in your project directory.
        5.4.2 Select client_debug or server_debug and press Debug->Start Debugging in menu (or F5) to compile and start debugging client or server.
        SpoilerShow
        scr4.png
        scr4.png (157.01 KiB) Viewed 14263 times
      5.5 (Optional) If you want to compile server_sql_release or server_sql_debug, you need to:
If you have some questions, suggestions or remarks, post them in this topic.
Last edited by milk on Tue Jan 19, 2016 9:45 pm, edited 4 times in total.
milk
Posts: 207
Joined: Mon May 05, 2014 5:25 pm
Player profile: http://ddnet.tw/players/milk/

Re: How to compile and debug ddnet on Windows in Visual Studio

Post by milk »

FAQ:
  • Q: I got compilation error in Visual Studio 2010:
    • LNK1123: failure during conversion to COFF: file invalid or corrupt
    A: There is a simple solution:
    Just remove or rename file "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\cvtres.exe"
    Here is explanation why is it so: http://stackoverflow.com/a/14144713/5720164
    Now clean the project and try to compile again.
    SpoilerShow
    scr7.png
    scr7.png (21.67 KiB) Viewed 14151 times
Last edited by milk on Tue Jan 19, 2016 9:37 pm, edited 1 time in total.
User avatar
kamillentee
Posts: 687
Joined: Sat Jul 26, 2014 11:47 pm
Player profile: http://ddnet.tw/players/kamillentee/
Clan: |*KoG*|

Re: How to compile and debug ddnet on Windows in Visual Studio

Post by kamillentee »

good work!
HMH
Posts: 145
Joined: Mon May 05, 2014 8:41 pm
Player profile: http://ddnet.tw/players/HMH/

Re: How to compile and debug ddnet on Windows in Visual Studio

Post by HMH »

Very nice work ! There is just a tiny thing you should definitely change: https://matricks.github.io/bam/ indeed offers bam-0.4. The problem is that the script thats builds bam does not support any Visual Studio version beyond Visual Studio 10. The download there is simply outdated. Instead use: https://github.com/matricks/bam/archive/master.zip
User avatar
Ryozuki
Posts: 1748
Joined: Tue Feb 24, 2015 7:28 am
Location: Catalonia
Player profile: http://ddnet.tw/players/Ryozuki/
Mapper profile: http://ddnet.tw/mappers/Ryozuki/
Clan: Unique
Website: https://edgarluque.com
Discord: Ryozuki#2188

Re: How to compile and debug ddnet on Windows in Visual Studio

Post by Ryozuki »

would be cool if you add that info on the wiki :)
milk
Posts: 207
Joined: Mon May 05, 2014 5:25 pm
Player profile: http://ddnet.tw/players/milk/

Re: How to compile and debug ddnet on Windows in Visual Studio

Post by milk »

HMH wrote:Very nice work ! There is just a tiny thing you should definitely change: https://matricks.github.io/bam/ indeed offers bam-0.4. The problem is that the script thats builds bam does not support any Visual Studio version beyond Visual Studio 10. The download there is simply outdated. Instead use: https://github.com/matricks/bam/archive/master.zip
Thank you! Fixed.
Ryozuki wrote:would be cool if you add that info on the wiki
Oh, I forgot about wiki. I'll add this later.
pixel
Posts: 430
Joined: Sun Nov 22, 2015 8:44 pm
Player profile: http://ddnet.tw/players/pixel
Mapper profile: https://ddnet.tw/mappers/pixel/
Clan: Bitfighter

Re: How to compile and debug ddnet on Windows in Visual Studio

Post by pixel »

Question: Is there a ddnet_visual_studio_project.zip for normal teeworlds? like teeworlds_visual_studio_project.zip????
User avatar
justafish
Posts: 58
Joined: Sun Dec 18, 2016 7:49 pm
Location: Sweden
Player profile: https://ddnet.tw/players/Just%20a%20fish/

Re: How to compile and debug ddnet on Windows in Visual Studio

Post by justafish »

I have been trying to follow this guide, but I just can't get it to work.
Here is what I get in Visual Studio Express 10.0:
http://pasted.co/aae99a7a

Errors everywhere! Can someone please help me? :/
Smoking kills. If you're killed, you've lost a very important part of your life.
User avatar
deen
TECHNICAL Team
Posts: 3575
Joined: Mon May 05, 2014 2:30 pm
Player profile: https://ddnet.org/players/deen/
Discord: deen#5910

Re: How to compile and debug ddnet on Windows in Visual Studio

Post by deen »

The C files should be compiled with a C compiler, not with a C++ one. That's all I can tell though, hopefully someone with Visual Studio experience can chime in.
BeaR
Posts: 54
Joined: Fri May 30, 2014 10:18 am
Player profile: http://ddnet.tw/players/BeaR/

Re: How to compile and debug ddnet on Windows in Visual Studio

Post by BeaR »

Looks like the scripts for generating the protocol files aren't executed properly. Either call them manually or fix your python setup.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests