setting up sfml - c++

I'm following the sfml getting started guide for version 2 and codeblocks and did everything the tutorial told me to do :
downloaded and unzipped the sdk
added the path to the sfml headers and libraries
linked the libraries graphics, window and system
but the sample code doesnt work. I'm getting the error message that sfml-graphics-d-2.dll is missing. Compilation works, the window opens but remains black and this error pops up.
Here's the link to the tutorial
http://www.sfml-dev.org/tutorials/2.0/start-cb.php
Since Im new to c++ and codeblocks, I would be grateful for a detailed answer.
UPDATE:
I have copied the SFML dlls to the executable. Now my program just crashes. I don't know why. It's the exact same code as used in the tutorial.
UPDATE:
I have changed the linked libraries to the -s version and added the #define SFML_STATIC. The program still builds and then crashes

If you're using the latest Code::Blocks version, which includes GCC 4.7.1, then you have to recompile SFML on your own (or use my Nightly Builds), because the ones provided are only for GCC versions < 4.7.x.

It seems you aren't setting up your static libraries to be built inside the project, and instead using dynamic linking with your SFML. I had a similar problem when setting up SFML a couple months ago, recall this quote:
The settings shown here will result in your application being linked to the dynamic version of SFML, the one that needs the DLL files. If you want to get rid of these DLLs and have SFML directly integrated to your executable, you must link to the static version. Static SFML libraries have the "-s" suffix: "sfml-xxx-s-d" for Debug, and "sfml-xxx-s" for Release.
In this case, you'll also need to define the SFML_STATIC macro in the preprocessor options of your project.
make sure you include the static files in your project
sfml-graphics-s-d //for debug
sfml-window-s-d //d for debug!
sfml-system-s-d
for release, omit the d (sfml-graphics-s)
Next go to Compiler settings -> #Defines and type
SFML_STATIC

Regarding Visual Studio 2017 and SFML-2.5.1, I suggest this tutorial. Setting up SFML is similar to setting up SDL, GLFW, freeGLUT, and GLEW, with two peculiarities: .lib files are 29, and .dll are 11. Briefly I suggest:
1. Upload SFML and select first "Download". Copy downloaded folder and paste in a folder you created in C:.
2. Create Empty Project.
3. Configure "Additional Include Directories" with C:...\SFML-2.5.1\include.
4. Configure "Additional Library Directories" with C:...\SFML-2.5.1\lib.
5. In "Additional Dependencies" window copy and paste: flac.lib; freetype.lib; ogg.lib; openal32.lib; sfml-audio.lib; sfml-audio-d.lib; sfml-audio-s.lib; sfml-audio-s-d.lib; sfml-graphics.lib; sfml-graphics-d.lib; sfml-graphics-s.lib; sfml-graphics-s-d.lib; sfml-main.lib; sfml-main-d.lib; sfml-network.lib; sfml-network-d.lib; sfml-network-s.lib; sfml-network-s-d.lib; sfml-system.lib; sfml-system-d.lib; sfml-system-s.lib; sfml-system-s-d.lib; sfml-window.lib; sfml-window-d.lib; sfml-window-s.lib; sfml-window-s-d.lib; vorbis.lib; vorbisenc.lib; vorbisfile.lib
6. Navigate to C: > ... > SFML2.5.1 > bin. Copy all 11 dll files and paste in project-folder.
Good job. Regards.

Related

how to make my executable not rely on sfml dll files [c++] [minGW] [g++]

Perhaps I can "create" these necessary files by having them linked to the exe, and store them in a temp folder when the program launches, and if that's possible how please? I've tried messing around with compiler options but nothing seems to work.
In order your executable to not rely on DLL files, you should link them statically. SFML gives you that option by using their "sfml-xxx-s-d.lib" (for Debug) and "sfml-xxx-s.lib" (for Release) libraries, as stated in the documentation.
If you want to get rid of these DLLs and have SFML directly integrated
into your executable, you must link to the static version. Static SFML
libraries have the "-s" suffix: "sfml-xxx-s-d.lib" for Debug, and
"sfml-xxx-s.lib" for Release. In this case, you'll also need to define
the SFML_STATIC macro in the preprocessor options of your project.
NOTE: "xxx" stands for the name of the file you are trying to include into your project
Full documentation on how to set up SFML in VisualStudio: https://www.sfml-dev.org/tutorials/2.5/start-vc.php
Hope this answered your question! :)

