Cannot open file 'sfml-graphicsd.lib' - c++

I have recently picked up the book Beginning C++ Game Programming. I am following the book as precise as I can. I am a Java dev with about 2 years experience who is looking to pick up C++. I thought it would be fun learning it while learning game programming.
So I am getting the error 1>LINK : fatal error LNK1104: cannot open file 'sfml-graphicsd.lib'. I have added the include to the file, I have added the additional include and libs in the C++, Linker and Debug project properties. I will include the code, there is nothing yet I just wanted to see the window that is being created but already getting compiler errors.
I have noticed that the actual file name is sfml-graphics-d.lib whereas the compiler seems to be trying to open sfml-graphicsd.lib. I have checked the version of SFML that I downloaded and it is Visual C++ 14 (2015) - 32-bit and I am compiling win32.
Code:
// Samurai.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <SFML\Graphics.hpp>
using namespace sf;
int main()
{
VideoMode vm(1920, 1080);
Window(vm, "Samurai", Style::Fullscreen);
return 0;
}
Output:
1>------ Build started: Project: Samurai, Configuration: Debug Win32 ------
1>LINK : fatal error LNK1104: cannot open file 'sfml-graphicsd.lib'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Please let me know if any further information is required.
Thank you all so much,
Owen

I found the error. It was a spelling mistake in the properties > debugs > linker > input there was no - in the dll filenames

Related

My C++ project can't find the .exe

I haven't been coding in some time and I wanted to open up a new project to wipe of the rust.
I go to File New... Project
I press on "Visual C++"
Select an empty project and name it "test"
In the solution explorer I right click on Source Files
I select Add New Item...
I select the C++ file (.cpp) and name it main.cpp (no reason)
I write this simple piece of code right here:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello, world!" << endl;
return 0;
}
I go to Build Build Solution (and here start the problems...)
When it builds it shows this Output:
1>------ Build started: Project: Test, Configuration: Debug Win32 ------
1>LINK : fatal error LNK1104: cannot open file 'kernel32.lib'
1>Done building project "Test.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
It also goes to the Error List and shows this error:LNK1104
I have no idea what's the problem here because this exact same way always worked and now it suddenly doesn't? Can anybody explain me what am I doing here? I searched all over the neat and found people with similar problems but didn't really understand the solutions.
I had similar problem. Try Properties -> Configuration properties -> Linker -> System -> Set the SubSystem to 'Windows (/SUBSYSTEM:WINDOWS)'.
It helped to me.

Visual Studio C++ cannot open some headers I didn't deliberately include

