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.
Related
I have not used C++ in visual studio in a lonnng lonnng time so probably this is a basic question but I would like some help.
I am opening someone else C++ code and the first thing I notice is that it is not recognizing its includes.
For example I have a main.cpp that has
#include "stdafx.h"
#include "myheader.h"
this cpp file is inside a "source" folder and those header files are under a "headers" folder.
I got an error "cannot open source file "stdafx.h" and "cannot open source file "myheader.h"
It is been ages I haven't touched C++ in visual studio. What configuration I should do to fix this?
if source and headers folders are in same level in folder structure you can use
#include "..\headers\myheader.h"
Similarly locate your stdafx.h and add the relative path to the .cpp file.
I am using Visual Studio 2012 and trying to import header files in the project, but have been failing miserably. Here is what I have tried to do:
#include "gevents.h"
#include "gobjects.h"
#include "gwindow.h"
int main(){
int x=1;
return 0;
}
I have added these three header files in the project location:
C:\Users\Shaby\Documents\Visual Studio 2012\Projects\ConsoleApplication39
In addition, I have also gone to Project properties ->Configuration Propertues -> C/C++ ->General and included the above path location in "Additional Include Directories" but this had yielded nothing. Instead, I am getting the following error:
Unable to start program C:\Users\Shaby\Documents\Visual Studio 2012\Projects\ConsoleApplication39\Debug\ConsoleApplication39.exe The system cannot find the file specified
#Usman Khan ,
I have one solution for your problem.In Solution Explorer Window (if not opened then press Ctrl+Alt+l) you can see you project name.Right click on it and than Add > Existing Item. Now select your header files which you want to include & press Add. Done :) .
why are you making it complex, just keep it simple.After creating your project. Open solution explorer. Under your project name you would see a folder "header files" , add your header files in it (your header files should have ".h" extension) and then to use them include them in your source files
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 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)...
I am new to visual studio.I have created a simple console application and then selected an empty project of c++.
I have pasted the code form
http://www.cprogramming.com/tutorial/opengl_first_windows_app.html
it is giving the following error
error C1083: Cannot open include file: 'stdafx.h': No such file or directory.
Can any body help me how ti solve that issue.
Also i have pasted the code from
http://www.cprogramming.com/tutorial/opengl_windows_programming.html
and it gives me error in MessageBox function.
Fall in the pit of success by using an appropriate project template. Which is Win32 + Win32 Project, don't tick the "Empty project" option on the property page. You'll get pre-generated code for a Win32 application, take a look at it since you might want to keep parts of it. Or just delete it all past the #include for stdafx.h and replace it with the code you want to try. The stdafx.h file is already pre-cooked for you.
The second snippet probably fails to compile because the code sample is not using Unicode strings. Put an L in front of the string literal, like L"\tHello world".
"stdafx.h" is the default name for the precompiled header in Visual Studio.
If you are not using precompiled headers you can omit that include directive.
See this article on Wikipedia for an explanation of precompiled headers.