# [Tutorial] Setting up Visual Studio 2017 environment for Nintendo Switch homebrew development

19,516 64 17

1. ### eyeliner Has an itch needing to be scratched. Member Level 11

Joined:
Feb 17, 2006
Messages:
1,581
Country:
This should be it.
I didn't include them.

2. ### eyeliner Has an itch needing to be scratched. Member Level 11

Joined:
Feb 17, 2006
Messages:
1,581
Country:
Bah, now it rants that it can't find SDL.h and SDL_image.h in the #includes.
I downloaded SDL2 and SDL_image sources and slapped them in the include folder of devkitPro.
I have serious difficulties wrapping my head around c/c++ configuration.

This thing can be simple, but it really is not...

3. ### OP Manurocker95 Game Developer & Pokémon Master Member Level 10

Joined:
May 29, 2016
Messages:
1,431
Country:
If you want to use my helper, it includes everything by default. Just include sdlHelper.h
Use pacman instead. You just need to use pacman -Syuu packagename and to know the packages' name pacman -Sl

— Posts automatically merged - Please don't double post! —

When doing pacman -Sl be sure you have them installed

eyeliner likes this.
4. ### eyeliner Has an itch needing to be scratched. Member Level 11

Joined:
Feb 17, 2006
Messages:
1,581
Country:
switch-sdl2 reports as installed.
I'm using your helper: #include "sdl_helper.hpp"

SDL_Texture * myTexture is always marked as undefined. I have no idea what is wrong, really, I don't.

Do I have to get ALL your files in my source folder? Or only those 4 you specifically mentioned?

5. ### OP Manurocker95 Game Developer & Pokémon Master Member Level 10

Joined:
May 29, 2016
Messages:
1,431
Country:
No, you need to have it linked in the makefile and your VS solution

6. ### eyeliner Has an itch needing to be scratched. Member Level 11

Joined:
Feb 17, 2006
Messages:
1,581
Country:
Then I have no idea of what I am doing.
Thanks for the patience.

7. ### OP Manurocker95 Game Developer & Pokémon Master Member Level 10

Joined:
May 29, 2016
Messages:
1,431
Country:
Don't worry. Take my template and try to compile it using make. If you can compile it that way, download the solution, open it and use it as base if you want

eyeliner and lordelan like this.
8. ### JupiterJesus Member Newcomer Level 3

Joined:
Jul 14, 2018
Messages:
42
Country:
When installing sdl using the provided pacman command line, I had to replace "switch-sdl" with "switch-sdl2" to get it to work. switch-sdl just gives an error, no such library found.

I also had to add "path\to\devkitPro\portlibs\switch\include" to my vc++ directories include list. I guess that's where sdl2 got installed.

Finally, I couldn't just include <SDL.h>. I had to include <SDL2\SDL.h>, since the SDL includes were in "path\to\devkitPro\portlibs\switch\include\SDL2". Similarly, #include <SDL2\SDL_Image.h>.

I also needed more than the 4 files listed from the template github project, since other files are #included from the ones we use. These were Settings.hpp and Colors.h.

Finally for real this time, I had to remove -lavformat -lavcodec -lswresample -lswscale -lavutil -lbz2 -lass -ltheora -lvorbis -lopus from the LIBS definition in the makefile. Maybe these are libs that are required by some of the SDL2 libs, but the tutorial didn't give instructions to install them and the obvious thing (calling pacman to install the missing libs) didn't work, at least not with the obvious names e.g. avformat, avcodec, etc.

At this point the Makefile compiles. The only thing left is that I get intellisense errors when including stdio.h, stdlib.h, string.h and other C std libraries. I don't know why - seems like these of all things should be a simple thing for VS to find.

9. ### urherenow GBAtemp Psycho! Member Level 10

Joined:
Mar 8, 2009
Messages:
3,809
Country:
Why? Why do this? Use devkit like it was intended to be, and use pacman/dkp-pacman to keep the libraries up to date. Using different setups will create different bugs and end up being a headache for devs. People are likely to end up using the wrong gcc, and wrong "standard" libraries. Devkit installers/scripts are available for all systems. If you're not using ubuntu bash on windows subsystem, the proper thing to use is msys2 (included when you simply install devkitpro with the installer).

Last edited by urherenow, Mar 31, 2019
10. ### OP Manurocker95 Game Developer & Pokémon Master Member Level 10

Joined:
May 29, 2016
Messages:
1,431
Country:
Using pacman -Sl you can see the names of the libraries. You just need to install the ones you wanna use. In my template I use the ones you see here. If you cant include sdl you maybe didn’t link the includes correctly or didn’t install the libs correctly.

— Posts automatically merged - Please don't double post! —

I use VS because it is A LOT easier to develop stuff on windows if you are used to it. If you don’t want to use it, don’t do it. It works flawlessly for me.

eyeliner and lordelan like this.
11. ### Zorn_Taov Newbie Newcomer Level 2

