OpenGL project is requiring DirectX lib files - c++

I have glut version 3.7 installed, running Windows 7 and using VS 2010:
I seem unable to run any C++ programs without it saying it requires Direct X libraries and includes in the VC++ Directories properties tab.
Under propertes>input>additional dependencies it shows dxerr.lib and a few other dx libraries under inherited values which I believe is the cause of this error. How can I remove these values? Unless anyone believes the error originates elsewhere...
#include <stdlib.h>
#include <GL\glut.h>
int main(int argc, char **argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(100, 100);
glutInitWindowSize(720, 480);
glutCreateWindow("First OpenGL Project");
return 1;
}
Error 1 error LNK1104: cannot open file 'dxerr.lib' c:\Users\mallaboro\documents\visual studio 2010\Projects\First OpenGL Project2\First OpenGL Project2\LINK First OpenGL Project2

Try a maintained GLUT implementation instead of nearly twenty-year-old software.

Related

OpenCV namedWindow() create a window then not responding and crash( QT 5.11 + OpenCV 4.5.3)

include .....
using namespace std;
using namespace cv;
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
namedWindow("My Image");
waitKey();
return a.exec();
}
Here's code. A window displayed and then program crashed.
I followed the tutorial that used Qt+mingw to build mingw version lib.
If I use msvc version lib and compiler directly (don't need to build lib manually) , it works fine.
Now I believe that maybe some procedure lead the error. Just use msvc be OK.

GL/gl.h: no such file or directory

Usually I use Visual Studio 2019 on Windows 10. Today, I have to use freeglut. All the files are installed correctly, but I don't have file GL/gl.h.
I have installed the Windows Platform SDK. I tried it in Visual Studio 2017 and Clion, but every time I have this error:
fatal error C1083: Cannot open include file: 'GL/gl.h': No such file or directory.
I also tried to add #include <windows.h> before the #include <GL/glut.h> and checked for updates for Windows and video driver.
The code I tried to run:
#include <iostream>
#include <windows.h>
#include <GL/glut.h>
int main(int argc, char** argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA);
glutInitWindowSize(512, 512);
glutInitContextVersion(4, 1);
glutInitContextProfile(GLUT_CORE_PROFILE);
glutCreateWindow(argv[0]);
glutMainLoop();
}

compiled program cannot find freeglut.dll

I'm new to this site, and relatively new to programming.
I've been doing some C++ programming for a while using Visual Studio 2010, and I wanted to get into OpenGL, so I bought the OpenGL Superbible to get started. I've gotten stuck on the second chapter's "simple" project.
After hours of research I've been able to download all the necessary files to use freeGLUT and GLtools. I've made sure that everything is in the right place for the program to work.
Now, it appears as though everything has been worked out... except for one odd problem.
I was instructed that I needed to place freeglut.dll into Windows\System32, so I did. The project will build now, but when I go to run it, it tells me
"The program can't start because freeglut.dll is missing from your computer. Try
reinstalling the program to fix this problem."
Now, I am certain that freeglut.dll is in Windows\System32 as it should be, so what's the problem? how do I solve it?
Here's the original code from the book:
#include "../../shared/gltools.h" //OpenGL toolkit
//////////////////////////////////////////////
//called to draw scene
void RenderScene(void)
{
// clear the window with current clearing color
glClear(GL_COLOR_BUFFER_BIT);
//Flush drawing commands
glFlush();
}
////////////////////////////////////////////////////////
//set up the rendering state
void SetupRC(void)
{
glClearColor(0.0f , 0.0f, 1.0f, 1.0f );
}
///////////////////////////////////////////////////////////
//main program entry point
void main(void)
int main(int argc, char* argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
glutCreateWindow("Simple");
glutDisplayFunc(RenderScene);
SetupRC();
glutMainLoop();
return 0;
}
This is the code that actually compiled, but would not run (it's a bit of a mess from all the conflicting data I got from different resources):
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <GLTools.h>
#include <gl/GLUT.h>
//called to draw scene
void RenderScene(void)
{
// clear the window with current clearing color
glClear(GL_COLOR_BUFFER_BIT);
glFlush();
}
//set up the rendering state
void SetupRC(void)
{
glClearColor(0.0f , 0.0f, 1.0f, 1.0f );
}
//void main(void)
int main(int argc, char* argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
glutCreateWindow("Simple");
glutDisplayFunc(RenderScene);
SetupRC();
glutMainLoop();
return 0;
}
Try putting the DLL in the same folder as your exe file. The advice to put it in Windows\System32 predates a lot of newer Windows security restrictions.
#ScottMcP-MVP 's answer solved my problem, but I thought I'd add some detail that doesn't really fit in the comment.
My solution:
Add the following subdirectory structure to your solution folder:
In x86, put the 32-bit versions of GLut, GLew and anything else you need.
In x64, put the 64-bit versions of same.
I went ahead and put all .dll, .lib, and .h in the corresponding folders here rather than placing them in the Windows SDK (Or, in Win7+, the "Windows Kits" folder) to ensure that my projects in SVN had the correct version, and checking out on another machine would retrieve all dependencies. This required adding the include and target-specific lib folders to the project properties:
Set your Include Directories field to
$(SolutionDir)ThirdParty\Include\;$(IncludePath)
And your Library Directories field to
$(SolutionDir)\ThirdParty\$(PlatformTarget)\lib\;$(LibraryPath)
Note that all of these should be applied to the "All Platforms" build configuration. The $(PlatformTarget) macro will make sure that the correct lib's and dll's are used. The include folder is target-agnostic, so I've placed it in the root of my ThirdParty folder.
To get the required files into your output folder, add the following post-build event to your project configuration (under "All platforms"):
xcopy $(SolutionDir)ThirdParty\$(PlatformTarget)\*.dll $(OutputPath) /Y
That will copy the correct version of the DLLs to your output folder on build. This keeps you from having to manually put the DLLs in our output folder, and is more compatible with source control where you typically don't want to include your output, bin or debug folders.
Once I had all of this configured, I created a VC OpenGL project template since getting everything configured took 30 minutes of my life I'd rather have back.

OpenGL installation/initialization

I am trying to write some openGL code in visual studio 2012. I've looked over the internet to try and get this set up properly, and I can't seem to solve this.
#include <gl\GL.h>
#include <gl\GLU.h>
#include <gl\glut.h>
int main(int argc, char**argv){
glutInit(&argc, argv);
}
The glutInit line does not work, saying glutInit is not defined. Can someone please walk me through how to set this up properly in VS 2012? I've done things like this before in 2010, and would really like to just start working on my project.
You add the glut directory to the VC++ directories, here:
Then you need to add the name of the library under the Additional Dependencies:

"Using OS scope before setting MAKEFILE_GENERATOR" in Qt

I have downloaded and installed Qt and I'm learning how to use it.
So, I created a new project myfristqt (empty project). I then added a main.cpp file with this code:
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
return app.exec();
}
First thing I noticed #include <QApplication> line is hightlighted with a red line as if QApplication was an unknown identifier. So, I compiled it to see what happens and here's the error I got:
(internal):1: error : Using OS scope before setting MAKEFILE_GENERATOR
Any idea why this is happening ? I'm using Windows XP
MAKEFILE_GENERATOR is a qmake variable.
This variable contains the name of the Makefile generator to use when generating a Makefile. The value of this variable is typically handled internally by qmake and rarely needs to be modified.
It define in QTDIR/mkspecs/PLATFORM/qmake.conf. Where PLATFORM is maybe cygwin-g++, win32-msvc200x on your Windows XP.