Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I'm trying to learn GLFW and i found a good tutorial online.
I did everything they did but when i even try to write a line of code to main() a lot of errors occur.
The first two error given are
In file included from main.cpp:10:0:
/usr/include/GL/glew.h:15769:109: error: conflicting declaration ‘typedef void (* PFNGLGETFRAGMENTMATERIALIVSGIXPROC)(GLenum, GLenum, const GLint*)’
typedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint* data);
^
In file included from /usr/include/GL/gl.h:2055:0,
from /usr/include/GLFW/glfw3.h:153,
from main.cpp:7:
/usr/include/GL/glext.h:11616:25: note: previous declaration as ‘typedef void (* PFNGLGETFRAGMENTMATERIALIVSGIXPROC)(GLenum, GLenum, GLint*)’
typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params);
^
Followed by many errors that look like
In file included from main.cpp:10:0:
/usr/include/GL/glew.h:16432:17: error: ‘PFNGLCLIENTACTIVETEXTUREPROC’ does not name a type
GLEW_FUN_EXPORT PFNGLCLIENTACTIVETEXTUREPROC __glewClientActiveTexture;
^
Since there were to many error i will paste them in pastebin:
here
My code is:
#include <iostream>
#include <GLFW/glfw.h>
#include <GL/glew.h>
int main()
{
return 0;
}
I compile it using this command:
g++ -o exec main.cpp -I/usr/include/libdrm -lglfw -I/usr/include/libdrm -lGL -I/usr/include/libdrm -lGLEW -lGLU
I have everything installed and i can create GLFW programs without glew but glew seems to be causing those problems.
Thank you!
EDIT:
I use Ubuntu if it matters.
from http://glew.sourceforge.net/install.html
Also, GLEW will warn you by issuing a preprocessor error in case you
have included gl.h, glext.h, or glATI.h before glew.h.
I suspect that #include <GLFW/glfw.h> internally does one of these things. Try swapping the includes.
GLFW confirms: http://www.glfw.org/docs/3.0/build.html
If you are using an OpenGL extension loading library such as GLEW, the
GLEW header should also be included before* the GLFW one. The GLEW
header defines macros that disable any OpenGL header that the GLFW
header includes and GLEW will work as expected.
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 10 months ago.
This post was edited and submitted for review 10 months ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
I am trying to compile some C++ code using Qt creator that has to connect to a socket for sending and receiving data. I have linked the library file, added the flag win32: LIBS+= -lWS2_32. Attaching the code snippet below:
...
#include<winsock2.h>
#pragma comment(lib,"Ws2_32.lib")
#include<windows.h>
...
WSADATA wsa;
SOCKET s;
uint8_t* encode_buffer;
uint8_t* decode_buffer;
uint16_t encode_buffer_length;
uint16_t decode_buffer_length;
if (send(s, encode_buffer, encode_buffer_length,0)<0){
...
}
if((recv_size=recv(s, decode_buffer, decode_buffer_length,0))== SOCKET_ERROR){
...
}
And my following issues are:
Warning: ignoring #pragma comment [-Wunknown-pragma]
Error: invalid conversion from 'uint8_t* {aka unsigned char*} to 'const char*'[-fpermissive]
Error: invalid conversion from 'uint8_t* {aka unsigned char*} to 'char*'[-fpermissive]
Error: no matching function for call to 'send'
Error: no matching function for call to 'recv'
Warning: unknown pragma ignored
I have added the ws2_32.lib file to the project as an external library, and mentioned it in the #pragma directive.
Not sure where I am going wrong.
Edit: Thanks! Reinterpret_cast solved the issue
Regarding the warnings (not errors), the #pragma you are using is not supported by most compilers (Microsoft and Embarcadero compilers do). So just remove it altogether (you already link to the library in the project makefile), or at least disable it with an appropriate #if/def.
As for the rest of the errors, send() and recv()expect char* pointers, not uint8* pointers. A simple type-cast will suffice.
Try this:
...
#if defined(_MSC_VER) || defined(__BORLANDC__)
#pragma comment(lib,"Ws2_32.lib")
#endif
...
if (send(s, reinterpret_cast<char*>(encode buffer), encode_buffer_length, 0) < 0) {
...
}
if ((recv_size = recv(s, reinterpret_cast<char*>(decode buffer), decode_buffer_length, 0)) == SOCKET_ERROR) {
...
}
...
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I'm trying to compile the very first code given by Irrlicht library website.
As said in the title, I get an undefined reference. I'm using 8.2 netbeans IDE.
This is what I've done so far :
Installed Irrlicht library from the Linux repository (I'm using Ubuntu 18.04).
Using these command lines : sudo apt-get install libirrlicht1.8 libirrlicht1.8-dbg libirrlicht-dev libirrlicht-doc
In the "project properties", I've added the include directory, as well as the include headers (e.g all the files contained in /usr/include/irrlicht. Also, in the "Additional Options" (the linker part, I guess ?) , I've seen online that I should add -lIrrlicht command line, and it still got me the undefined reference.
I've tried also the following command line : -L /usr/include/irrlicht -lIrrlicht, still got me the undefined reference.
I know that the compiler finds the library, as it does not make a compilation error saying that it doesn't know "irrlicht.h", so the problem is coming from the linker. What command line does the linker expects ?
Note : I'm not able to make any update. Talking about irrlicht, it seems that I have 363 packages outdated. Could the problem be from there ?
Edit : Here is the minimum code, as requested. There is no point showing it, as the error comes from the linker command line :
#include <cstdlib>
#include <iostream>
#include <irrlicht.h>
using namespace std;
using namespace irr;
using namespace core;
int main(int argc, char** argv) {
IrrlichtDevice *device=createDevice(video::EDT_SOFTWARE,dimension2d<u32>(640,480),16,false,false,false,0);
return 0;
}
I had a similar problem with another library. I fixed it by changing the path in the linker?
according to https://de.wikibooks.org/wiki/Irrlicht_-_from_Noob_to_Pro:_C%2B%2B_f%C3%BCr_Irrlicht_einrichten
you have to link lIrrlicht like:
LIBS += -L/.../Irrlicht/irrlicht-1.7.1/lib/Linux
LIBS += -lIrrlicht
instead of -L /usr/include/irrlicht -lIrrlicht (for unix).
Did you try that?
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I am merging two complicated program, one written in c and the other in c++.
Here is a simplified situation.
My main program is written in c (main.c).
#include <stdio.h>
#include "test.h"
int main()
{
printf("test!\n");
}
where test.h is the header of test.cpp, which is another program written by others in cpp.
test.h
#include <vector>
int test();
test.cpp
#include "test.h"
int test()
{
return 1;
}
I try to compile main.c using the following command:
gcc -c main.c -o main.o -lstdc++
But I get the following error:
fatal error: no such file or dirctory #include
I don't want to change the codes of my main.c or test.cpp since they are much more complicated than that in this simplified example.
I am new to gcc, anyone can help to solve this problem?
Many thanks.
You should compile with g++, not gcc because it's C compiler and <vector> is a C++ header file (not mentioning <vecotr> which is a typo)
If you have to use C compiler, you have to remove all C++ dependencies from header files which are included from the C sources.
That's a typo: replace
#include <vecotr>
^^^
with
#include <vector>
Edit: plus you should compile with g++, not gcc since you're including a C++ header file.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
This is the c++ code I want to run on my computer: http://pastebin.com/66BEyTWK
On the university computer, this code displays a white square. But when I try to run it on my computer all I get is a blank screen.
I read on the opengl faq that the problem might be that I am linking with the wrong combination of opengl libraries.
The include part of the code suggests that I need to link glm, glew and freeglut.
#include <iostream>
#include <GL/glew.h>
#include <GL/freeglut.h>
#include <glm/glm.hpp>
I read that it is not necessary to link glm, because it is only a header file. So this is the compile statement I came up with:
g++ -o main white_square.cpp -lGL -lglut -lGLEW
At my university they have setup a custom makefile which I can't get much sense out of: http://pastebin.com/3DxST3Xs
trying to use this tutorial on 64-bit windows 8 with netbeans and cygwin 4.8.1.
i get many errors like this: /usr/include/w32api/GL/glu.h:68:79: error: expected ‘)’ before ‘*’ token.
on statements like this: void APIENTRY gluQuadricCallback(GLUquadric *qobj,GLenum which,void (CALLBACK *fn)());
the pointer on error message points to the * before the fn().
edit: including windef.h gets rid of the compiler error messages.
i am left with a bunch of undefined references like: glfwInit
edit2: using André Fischer's ideas, i can get a clean compile (you need to add the directory and a -l option for the linker).
i now have a: skipping incompatible ../../../../../Windows/SysWOW64/opengl32.dll when searching for -lopengl32 and: undefined reference to `_imp_vsnprintf'. so it looks like i have a 32/64 bit problems and an undefined external.
there must be a saner way to get opengl working on windows.
I assume you mean Tutorial 1: Opening a Window and are using Netbeans' builtin build system instead of CMake.
The order in which you include the header files is important (source). Try it like this:
#include <windef.h> // According to comments above
#include <GL/glew.h> // Before any gl headers
#include <GL/gl.h>
//#include <GL/glext.h> // Linux headers
//#include <GL/wglext.h> // Windows headers - Not sure which ones cygwin needs. Just try it
#include <GL/glu.h> // Always after gl.h
#include <GL/glfw.h> // When all gl-headers have been included
Create a directory named "include" in your project directory with a subfolder "GL".
Grab the binaries (32 bit, MinGW) from the GLFW Download Site and put the .dll/.so into your build-folder (Or extract them somewhere and add them to the search directories) and the header files into "include/GL".
Also the glfw code in the tutorial is slightly outdated; It does not work with glfw3 anymore.
You'll have to update it using GLFW's conversion guide/try this version (which I haven't been able to test, since I'm currently not at home) or use glfw2.
Finally download the GLEW sources and build it by following the instructions in the README.txt. Put the .dll/.so into your build-folder (or add to search directories) and the header files into "include/GL".
Add following to your Compiler-Flags:
-Iinclude/
Finally add following arguments to your Linker:
-L/lib -lglu32 -lopengl32 -lGL -lGLU -lglfw -lglew
You should be able to compile the tutorial now.
Edit: Added instructions for building GLEW, GLFW and completed my answer to include building everything from scratch.
Edit2: Linked glfw3-version of the tutorial-code.
Edit3: Added missing linker options.