LNK1104 Error when trying to setup SFML 2.3.1 in MS Visual Studio COmmunity 2015 - sfml

I'm no expert in programming, and have never used SFML previously, but thought I would give it a try for fun tonight. I followed the instructions on the sfml-dev.org, but when I try to run the testprogram that's supposed to render a circle, I get the following build error:
Error LNK1104 cannot open file 'sfml-graphics-s-d.lib
sfml-window-s-d.lib sfml-system-s-d.lib sfml-audio-s-d.lib
sfml-network-s-d.lib opengl32.lib freetype.lib jpeg.lib winmm.lib
gdi32.lib openal32.lib ws2_32.lib
kernel32.lib' Win32Project2 C:\Users\Johan\documents\visual studio
2015\Projects\Win32Project2\Win32Project2\LINK 1
I added the dependencies from opengl32.lib to ws2_32.lib because sfml-dev.org stated that the 5 main libraries were dependent on those. What could cause this problem?

Did you define SFML_STATIC in the pre-processor options? I normally don't like linking to SFML libraries statically. Just put the libraries in the same directory of your executable and link to the dynamically.
Example:
Make sure to append your libraries with -d when you link to them if you're compiling a debug version, ex: sfml-graphics-d. Remove -d otherwise.

You need to put the appropriate DLL's in your project directory: Go to "bin" in your SFML folder, copy and paste everything, then go back to the folder that has all your source files for your project and paste there. Looking at your error message, it should be here:
C:\Users\Johan\documents\visual studio 2015\Projects\Win32Project2\Win32Project2\

Related

cannot see the file 'SDL2.lib'

