undefined reference to glCompressedTexImage2D - opengl

I am trying to load some .dds textures for my game.
My IDE is Dev-C++ with GLUT 7.6 installed.
When I use OpenGL functions like glTexImage2D() or glVertex2f() my programs compile normally but when I try any of the glCompressedTexImage functions the linker tells me that there's an undefined reference to it.
like that: [Linker error] undefined reference to `glCompressedTexImage2D#32'.
I am linking my project only with libopengl32.a, and I am using Win API for the window.
Does I need to add another library in the linker options or my OpenGL version is too old ?

On windows platform opengl32.lib provides functions only for a very old GL version (1.1 or something like that). If you want functionality from newer OpenGL version, then you should get pointers to missing functions using wglGetProcAddress.
However, this is too much hassle. So instead of that you can use OpenGL extension library (GLEW or GLEE) to get missing function addresses for you. It is a better idea to use GLEW instead of GLEE, since GLEE looks abandoned.

Related

OpenGL functions missing in SFML environment

Following this tutorial I was trying to manage my OpenGL buffers for an OpenGL context I created using SFML, under a visual studio environment. I installed SFML and Glew in their latest versions, did correct linking, and I am able to work with primitives like OpenGL glClear, glBegin and glVertext3d.
However there is plenty of other OpenGL functions that I can t seem to be able to call like glEnableVertexAttribArray or glBindBuffer and I would like to understand why. I noticed that the default OpenGL version set by SFML context is 4.6 but I can t find proper documentation for these functions on khronos website for this version. Moreover my visual studio doesn t even recognize theses functions as part of any library but I might have missed some includes given that I rely on SFML/OpenGL.hpp. Documentation on SFML side is very ligth on this subject...
Thanks !
I am able to work with primitives like OpenGL glClear, glBegin and glVertext3d. However there is plenty of other OpenGL functions that I can t seem to be able to call like glEnableVertexAttribArray or glBindBuffer and I would like to understand why.
The reason for this is that the opengl32 library on windows only provides OpenGL 1.1 functionality, everything else is brought in by your graphics card driver. To actually access these functions, windows provides a function to load them. However, writing all the declarations and loading all functions is a lot of work (See Load OpenGL Functions in the OpenGL Wiki) so libraries exist which do this for you, one such library is glew, "The OpenGL Extension Wrangler Library". After you created your OpenGL context (which SFML does), you must call glewInit() which then loads all the other functions. The declarations for those functions are also provided by glew, so make sure to include the glew header instead of your systems or SFMLs opengl header.

How do I get MinGW to accept DirectX 11?

After attempting the solutions here and here, I got Eclipse to the point where it doesn't give me a bunch of errors while I'm writing my DX11 application. The linker on the other hand, continues to give me some undefined reference errors. Right now, it's just for IID_IDXGIFactory and CreateDXGIFactory simply because I haven't finished the Initialize() function and there's no other part of the code that uses the DirectX API.
What am I missing that is causing these errors in the linker?
Edit: Libraries included are the x64 versions of dxgi, dxguid, d3d10, d3dx10, d3d11 and d3dx11 in that order. I already know that not linking to the correct libraries causes undefined reference errors. My question is, what am I missing?

Running OpenGL without installing?

I am writing an OpenGL based game. It includes just these two libraries: glew, glfw3. In order to run it the user must obviously have OpenGL installed, an assumption which I'd like to bypass.
I've gathered all the appropriate binaries inside the game directory and tried linking to these libraries locally but the compiler claims undefined reference to all their functions. Am I doing something wrong or is it just impossible? I'm using Windows but it fails on Linux for the same reason.
OpenGL is not a library you install, it's an API that's implemented as part of the driver. Your compiler complaining about symbols not resolving is completely unrelated to the situation on the end user's computer. And in your case it simply sounds that you did not tell the compiler / linker which libraries and API interfaces to link into your program binary; your compiler is hence complaining, that some of the internal references don't redolve.
So here it goes: OpenGL is not something you ship with your program, it's part of the graphics drivers and your program must use whatever OpenGL version is installed on the user's machine. For this you dynamically link against libGL.so by passing the compiler-linker option -lGL.
GLEW is a helper library that post-loads dynamically all OpenGL functions not found in the system OpenGL ABI, which hence are not exported through the public symbol table of libGL.so. Rather they're to be loaded dynamically using glXGetProcAddress – a rather tedious task. Be advised that GLEW has some serious issues when it comes to OpenGL-3 and later core profiles.
GLFW is a simplistic framework library for setting up a window having an OpenGL context.
GLEW and GLFW are safe to link statically with your program, and I recommend you do that. Instead of using the -l… flag, add libGLEW.a and libGLFW.a to the list of source files / compilation units to be linked.

Build issues with libzbar based Qt application

I am using libzbarQT (libzbarQT.so) in my QT code.I am facing an error while building the code saying "undefined reference to QWidget::qwsEvent(QWSEvent *event)".I am not using this function in my QT code.I want to know which function is internally calling this function so that I can tweak the library a bit.
Any suggestions please..
Thanks in advance for any help.
PS: I am crosscompiling my code using arm-none-linux-gnueabi-g++ toolchain with LTIB.
To solve error '/usr/lib/libzbarqt.so: undefined reference to QX11Info::display()', I have build Qt with X11.Now I am getting error:libzbarqt.so: undefined reference toQWidget::qwsEvent(QWSEvent*)' error.
In general, you could make sure that the symbols are present in the library unless it is built without symbols. I usually use the nm -a and objdump utilities for that operation.
More to the point: it seems that the zbar dynamic library that you have was built against the embedded version of Qt rather than the desktop Linux.
It is an unfortunate issue that both versions have the same dynamic library file names, so things like ldd cannot be much of help.
You will need to make sure to use exactly the same version of Qt installation that the library was built against. This means, if you use the desktop Linux installation for this, it will not work.

Build errors w/ GLee (GL Easy Extension Library)

Using Code::Blocks w/ mingw, and trying to use GLee for some OpenGL on windows. I'm getting the following build errors:
GLee.c|60|undefined reference to `_wglGetProcAddress#4'
GLee.c|10748|undefined reference to `_wglGetProcAddress#4'
GLee.c|10751|undefined reference to `_wglGetCurrentDC#0'
GLee.c|10797|undefined reference to `_glGetString#4'
GLee.c|10910|undefined reference to `_glGetString#4'
GLee.c|10976|undefined reference to `_glGetString#4'
And I'm just including GLee likes so (with GLee.c, not the .dll):
#include "GLee.h"
According to Ben Woodhouse, GLee is "written in pure ANSI C, so any C or C++ compiler should work. You can include the source files in your projects directly or compile them into a library", so I should be having no problems.
Google didn't give me much on this, so I'm hoping some OpenGL vets (or anyone familiar with GLee) out there can point me in the right direction.
It looks like you need to link your application against the OpenGL libraries (specifically Opengl32.lib) which will provide the functions that you are missing. Perhaps the OpenGL FAQ might be of help in figuring this out.