compiling an SFML c++ program on a Windows computer

I have an old Dell laptop that has Windows 10. I have tried a few times to install g++ (unsuccessful) and install SFML (will not compile even the most simple program) in order to compile a program I've written on my Mac. I can think of two possible solutions: Ask if anyone on cplusplus.com will compile the program and return the executable to me or ask if someone on cplusplus.com wants to assist in getting g++ or possibly even using Microsoft's IDE with whatever compiler it uses. I'm open to either solution if someone cares to help.
Last edited on
If your laptop can handle it I'd personally suggest either Visual Studio 2019 or 2022, there is a free Community edition.

If you have the HD space, RAM and CPU there's a package manager that makes integrating 3rd party libraries into VS almost a snap. vcpkg.
https://vcpkg.io/en/index.html

vcpkg can also be used with CMake.

MSYS2 is also possible as a development environment that isn't as heavyweight as VS.
https://www.msys2.org/


Oh, I forgot to mention both VS 2022 and MSYS2 require a 64-bit processor. VS2019 doesn't.

Another IDE is Code::Blocks.
http://www.codeblocks.org/

FYI, I've never used SMFL beyond a bit of testing, but I have used vcpkg to integrate it into Visual Studio.

If you aren't interested in using the current C++ language standard, C++20, Visual Studio 2017 is also a possibility.
George P. and this forum,
I installed git. I followed the instructions from the page you recommended. I followed the instructions including the one that didn't work until I located vcpkg.exe which was installed into my home directory instead of where I expected. The program took 11.5 minutes to configure, install, copy, whatever it was doing. I then opened the most basic SFML window project in MS Visual Studio which I had copied from the SFML website some time ago. I tried to compile it and got EIGHTEEN errors and four warnings.
I could think of some very descriptive 4 letter words to describe this experience but I will not. Instead, I restate my original requests. Will someone please either compile the program for me and return the executable or supply a WORKING solution so I can use SFML with either g++ or VS? Thank you.
First, delete your old installation of vcpkg because it's in your desktop and your desktop doesn't have a short path name. Download it again, but this time into a better spot. Open an unprivileged shell. Change the current directory to the vcpkg directory and run the bootstrap script again. Then in an elevated shell, run vcpkg integrate install as root and exit the root shell.

Finally, as a normal user, say vcpkg install sfml:x86-windows sfml:x64-windows to install both x86 and x64 versions of the library. Both versions, for simplicity.

Now close VS if it's open and reopen it as a normal user. At this point you should be able to compile your code. If not the program doesn't use MSBuild and we have to talk about configuring the build system or pointing Visual Studio to the libraries & headers that were just installed.
Last edited on
When you installed VS, did you change the installer configuration to actually install C++? By default C+ is not selected to be installed, You have to tell the installer to manually.
Let me restate my question. On my Mac, I can open a terminal window and run g++ from anywhere and it will compile. With the proper switches, it will also link, create an executable app and include the markers to run the debugger. I had X-code installed before I started using g++, so maybe the command relies on some components of X-code. When I ask g++ for its version, I get
Apple clang version 13.1.6 (clang-1316.0.21.2.5)
Target: x86_64-apple-darwin21.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
Is there a way I can have this on Windows? I would like to be able to run g++ or gcc or even something else if someone has a suggestion that will compile and link to a Windows command-line executable. BTW, it needs to include SFML.
To bring followers of this thread up to date, if I open a command window on the current setup and do dir c:\cpp.exe /s/p, I get about 7 or 8 of them including MS version, plus many others that I tried and couldn't make work. If I do dir c:\iostream*.* /s/p, I get several of those, too.
I said it before, and you seemingly ignored it, ffej2ffej....

Use MSYS2, it is command-line compiling, using Mintty with Bash and other tools you are probably used to.
https://www.msys2.org/

One major issue is MSYS2 requires a 64-bit processor.

If your processor is 32-bit you can download MinGW or other command-line compilers. They aren't as integrated with support tools as Visual Studio or MSYS2.
There's no need to restate the question, you've already said what you want.

Help us help you. The claim
"I couldn't make it work."
Doesn't give us enough information to find a solution.

Tell us what you tried, what happened, and what you expected. Be specific.
Last edited on
mbozzi, I am currently in the process of downloading, compiling and integrating SFML into Visual Studio using vcpkg as I type this.