I cant link against opengl32 in Windows

I am working on porting an app of mine that I made in OS X to Windows 10. I'm using visual studio 2015 Community Edition.
To get the project running, I need to link against GLFW and, in Windows as I understand, GLEW, since I am targeting GL 4.5.
So I have the glfw and glew libs. I also use Cygwin so I have the libs installed in usr/local/(bin | lib | include) to mimic the folder structure I'd use in OS X for these libs.
The issue I'm having is with the opengl lib itself.
Until yesterday, I had managed to get my project compiling and initializing the glfw window with the following visual studio settings:
Project->Properties-> :
C++->General:
Additional Include Directories:
C:\cygwin64\usr\local\include
Linker->General:
Additional Library Directories:
C:\cygwin64\usr\local\lib
C:\cygwin64\usr\local\bin
Linker->Input:
opengl32.dll
glew32s.lib
glfw3.lib
The first thing to notice is that I was linking against opengl32.dll, not .lib. I saw a bunch of questions / posts online that state that when you install Windows SDK you have a opengl32.lib in Program Files/Microsoft SDKs/Windows (x86 or otherwise). This is not the case for me. I have even reinstalled the Windows 10 SDK and it does not install any opengl lib, static nor dynamic, anywhere.
So I'm pretty sure that my opengl dll was coming from Windows/System32 because that is the only place in the whole machine where there is any sort of opengl lib.
Which makes me think I might have also had C:\Windows\System32 in the linker's additional library directories section. I say makes me think, because I had set this up with a lot of struggle about a week ago. Since then I was able to develop just fine.
Last night all I did was commit my work to a git branch, switch to another branch and merge to that branch. After the merge, all Visual Studio linker/C++ settings were wiped. So I had to recreate them, as I showed above.
Now what happens is that if I include C:\Windows\System32 and the opengl32.dll VS spits out:
LNK1107 invalid or corrupt file: cannot read at 0x2E0 OpenVRTest C:\Windows\System32\opengl32.dll
And if I don't include it obviously half the stuff in glfw is unresolved.
Any hints as to how to get this working again?
It makes no sense to me... It was working just fine and it has to have been working fine with this opengl32.dll
Also as a side note, I'm not sure why people insist that installing the Windows SDK installs a static version of the gl lib; at least it does not for me.
Linker->Input:
opengl32.dll
glew32s.lib
glfw3.lib
That opengl32.dll is wrong. In Windows development the linker always takes .lib files. In case of static libraries the .lib contains the actual library binary. In case of DLLs the corresponding .lib informs the linker about which DLL to use and which symbols it offers.
The main reason for this particular choice of how things are to be done was, that in Windows development it shall be possible to link against a DLL without having the actual DLL around.
Also system libraries always are suffixed …32 even on 64 bit systems.
The issue was that among the VS configuration settings that got wiped, were a couple things related to x86 vs x64 platform settings. So the project was now trying to build for 64bit linking against the 32bit dll in System32.
So that's that.
A separate issue is why a lot of answers speak of an opengl32.lib (static) that theoretically comes with the Windows SDK but I have not seen it anywhere. I just link against the dynamic one.

Setting up OpenGL projects in VS2010 with freeglut/glew