This question is not a duplicate of cannot open file 'SDL2.lib' which discusses this same error but my problem is that I don't have an SDL2.lib file, if I can just see it I can make this work
I'm trying to set up the development environment for SDL2 by following Lazy Foo's tutorial.
Setting up SDL 2 on Visual Studio 2010 Ultimate
The tutorial is for Visual Studio 2010, I'm using Visual Studio Community Edition 2017. Is that a problem?
The problem starts when linking the libraries, there is no x86 or x64 folder inside the lib directory of SDL2's Windows Development libraries that I downloaded from SDL version 2.0.8 (stable).
So I specified it as lib/ instead of lib/x86 as it says in the tutorial.
These are the files inside the lib folder
$ ls
cmake/ libSDL2.dll.a libSDL2_test.a libSDL2main.a pkgconfig/
libSDL2.a libSDL2.la libSDL2_test.la libSDL2main.la
When building VS2017 is throwing an error saying that Cannot open file 'SDL2.lib'. Yeah, there is no such file. Do I need to do an additional step to get this file?
When I configured for CodeBlocks it works fine. What exactly am I doing wrong here? This may have an obvious answer but I'm not able to find it.
Library name `libSDL2.dll.a' indicates that it is not meant for use with VS C++ ( for dynamic link you need dll + lib, for static link you need only the lib ). You can construct a lib file from dll using dumpbin.exe and lib.exe. Your options are:
1) Download SDL source file in zip format from GitHub and create you own binaries.
2) Use vcpkg and install in just one command line ( recommended).
3) Download the SDL binaries from internet. ( you can have linker issues if the project configurations doesn't matches yours)

how to use boost libs in project (VS2015)

I have Visual Studio 2015 and I'm trying to build the sample boost 1.62 link program on the 'Boost Getting Started' page. I followed the build steps in order to compile the various binaries, like regex. These are the steps:
c:\boost> bootstrap
c:\boost> .\b2
I got multiple errors because 'pyconfig.h' was missing, but I don't need this so I thought it was ok.
I set the 'Additional Libraries Directory' in my test project to c:\boost\libs, but at link time, get:
error: cannot open file libboost_regex-vc140-mt-gd-1_62.lib
I looked under .\libs and there were no lib files under there. I did see a new bin.v2 directory under boost\, which, under a very complicate tree has the lib file.
I set the 'Additional Libraries Directories' in my project to c:\boost\bin.v2, but same error.
Can anyone tell me what I need to do to be able to link successfully? Do I need to resolve that pyconfig.h error to get the libs deployed to the right location?
I found the problem. It appears VC++ projects should add an include path to .\boost\stage\lib, instead of what the boost webpage says. I don't know if this is true intention, but it appears to work.

Setting up Aquila for my c++ Project in Visual studio 2012

I want to use Aquila DSP to compute MFCC features in my project and trying to make it work.I followed this tutorial but after mingw32-make install on the source code pulled from Aquila's git repo, it generates only libAquila.a in lib folder. I tried changing my project's include and library dependencies using these generated files after install. Also tried adding FindAquila.cmake and tried building my project with cmake for VS 2012, still no luck. Keep getting "aquila/global.h" no such file or directory when I try to include "aquila/global.h".
I also tried building Aquila with cmake for VS 2012 and able to compile it and it generates .lib files as well, but not sure how to proceed with that.
If anyone knows how to make it work, it will be great help.
So, I made it work with Visual studio 2013. Now what I am doing is I am building Aquila with both Mingw and with VisualStudio. Mingw gives required include files and visual studio build gives required .lib files. I am building Aquila in VS 2013 with configuration type static lib (project properties >> General >> Configuration type) for both debug and release configuration and then I build the project.
For Mingw, first I use cmake GUI with mingw cmakefiles configuration and then run mingw32-make install in the build directory, which will put the include, lib and share files in the installation directory( usually C:\\Programme files\\Aquila.
Now I create a Folder Aquila and put include and share from above path and create a new folder lib with two subfolder debug and release. Here I put two .lib files in each folder (aquila.lib and Ooura_fft.lib) (debug libs in debug and release libs in release folder, they will be VS build folder). Once this is done, in my project setting, I add Additional include directories under C++ >> general, Addiotnal library path under linker >> general and names of libraries under linker >> input for both bebug and release configuration. After doing all these things, now the library works with my project.

Linking error while using dlib with libjpeg

I am studying Machine Learning and Pattern Recognition and using dlib library for that. I was trying one example code face_detection_ex.cpp provided with the library. I created a separate project under Visual Studio 2010 and included the face_detection_ex.cpp example and dlib\all\source.cpp files. It build fine. But, if I enable DLIB_JPEG_SUPPORT by
#define DLIB_JPEG_SUPPORT
then it will throw the linking error LNK2019 for all the functions of libjpeg library used by the dlib library. I tried #pragma comment(lib, libjpeg) and I also tried to include the library in project properties, but still the same.
After spending 1 day on this error, I switched to linux and try to work in that. But there also I am getting the same linking errors.
Then on the dlib release-note I read that libjpeg library is included in dlib's external folder and use dlib's cmake file for the example code and cmake will perform the static linking. I tried that and with cmake it is linking. I tried to find out how the linking is happening as I want it to work with visual studio and other compilers also but I couldn't find out why the libjpeg library is unable to link.
Any suggestion?
EDIT: Here it is mentioned how to use dlib with Visual Studio. And how to compile the example on linux. So, as I have to link with libjpeg library, I added the -ljpeg in the command.
You can use CMake to generate a Visual Studio project that is properly configured and that's the easiest way to do this if you want to use Visual Studio.
However, if you really want to configure the Visual Studio project by hand then all you need to do is add the files in the dlib/external/libjpeg folder to your Visual Studio project and also add the dlib/external/libjpeg folder to the include search path.

Building & Linking FreeImage with Visual Studio Express 2013

I'm having a lot of trouble linking my project with FreeImage library with VSE 2013
I've followed this answer for VS2010 to no avail: Linking FreeImage as a static library in VS2010?
I am getting LNK2019 errors when calling FreeImage functions.
I've linked the library just as I would any library. Below are the following steps I made:
Download FreeImage Source.
Open the 2008 Solution (converted to 2013) and changed Code Generation to /MDd for all projects
Attempted to build project but for some reason min/max functions were not defined So I included algorithm.h to those files and that stopped those errors.
Attempted to build project and I get an error: "Could not open "afxres.h". So I swapped afxres.h with windows.h as suggested in another topic.
Built the project -> success
Copied Fresh FreeImaged.lib to to my project
Added directory to "Additional Library Directories"
Added FreeImaged.lib to Additional Dependencies under linker
Copied FreeImaged.dll to my debug folder where the .exe is being built
Added FreeImage.h to the project
Added #define FREEIMAGE_LIB before including the header
Attempted to build my project -> LNK2019s everywhere.
If anyone has been able to build FreeImage on VS2013 and could share how they did it I would greatly appreciate it, or if anyone has any suggestions.
The reason for your troubles is that with Visual Studio 2013 some breaking changes (as outlined by Microsoft) were introduced in related to C++11 conformity.
One includes that in order to use std::min()/std::max(), you now have to include the header . This also concerns FreeImage. Unfortunately, up until version 3.6.1 (the most recent as of today) this hasn't been fixed yet.
This blog post explains what you need to do to get it to compile. The most relevant part is:
Specifically, you will need to add
include <algorithm>
to the following files:
Source/OpenEXR/IlmImf/ImfOutputFile.cpp
Source/OpenEXR/IlmImf/ImfScanLineInputFile.cpp
Source/OpenEXR/IlmImf/ImfTiledMisc.cpp
Source/OpenEXR/IlmImf/ImfTiledOutputFile.cpp
Source/OpenEXR/Imath/ImathMatrixAlgo.cpp
I was able to get this to work by going into the Configuration Manager unchecking FreeImage and checking FreeImageLib under build. Also disabling whole program optimization seems to make the binary size more normal and, gets rid of warnings when linking.
I know this question is over a year old. Just providing an answer to anyone google searching this problem like me.
version: FreeImage3170Win32Win64.zip
os.env.: win7 64bit visualstudio ULTIMATE 2013
operation:
1_ just unpacking the zip somewhere
e.g. (D:/library/FreeImage3170Win32Win64/FreeImage)
2_ in C/C++->General->Additional Including Directerories
add (D:/library/FreeImage3170Win32Win64/FreeImage/Dist/x32)
3_ in Linker->General->Additional Library Directerories
add (D:/library/FreeImage3170Win32Win64/FreeImage/Dist/x32)
4_ in Linker->Input->Additional Dependency
add (FreeImage.lib)
PS0: i just add a new entry to Include Directories and Library
Directories and FreeImage.lib to Linker->input in Visual Studio without rebuild the FreeImage library
:)
PS1: error LNK2019 occured when i added the FreeImage/Dist/x64 option
;( ( got no idea about this)
maybe this helps :)