To say "I couldn't make it work" shows they are not following/understanding the very plain instructions for how to use vcpkg.

Which BTW doesn't require Visual Studio being installed. All that is required is having git installed and a bit of "take one's time."

Should the install be borked simple delete the directories created, there are two if VS integration is installed, and start the process over again. That is what I am doing, this is my7th install in about 4 months.

This time I'm documenting what I am doing. :Þ
FYI, until I starting using vcpkg I had never been able to get a 3rd party library other than Boost to compile and work properly with any compiler I use.

Now it is almost too easy, I've installed probably more libraries than I need. One of the reasons why I've deleted the dirs and started over so many times.
This time I'm documenting what I am doing


Always a good idea..

Also, cmd.exe maintains a history of the last 50 commands entered. These can be accessed and viewed.

See https://ss64.com/nt/syntax-keyboard.html

and the section on command history shortcuts.

https://www.windowscentral.com/how-access-command-history-command-prompt

Which explains how to export command history to a file - useful to create a batch file of what has been done...

Also you should be familiar with doskey
https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/doskey
Last edited on
I am documenting what I am doing by writing an external "diary" text file of my thoughts of mashing on vcpkg, along with what packages I've installed currently.

One thing I like about vcpkg... a bane of using 3rd party libraries for even experienced users is "does the fool thing have any dependencies?"

With vcpkg when installing a library it supports, say SFML for example, it also downloads any other needed libraries and compiles the entire lot.

Here's the vcpkg install command I used:
vcpkg install smfl:x64-windows sfml:x64-windows-static sfml:x86-windows
Start the process and go away for about 20 minutes.

Afterwards when it completes I now have integrated into VS a 64-bit dynamic library version (debug & release versions), a 64-bit static lib version (debug & release versions), and a 32-bit dynamic lib version (debug & release versions). As well as access to the library's header that are IDE searchable, same as the C++ stdlib headers are.

Re: the Command Prompt....

I've been using computers since the Before Times. Before Windows 1.0. MS-DOS 2.0. Being a keyboard warrior is "in muh blood".

OS/2 Warp was slated to be the IMB PC OS instead of MS DOS/Windows 1.0. *sigh*
Last edited on
Re: the Command Prompt....


Fair doos. But others reading this topic might not know about these. I started with Compaq MS-DOS 1 about 1983...
Heh, that is why I mentioned The History. So a yute possibly reading this understands I ain't just some "jumped off the rutabaga lorry at Fleet Street" type.

I add such tiffle-bits from time to time myself.
Here is the latest update to this ongoing saga. I have followed the instructions of many people here and elsewhere on the 'net. Most things create a shortcut to an IDE that I cannot use for the library I'm trying to use.
I recently goofed around with MS VS recently. I found an option in the IDE to compile only and much to my surprise, the program, including SFML compiled perfectly. The result is a filename.obj in the same directory as the source. However, when I try to link (I think I used VS command window for this) I got some message about the back end not matching the front end. Good thing they didn't state it in American English that I can understand and do something about. Any further help is appreciated.
I'll say it again and then I'll "Elvis Has Left The Building".

Step Zero: Make sure git is installed. I seriously suggest getting the "git for Windows" package, it integrates into the Windows/File Explorer shell quite well, adding some right-click menu shortcuts. Git For Windows has a GUI client, and a Bash clone.

Step One: Follow the instructions for getting and installing vcpkg here.
https://vcpkg.io/en/getting-started.html

DO NOT install it on the frinkkin' Desktop. Create a simple directory off the drive's root. C:\libs for example.

What is not explained well is that when cloing a github repository git will create a new directory inside the directory your command prompt is currently seated on. If you started your command prompt at C:\libs the git clone command will create a sub-dir C:\libs\vcpkg.

This is normal, this is what should happen.

DO integrate vcpkg into Visual Studio. With vcpkg integrated the IDE acts as if any vcpkg you install as being native to the IDE. No need to add directory locations.

After successfully installing and integrating vcpkg you can now download SFML. I really recommend the following command:
vcpkg install smfl:x64-windows sfml:x64-windows-static sfml:x86-windows
That installs three different versions of the SMFL package. x86, x64 and an extra x64 static version so your app shouldn't require any SFML DLLs.

Doing this install takes about 20-30 minutes. Start the install and let the computer do the magic.

Pax, peeps.
Topic archived. No new replies allowed.