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.
Related
Why in Visual Studio 2017 the compiler will complain (LinkError 2019, seems to not compile the implementation) if I include my headers and implementation files rather than use the default pch.h and pch.cpp files? Obviously all the files mentioned are in the same folder.
(Note: Copy-Paste the same code in pch.h and pch.cpp will work fine)
Im using this sintax on header.h:
#pragma once
//init code
Implementation.cpp:
#include "header.h"
//impl code
Main.cpp:
#include "header.h"
//main code
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.
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.
I've created an Allegro 5 project in Xcode 4.6.3 as an empty project. I've added all the Allegro 5 libraries as described in the Allegro documentation. But now I need to use some C/C++ libraries and get the error, that Xcode doesn't find the libraries (e.g. 'fstream file not found').
#include <allegro5/allegro5.h>
#include <allegro5/allegro_native_dialog.h>
#include <allegro5/allegro_primitives.h>
#include <allegro5/allegro_image.h>
#include <fstream>
#include <string>
#include <vector>
#include <sstream>
How can I add the standard libraries to Xcode projects so that it finds them? Unfortunatelly I can't find any solution. This is not an Objective-C Project. It's written in C++ and also works if I don't use any of these libraries.
Thanks!
Does the name of your source file end with an extension that indicates it's C++? If it ends in (for instance) .c or .m, the compiler will not consider it to be C++, therefore the C++ headers won't be found. Try changing the extension on the source file name to .cpp (or some other extension that implies C++, see C++ code file extension? .cc vs .cpp ) and see if the header is found.
i used a c++ programm for image processing using opencv 2.1. and that program has below include files:
#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <iostream>
#include <math.h>
#include <string.h>
but after debuging the program i get error message as:
fatal error C1083: Cannot open include file: 'opencv2/core/core.hpp': No such file or directory.
that is same as for imgproc.hpp and highgui.hpp after that i changed #include "opencv2/highgui/highgui.hpp" to #include <highgui.h> and that error solved.
But i could not find a solution for imgproc.hpp and highgui.hpp and there are no files named imgproc.hpp and highgui.hpp inside the opencv folder.
How can i solve this error?
From the path separator, I assume you are using *nix OS. So the following shell commands should help you to find the correct location of the header files:
locate highgui.h
locate highgui.hpp
As previously stated, your libraries aren't in an included area. Most people have tailored their responses to a Linux-based system, but if you're on Windows (i.e. Using Visual Studio), you can usually just include the entire path of your library folder in the include statement.
For example:
#include "C:\OpenCV\bin\install\opencv2\highgui\highgui.hpp"
#include "C:\OpenCV\bin\install\opencv2\imgproc\imgproc.hpp"
I recently had my fair share of errors after trying to install OpenCV 2.4.1 and finding the correct directories to include (both for 'include' and 'lib') was difficult at first. I recommend re-installing your OpenCV and going from there.
http://opencv.willowgarage.com/wiki/InstallGuide