Cannot #include freeglut of OpenGL in Visual Studio C++ 2013 - c++

I want to begin programming with C++ OpenGl, and thus have downloaded freeglut to be included in my programn.
I have defined statically FREEGLUT_STATIC
Here is my source.cpp:
#include <GL\glew.h>
#include <GL\GLU.h>
#include <GL\freeglut.h>
#include "Source.h"
using namespace std;
int main()
{
return 0;
}
source.h
#define FREEGLUT_STATIC
But it does not work, the error is:
1>LINK : fatal error LNK1104: cannot open file 'freeglut.lib'
It's worth mentioning that I have added the libraries directories to the project, and even when I type Gl/ visual studio 2013 automatically suggest the libraries and headers which means it knows the directory,

I have found the problem. I should simlpy do the following:
Right click on my project in Visual Studio, go to the properties, and then to VC++ Directories, click on "Library Directories" and then add a new path:
under the freeglut main directory in your hard drive, there is a folder called lib/x86/Debug, just add the full path and then apply that.
Your script should be executed properly.

The include works alright (otherwise you'd get an error at compile time, not at link time). The library file itself (freeglut.lib) seems to be missing. This SO question addreses your problem.
EDIT: Updated my answer because obviously just the binary for the lib is missing. Same link already given in a comment by swaldi.

Related

need help to create first c++ console applciation

i'm a c# developer, have no experience on c++. I'm trying to create a c++ console application from this code:
http://www.oblita.com/interception.html
i downloaded the sources and registerd with install-interception.exe
in visual studio 2015 i created a new console application and added interception.h under Header Files.
in ConsoleApplication1.cpp added this code:
#include "stdafx.h"
#include <iostream>
#include <interception.h>
#include "utils.h"
using namespace std;
int main()
{
return 0;
}
when building i get this error:
Severity Code Description Project File Line Suppression State
Error C1083 Cannot open include file: 'interception.h': No such file or directory ConsoleApplication1 d:\documenti\visual studio 2015\projects\c++\consoleapplication1\consoleapplication1\consoleapplication1.cpp 6
To paraphrase #Biffen:
Adding a header file to a project and telling the compiler where to look for header files are two different things.
MSDN describes how to do tell the compiler to look for the header file:
To set this compiler option in the Visual Studio development environment
Open the project's Property Pages dialog box. For details, see How to: Open Project Property Pages.
Click the C/C++ folder.
Click the General property page.
Modify the Additional Include Directories property.

I completely cannot include boost headers

I needed a boost's "filesystem" so I downloaded and successfully build the whole boost. Its directory is C:\Program Files\Boost\boost_1_60_0\boost
Then I created a vs project and specified include directories, additional include directories and library directories. A couple of ways. Tried to add it to the system path, created a system variable bouth with setx an manually.
C:\Program Files\Boost\boost_1_60_0; $(BOOST_ROOT);
"evaluetes to" C:\Program Files\Boost\boost_1_60_0
But I still can't include and use anything.
#include <boost\filesystem> // error
#include "boost//filesystem.hpp" //error
#include <boost\filesystem.hpp> //error
#include "C://Program Files//Boost//boost_1_60_0//boost" //error
// those are working but still useless due to includes in the "filesystem.hpp"
#include "C:\Program Files\Boost\boost_1_60_0\boost\filesystem.hpp"
#include <C:\Program Files/Boost//boost_1_60_0\boost\filesystem.hpp>
#include <filesystem> // does not give an error, but following
using namespace boost::filesystem; //still does
By the way, I worked with boost in this same ide a couple of weeks ago. And things were ok, not sure how I got it working back then though.
What could possibly be wrong? I'm kind of lost.
Assuming you already built the library. You need to right-click on your Visual Studio project and click Properties.
As you can see on those pictures, specify the Additional Include Directories to C:\Program Files\Boost\boost_1_60_0 and Additional Library Directories to C:\Program Files\Boost\boost_1_60_0\stage\lib:
Then click OK
To include the boost filesystem write:
#include <boost/filesystem.hpp>
Let me know if you're still having problems after this.

Cannot find header file in Visual Studio project directory

I am trying to build a simple Windows 32 Console application pong game using Visual C++. See link http://www.noobtuts.com/cpp/2d-pong-game for more information. I have downloaded a group of headers files as well as a DLL file and libraries in a folder called freeglut_files.
Structure:
/GL
/freeglut.h
/freeglut.lib
/freeglut_ext.h
/freeglut_std.h
/glut.h
/freeglut.dll
/freeglut.lib
In Visual Studio Community 2015, my project structure looks like this:
/Pong
/External Dependencies
/Contains a number of files including GL.h and GLU.h (see below)
/Header Files
/stdafx.h
/targetver.h
/Resource Files
/Source Files
/freeglut.dll
/freeglut.h
/freeglut.lib
/freeglut_ext.h
/freeglut_std.h
/glut.h
/Pong.cpp (executable)
/stdafx.cpp
/ReadMe.txt
I added all the files, including the GL directory, to the source files directory of my Visual Studio project.
For some reason Visual Studio puts some of the header files in the /External Dependencies folder, including GL.h and GLU.h. However, my compiler cannot seem to find freeglut.h. I have tried moving it to the /Header Files directory and cannot move it to the /External Dependencies directory. Here is my code to Pong.cpp
#include "stdafx.h"
#include <string>
#include <windows.h>
#include <iostream>
#include <conio.h>
#include <sstream>
#include <math.h>
#include <gl\GL.h>
#include <gl\GLU.h>
#include "freeglut.h"
#pragma comment (lib, "OpenGL32.lib")
int _tmain(int argc, char** argv)
{
return 0;
}
The compiler will not compile the line where I include freeglut.h. Where should this file be? Why can I not add it to /External Dependencies?
Have a look at page Team Development with Visual Studio .NET and Visual SourceSafe. It might help problems in the future as well. It's always good to try to find the answer from the developer of the software you're using.

Visual Studio 2010 can't find cstddef

I'm attempting to compile a C++ solution in VS 2010, but for some reason it can't locate the standard libraries.
I'm including as so:
#include <cstddef>
VS is returning an error as so:
main.cpp(10): fatal error C1083: Cannot open include file: 'cstddef': No such file or directory
However, I check my installation directory, and it's right where it's supposed to be (VC\include), and this directory is a part of my include directory list in the project settings ($(VCInstallDir)include).
Any ideas why this is happening, and how I can fix it?
Give a try using #include <stddef.h> instead.
However, MSVC 10 should have <cstddef>: msdn
However, as #captain-obvlious pointed out this may require additional changes in your code..

unable to link FMOD library to VS2010 project

I am trying to link FMOD to my project, which I did very easily in the past in Visual Studio 2008.... So I have placed the fmodex_vc.lib and the fmodex.dll file in my project directory, added them to my project's solution explorer, then created a SoundMgr.h file which includes the fmod.h file
#include "include\fmod\fmod.h"
Where fmod has been placed in the include\fmod folder and opens ok if i right click on the above code and click "Open Document"...
But if I try to write any code at all, including a simple "using namespace FMOD" it tells me that it FMOD is undeclared or unidentified.... am I missing any step?
EDIT:
What the class looks like so far is:
#pragma once
#include "main.h"
#include "include\fmod\fmod.hpp"
#include "include\fmod\fmod_errors.h"
#include "include\fmod\fmod.h"
class SoundMgr{
void init();
};
void SoundMgr::init(){
FSOUND_Init (44100, 32, 0);
}
And the error is:
Error 1 error C3861: 'FSOUND_Init': identifier not found
And that's for any line of the sample code that I try import from this quick guide:
GameDev FMOD quick guide
I tried adding the library as an additional dependency in the Input section of the Properties/Linker and I get
1. fatal error LNK1181: cannot open input file 'fmodex_vc.lib'
Any of these errors ring a bell?
Don't you want fmod.hpp to get the c++ features?
you can include the headers path in C/C++ > General and library path to Linker properties and include the dll's in you project. In this case you have the files in you release/debug dir
Right so I eventually fixed it by removing the Additional Dependency in the Input section of the Linker and instead adding Include and Library directories in in Configuration Properties\VC++ directories.... Most articles I found advise to use the actual full path to the FMOD installation folder, but since I want this project to be portable and self contained, i created a "lib" and "include" folder in my project and put those files in them... (used the directories "\lib" and "\include" in the project properties which I am assuming links to the project folder, have never done this before but am hoping it won't cause dependency issues if I compile this on a different machine)...