today I wanted to start learning C++.
However I keep getting these errors:
Cannot open source file "stdio.h"
Cannot open source file "tchar.h"
Cannot open source file "SDKDDKver.h"
However, I even get these in a default empty win32 console project.
Does anyone know how to fix this?
OS: windows 10
My default code looks like this:
// HelloWorld.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
int main()
{
return 0;
}
The errors are:
Severity Code Description Project File Line Suppression State
Error (active) cannot open source file "stdio.h" HelloWorld c:\Users\HP\Documents\Visual Studio 2015\Projects\HelloWorld\HelloWorld\stdafx.h 10
Severity Code Description Project File Line Suppression State
Error (active) cannot open source file "tchar.h" HelloWorld c:\Users\HP\Documents\Visual Studio 2015\Projects\HelloWorld\HelloWorld\stdafx.h 11
Severity Code Description Project File Line Suppression State
Error (active) cannot open source file "SDKDDKVer.h" HelloWorld c:\Users\HP\Documents\Visual Studio 2015\Projects\HelloWorld\HelloWorld\targetver.h 8
Severity Code Description Project File Line Suppression State
Error (active) cannot open source file "stdio.h" HelloWorld c:\Users\HP\Documents\Visual Studio 2015\Projects\HelloWorld\HelloWorld\stdafx.h 10
In the OUTPUT window:
1>------ Build started: Project: HelloWorld, Configuration: Debug Win32 ------
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Platforms\Win32\PlatformToolsets\v140\Toolset.targets(34,5): error MSB8036: The Windows SDK version 8.1 was not found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution".
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
EDIT:
I believe I have C++ installed, cause first when I went to
file > new > project > Visual C++
It would only show me "Install ... for C++", So I installed one of the first options (don't remember which one it was) and after installing it allowed me to create projects.
Check your stdafx.h contents. Headers can be included transitively. In particular, the three ehaders you quote are in the VC++ stdafx.h for new projects. You can simply remove them if you're programming C++.
(It says something about Microsoft's struggle to choose between C and C++ : They don't support C99, but they default to a C header instead of C++. Not even <cstdio>. )

C++ Error for file_size() which belongs to Boost Filesystem

My IDE is MS Visual Studio C++ 2013, and I use Boost Library for Filesystem Operations.
I have written this code:
// BoostFileSystem.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <boost\filesystem.hpp>
using namespace boost::filesystem;
using namespace std;
int main()
{
cout << "File Size: " << endl;
cout << file_size("as.jpg");
return 0;
}
It throws error. The error is that:
1>------ Build started: Project: BoostFileSystem, Configuration: Debug Win32 ------
1> BoostFileSystem.cpp
1> LINK : C:\...\visual studio 2013\Projects\BoostFileSystem\Debug\BoostFileSystem.exe not found or not built by the last incremental link; performing full link
1> BoostFileSystem.vcxproj -> C:\..\documents\visual studio 2013\Projects\BoostFileSystem\Debug\BoostFileSystem.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
'as.jpg' is also included in the Resources folder. When I remove this line:
file_size("as.jpg");
The error is not thrown. Also bear in mind that the compiler reports no failure.
What is the problem? I really cannot figure it out.
Because when I remove file_size() line, the program works fully and also prints the text on the screen ("File Size:"). While when run it as-is, the compiler throws no error, but no text (even the line before the file_size()) is not printer and in the console the following is printed (which is also outputed to the error-area as already pasted above):
UPDATED:
Here is the error shown in the console window:
The system cannot find the file C:\Users\Ali\do
ts\BoostFileSystem\Debug\BoostFileSystem.exe.
The problem is solved. I post it for future visitors.
The problem is with incremental linking enabled in MS-Visual Studio C++. If disable it, then the program works.
Go to the properties of the project, then to the Linker, General and Disable the Incremental Linking.

playing a .wav file

I'm using visual studio 2010 express and I'm trying to write a simple program that will repeat a wave file 5 times(I'm running a windows xp sp3).
This is as far as I got:
#include "stdafx.h"
#include <windows.h>
#include <iostream>
using namespace std;
int main ()
{
int a = 5;
while(a >= 1){
cout << "It's a wav file";
PlaySound(L"SomeAudioFile-01.wav", NULL, SND_FILENAME);
--a;
}
return 0;
}
The problem is I keep getting this error message when I'm building it:
1>------ Build started: Project: It's a F**king Country, Configuration: Release Win32 -- ----
1> mycode.cpp
1>..\..\..\..\..\Shaul's documents\Visual Studio 2010\Projects\MyProject\Release\SomeAudioFile-01.wav : fatal error LNK1136: invalid or corrupt file
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
The file is perfectly fine and plays with no problems whatsoever outside visual studio.
Help would be truly appreciated.
Instead of adding the WAV file to the project files, add it to the resources and use SND_RESOURCE instead of SND_FILENAME.
You include the sound file as a object file, so the compiler tries to link with it. But it's a binary file that's not linkable (which is what the error message says).
Don't include the sound file in the project, so the environment won't link with it.
P.S. In the future, please refrain from using "bad" words on a public site like this.
To get rid of the linker error, you need to tell the IDE to link with the winmm.lib library also, so open Project/Properties/Configuration Properties/Linker/Input and append winmm.lib in the Additional Dependencies field.
Also, use the following function profile:
PlaySound(L"audio.wav", NULL, SND_APPLICATION);

Cannot open include file X11/X.h when compiling

I've copied the FL folder into the project.
and it show me this:
1>------ Build started: Project: Client, Configuration: Debug Win32
------ 1> Main.cpp 1>c:\users\user\documents\visual studio 2012\projects\talktome\talktome\fl\xutf8.h(33): fatal error C1083:
Cannot open include file: 'X11/X.h': No such file or directory
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
my source code is
using namespace std;
#include "FL\Fl.H"
#include "FL\Fl_Window.H"
#define WIDTH 700
#define HEIGHT 500
int main()
{
Fl_Window win(WIDTH, HEIGHT, "TalkToMe");
win.begin();
win.end();
win.show();
return Fl::run();
}
You should check if there is "#define WIN32" before your FLTK includes. will help you. It should. Simular problem here:
FLTK in MSVC needs x11 headers?
Do not use the \ in the include statements. Use the forward slash / .
The problems you refer to in your comment to Mycotoxin clearly indicate you have linking problems. You have to tell your compiler where to find the fltk library and the header files. Unresolved external symbols mean only one thing you know... :)
You do not have to define WIN32 as described in Mycotoxin's text. The compiler does that for you, and FLTK uses this fact. Even if it does not, you typically give it as a parameter to the compiler (something like -DWIN32 in the case of GCC or similar for CL).
Watch Greg's video tutorial at http://seriss.com/people/erco/fltk-videos/ where he explains how to configure FLTK and build a small app using Microsoft Visual Studio 7.
Finally, get the source package, and read the README.MSWindows.txt file. It explains everything you need to know in order to build your FLTK-based application on Windows.