I am following the following tutorial my instructor used in class for a graphics class that started last week.
http://cse.spsu.edu/jchastin/courses/cs4363/labs/ProjectSetup/Project_Setup.html
I am trying to set this up under Win8 using VS2010 pro.
I copied freeglut.dll and glew32.dll to C:\windows\sysWOW64
I get to step 5 to include the include directories - http://i.imgur.com/XI1E63q.png
I get to step 7 to include the dependencies - http://i.imgur.com/aOChW8p.png
And finally to step 8 for the library directories - http://i.imgur.com/AzDvD9R.png
I try to compile and I get what seem to be linkage errors according to a quick google search - http://i.imgur.com/5GxhE9u.png
Google says its a linkage error but everything seems to be linked properly on my end. Is there something I am missing since this is under Windows 8?
Thanks for looking.
Edit: Playing around with the linker directories. I am linking them to:
\freeglut-2.8.1\lib\x86
\glew-1.10.0\lib\Release\Win32
takes the error count down to 23 errors. :)
http://i.imgur.com/5PaHJkO.png
Edit2: freeglut.h is located at \freeglut-2.8.1\include\GL and glew.h is located at \glew-1.10.0\include\GL and both of those are pointing right include directories under C/C++/General's tab.
AFAIK, the full path of glew's libs is \glew-1.10.0\lib\Release\Win32(I suppose you use 32bit windows), make sure you path include the lib files correctly. if you didn't modify the directory structure, /glew-1.10.0/lib won't find the libs you want.
Do the same thing for glut libs, I see you got glut link errors as well.
VC++ Directory settings in Visual Studio.

MSCVR110d.dll Missing in Allegro / VS Set Up

So I'm trying to set up an Allegro template by linking everything to a new VS program.
I've downloaded the .cc files from Allegro and followed the installation guide in it's Wiki for setting up with Visual Studio 2010.
The version is 5.0.10.
Upon putting the main source code in my first program and linking everything as per the wiki (bin, include, lib), the program builds fine, however, when you go to debug/run the program in VS, a window pops up with:
This program can't run because msvcr110d.dll missing from your computer.
I'm successfully tested other VS projects using other third party libraries and they still work fine.
What could be the problem?
This S/O question doesn't have an answer.
You may download and install the MSVC redistributable: http://www.microsoft.com/es-es/download/details.aspx?id=30679
Anyway, it's not normal that msvcr110d is required instead of msvcr110. That means that the library you are using has been compiled with the debug runtime of the MSVC2012. Check it and choose the right library files.
The tutorial you are following includes this text:
This tutorial may reference an older version number than what is available on that page. While following the instructions, if you copy and paste something with a version number, be sure to update it to reflect the version you downloaded.
That would indeed appear to be the case. The runtime that the program is trying to link to is the runtime for VS2012. So it seems that the files you downloaded are more recent than the tutorial. The .lib files that you are using are linked against VS2012.
Possible solutions:
Repeat the steps in the tutorial, but use VS2012 rather than VS2010.
Find the old version of the tutorial that has VS2010 .lib files.
Build the entire thing from scratch so that you are not dependent on supplied .lib files that are tied to a specific version of VS.

Netbeans C++ using MinGW and the libnoise library

Using netbeans 7.2 and the most recent version of MinGW (using installer) I can't use the libnoise library. I am properly including the header files, the auto completion confirms this, however the library is simply not working. There is a .lib file and a .dll. I have tried every possible combination of adding them under project > properties > Build > Linker as well as putting the .dll in the base project directory. Despite all this I am still getting undefined reference errors whenever I try and run the code. Does anyone know what to do?
I know that it is possible to link import library files (*.lib) with MinGW, but I still suggest to recompile libnoise.
With the current Makefile, this is not very easy and may break. Thus I've written a CMake script, which doesn't only work on Windows, but should work on all CMake supported platforms. In addition to this, I've cleaned up the directory structure. The code itself hasn't been touched and when you build a library it should essentially be the same as the current one.
libnoise on GitHub
After you've built your shared library, you'll have a libnoise.dll.a and libnoise.dll file. You then add libnoise.dll.a to the linking settings and put the DLL itself next to the binary, or in the working directory.
You have to link the lib file (= adding it to linker libraries) and put the dll to
<project root>/dist/<...>/
(where your exe is put to). There's no need to add the dll to linker too.
Can you please post the error message you get?