Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: how do I build SMFL with VScode and MSCV?  (Read 1141 times)

0 Members and 1 Guest are viewing this topic.

chip3690

  • Newbie
  • *
  • Posts: 2
    • View Profile
how do I build SMFL with VScode and MSCV?
« on: July 21, 2022, 11:46:35 am »
OK forgive the basic question but I've done this to death and I'm ready to rage quit.
All I wanted was to get into coding C++ and use a library to render to screen, simple hello world stuff
I've been here for days, read the tutorials, the wiki, the README, the forum, Google, Youtube ect,ect.

What I'm using:
Windows 10 Home x64
VScode 2022
MSCV v19.32 (lib.exe, cl.exe, link.exe)
CMake Tools (code plugin) v1.11
SFML v3.0 (github master)
Nmake v14.32

What I tried:
1. Go to SFML/Downloads > Download a Visual c++ 2017 windows package > add to project
1.a add "includePath": ["${workspaceFolder}/lib/**"],  to c_cpp_properties.json (VScode can see SFML/Graphics.hpp)
1.b Pass SFML/include & sfml-graphics.lib, sfml-windows.lib, sfml-system.lib to cl.exe in tasks.json
1.c Add .dll files to src folder
Run cl.exe compiler
>Linker error (I tried multiple flags, passing to compiler and linker multiple ways, no luck)
I assume this is because of compiler mismatch. website states:  compiler versions have to match 100%!

2. git clone SFML (master) -> into Project_dir/lib/SFML_source
2.a run cmake -S ./SFML_source -B ./SFML_build -G"NMake Makefiles"
2.b run cmake --build ./SFML_build --config Release
2.c run nmake all

what I'm left with is a mess of files, a bunch of directories, a bunch of .obj files, the /lib with the sfml-graphics.lib etc
but no header files? VScode can not find SFML/Graphics.hpp..

what have I done wrong?
what next?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: how do I build SMFL with VScode and MSCV?
« Reply #1 on: July 21, 2022, 02:16:45 pm »
When you use cmake --build you don't need to call nmake afterwards, as CMake already called it with the previous command.

I recommend to set an install directory and then build the install target:

cmake -S ./SFML_source -B ./SFML_build -G"NMake Makefiles" -DCMAKE_INSTALL_PREFIX=<some absolute install path>
cmake --build ./SFML_build --config Release --target install
 

If you use CMake, you can also consider using  this template, which pulls down SFML and builds it automatically, when you build your project: https://github.com/eXpl0it3r/cmake-sfml-project
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

chip3690

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: how do I build SMFL with VScode and MSCV?
« Reply #2 on: July 21, 2022, 02:48:08 pm »
Thanks eXpl0it3r,

I just got it to work .. sort of.
Although I may have been building twice with the cmake and nmake commands
I wasn't looking to install, wanting to keep all dependencies and lib files in the project.

I found the header files, I was not expecting them to be in the source folder, I was expecting them in the build folder.

I had found your template, (thank you) I was rather determined to learn how to build myself, I may look to using your cmake template now and modify as I need.

Now VSCode is finding multiple compile issues with the Libraries  :'(
I might try again with 2.6 and see how I go.