Linking g++ with opengl (glm, glew and freeglut) [closed] - c++

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

Related

Undefined reference when using "Hello world" of Irrlicht library [closed]

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?

GCC compiler cannot compile Hello World program [closed]

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 am trying to compile the default Hello World on Code Blocks with the GNU GCC compiler but am getting the result of
cannot find -lbgi
It would be really helpful because right now I can't do a single thing!
Earlier I tried to use graphics.h and downloaded libbgi.a and I thought that was the problem so I deleted it. However, the compiler still produced the same error for the Hello World program, as well as previous programs that I made with C. From these information I guess that the problem is in the compiler but I cannot figure out what is causing it.
//c++ hello world program
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world!" << endl;
return 0;
}
//c hello world program
#include <stdio.h>
#include <stdlib.h>
int main(){
printf("Hello world!\n");
return 0;
}
I expect Hello World to be the output.
however:
||=== Build: Debug in firstCppProject (compiler: GNU GCC Compiler) ===|
ld.exe||cannot find -lbgi|
||error: ld returned 1 exit status|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|
You need to create a Console application (steps).
Currently you seem to be using a project created using a template with settings for Borland-compatible graphics (using a port of the old Turbo C++ "graphics" libraries), but you have deleted the libraries required to make that work.
Alternatively, you could remove the dependency on BGI from your project's linker settings.

GLEW giving bunch of uncoused errors [closed]

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.

Compile c/c++ program using gcc [closed]

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.

Visual Studio 2013 Professional linker errors [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I really want to use Visual Studio Professional's debugger to take a look at a segmentation fault I encountered in my program. However, the IDE would not compile even a simple program such as this:
// test_aug.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
cout << "Test" ;
return 0;
}
It keeps throwing the error "error LNK1104: cannot open file 'gdi32.lib'.
The thing is I don't want to fix this one linking error just to keep getting more for different libraries (I have also seen it for different libraries).
Can someone please tell me how to fix this error in general so I will not encounter it anymore, and can move on to ACTUALLY DEBUGGING.
If the linker cannot find that library check for its existence and/or set the path to find it into additional library directories.
The linking phase won't go on without solving that error first.
Other two thoughts:
gd123.lib sounds wrong, I believe you wanted to use gdi32.lib. Make sure the name is right
make sure that is included into the Windows SDK (express editions don't include it)