Joined:
Apr 15, 2013
Messages:
5
Country:
is this because you haven't figured out the 435 errors starting with "cannot open source file "errno.h"" in the Error List? I made sure to include the portslib\switch\include folder and installing "Windows 8.1 SDK" though I couldn't find "UCRT SDK". I can compile just fine and the compiled .NRO works on my switch, but it'd be good to squash all errors, especially errors like these.

12. ### OP Manurocker95 Game Developer & Pokémon Master Member Level 10

Joined:
May 29, 2016
Messages:
1,431
Country:
Are you using your own makefile? Are you running Windows 8.1 or Windows 10? Did you try opening an already created project?

Last edited by Manurocker95, Apr 15, 2019
13. ### Zorn_Taov Newbie Newcomer Level 2

Joined:
Apr 15, 2013
Messages:
5
Country:
started with the devkitpro/examples/switch/templates/application/makefile, changed it so the .nro/.nacp/.elf files end up in $(CURDIR)/Output/$(TARGET), then changed LIBS and LIBDIRS to
Code:
LIBS := -lpu -lfreetype -lSDL2_ttf -lSDL2_gfx -lSDL2_image -lSDL2 -lEGL -lGLESv2 -lglapi -ldrm_nouveau -lpng -ljpeg sdl2-config --libs freetype-config --libs -lnx
LIBDIRS := $(PORTLIBS)$(LIBNX) \$(CURDIR)/Plutonium
so that I could use Plutonium for a menu system. I'm using Windows 10 and created a new project by the tutorial in the opening post you made.

14. ### OP Manurocker95 Game Developer & Pokémon Master Member Level 10

Joined:
May 29, 2016
Messages:
1,431
Country:
I got so many problemas with Plutonium but if you have everything installed, it should work without issues. Hmm, can you compile any of my hbs? I tested to open one of my solutions and it works fine

15. ### Zorn_Taov Newbie Newcomer Level 2

Joined:
Apr 15, 2013
Messages:
5
Country:
well after installing everything starting with "switch-" in pacman, I got WhatsInTheBox to compile and run on the switch and it's the same situation. Almost all of these errors are actually errors in intellisense being unable to find those source files for some reason. Here's a CSV file of the errors when looking at the main.cpp of WhatsInTheBox. pastebin EdneqQ22 and just put that into a spreadsheet to read it easier

EDITED:
I eventually found "Windows Universal CRT SDK" which is the UCRT SDK listed above and I think that got rid of most of the errors(?) Though intellisense still can't find sys/lock.h and stdalign.h.

EDIT 2:
I've given up on using Plutonium. it's using C++17 only things and visual studio won't comply to my makefiles settings in that regard, thus adding to the warnings that don't actually break the compiler.

Last edited by Zorn_Taov, Apr 15, 2019
16. ### wstlxx Member Newcomer Level 2

Joined:
Apr 29, 2019
Messages:
11
Country:
Hello Manurocker95, I am trying to set up the whole environment with visualstudio 2019 .The build was a huge success, thank you for the tutorial.
May i ask if there is a proper way to do some debug?
Is it gonna be tools like GDB?

17. ### OP Manurocker95 Game Developer & Pokémon Master Member Level 10

Joined:
May 29, 2016
Messages:
1,431
Country:
For 3DS, Citra displays logs but YuZu AFAIK doesn't, so... :/

On real hardware, you can use nxlink to debug logs. I never got used to it so I used my own text rendering for debugging.

Last edited by Manurocker95, Apr 29, 2019
18. ### wstlxx Member Newcomer Level 2

Joined:
Apr 29, 2019
Messages:
11
Country:
I just found a tool named Twili. I haven't fully understand it yet ,but i think it will be of good use.

19. ### Gigaboy Member Newcomer Level 2

Joined:
May 12, 2019
Messages:
31
Country:
So, I got this working and I was extremely happy there was no compilation errors and such. I compiled your just the main.cpp file you provided and it works first try (amazingly). But then VS said there was errors, so without changing any code I rebuild the solution and it doesn't compile now. So, I open my terminal and enter "make" and it gives me an error with a .elf file. Any suggestions?
Code:
collect2.exe: error: ld returned 1 exit status
make[1]: *** [/opt/devkitpro/libnx/switch_rules:80: /home/imado/source/repos/Switch-Sandbox/Switch-Sandbox.elf] Error 1
make: *** [Makefile:165: build] Error 2
EDIT:
Actually, I lied. I did modify the code. I added "using namespace std;" and remove all the "std::"s and changed "char* argv[]" to "char** argv". But that was before the first build when it still worked.

ANOTHER EDIT:
I got it to work myself. Turns out I typed one of the libraries wrong in the makefile where I modified LIB variable.

Last edited by Gigaboy, May 12, 2019
20. ### mo_v Member Newcomer Level 1

Joined:
May 9, 2019
Messages:
21
Country:
I don't know what you mean by ProjectDir where do you find that.

Draft saved Draft deleted