GL/gl.h: no such file or directory - c++

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();
}

Related

Undefined reference to function in VlcQt (after installation)

I recently installed VlcQt libary for ubuntu 16.04, but when I try to use it, all i get is undefined reference to 'some_function()'.
Currently I am trying to expose video player to QML.
Main.cpp
#include <QGuiApplication>
#include <VLCQtCore/Common.h>
#include <VLCQtQml/QmlVideoPlayer.h>
#include "Controller.h"
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
VlcCommon::setPluginPath(app.applicationDirPath() + "plugins");
VlcQmlVideoPlayer::registerPlugin();
Controller controller;
QQuickWindow *quickWindow = qobject_cast<QQuickWindow *>(controller.view());
quickWindow->show();
return app.exec();
}
When I am trying to include libaries, Qt intellisense is detecting that this libary exists.
What am I doing wrong?
Thank you for your help!
//Edit:
I installed it via their repository:
add-apt-repository ppa:ntadej/tano
apt-get install libvlc-qt-core2 libvlc-qt-widgets2 libvlc-qt-dbg libvlc-qt-dev
//Edit:
This is how I add libs in .pro file, already tried INCLUDEPATH too
LIBS += -lvlccore -lvlc

Using Visual Leak Detector with a QApplication

I am trying to locate the memory leaks in my Qt application. I already have used Visual Leak Detector for some other projects, but VLD writes the output to the console window.
My problem now is that when using a QApplication, no console window, and therefore no output from VLD, is shown. I am using Visual Studio 2015 with the Qt VS Tools plugin.
Is there a way to force the application to show the console window? Or maybe a way to write the output generated by VLD to a file?
How I start up my application:
#include "mainwindow.h"
#include <vld.h>
#include <QApplication>
int main(int argc, char *argv[]) {
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
As ssbssa pointed out as a comment, the problem could be solved by setting ReportTo and ReportFile in vld.ini found in the installation folder of VLD:
change ReportFile = to ReportFile = memory_leak_report.txt or something like that.
change ReportTo = debugger to ReportTo = file or ReportTo = both.
Now the output produced by VLD will be written to the specified file.

OpenGL project is requiring DirectX lib files

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.

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:

(C++)Code:: blocks does not recognize QT4 classes

So far I have worked in the console and a few days ago decided to try the QT GUI.
I downloaded the QT SDK , install it, adjust the location of QT and
set up the PATH Environment Variable -> per the instructions on the site.
I opened a new Qt4 project in Code:: Blocks-in and it seemed that everything was OK.
There is by default an example:
#include <QApplication>
#include <QFont>
#include <QPushButton>
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QPushButton quit("Quit");
quit.resize(75, 30);
quit.setFont(QFont("Times", 18, QFont::Bold));
QObject::connect(&quit, SIGNAL(clicked()), &app, SLOT(quit()));
quit.show();
return app.exec();
}
Started it an it was all OK.
After that I went to a tutorial on the official site and there is a final example.
Some kind of simple game.I have done copy-paste of all .h and .cpp files and then put
them in current project to see how it works but then problems arise.
Code::Blocks does not recognize some classes.
For example :: #include QTimer : No such file or directory
#include QRect : No such file or directory
I uninstall QT and re-installed and configured everything again but the problem does not go out.
These classes are not working nor in the default example ::
#include <QApplication>
#include <QFont>
#include <QPushButton>
#include <QTimer> does not have real purpose , just for illustration
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QPushButton quit("Quit");
quit.resize(75, 30);
quit.setFont(QFont("Times", 18, QFont::Bold));
QObject::connect(&quit, SIGNAL(clicked()), &app, SLOT(quit()));
quit.show();
return app.exec();
}
ba\107\main.cpp|4|QTimer: No such file or directory|
||=== Build finished: 1 errors, 0 warnings ===|
I dont now how much classes don work properly , this is just some of them.
Not to reveal hot water for days on google looking for a solution, maybe for some of you
, this is a bizarrely easy problem.
Thanks
You need to either spend time monkeying with the default include search path, or else just provide a more explicit path the header you want to include. I was able to reproduce your problem with Code::Blocks 10.05 (with bundled gcc) on Windows XP/32 and a previously installed Qt 4.6. Here is the slightly changed version of your code that I was able to build without any problem:
#include <QApplication>
#include <QFont>
#include <QPushButton>
#include <QtCore/QTimer>
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QPushButton quit("Quit");
quit.resize(75, 30);
quit.setFont(QFont("Times", 18, QFont::Bold));
QObject::connect(&quit, SIGNAL(clicked()), &app, SLOT(quit()));
quit.show();
return app.exec();
}
Take a look in your Qt install directory. You'll be able to see the include directory, and where all the headers are within it if you run into this problem with any other headers. It looks like the Code::Blocks projects sets up the QtGui directory as an include search path by default, which is why you didn't need to explicitly mention it for including QPushButton and whatnot.
Code::Blocks is only an IDE not a Compiler/Linker toolchain, so it is not Code::blocks that cant find the files, you have simply not configured your project to use them.
"No such file or directory" is a pre-processor error message; you still have to tell the compiler where to find your third-party header files. Moreover when it comes to linking, you will need to tell the linker where to find the libraries.
Whenever you have an #include <blah> (with angle bracktes <>) the compiler looks in the default include path. You need to put the Qt include directory into the include path for your project. I'm not sure how this is done in Code::Blocks. It's probably somewhere in the project settings.