Simpler linking on linux
by intangir · in Torque Game Engine · 10/29/2006 (10:18 pm) · 1 replies
I was trying to solve a linking issue with cg when i noticed the linking in torque is super weird
looks like it makes a macro for every gl function that calls a binding function that calls getprocaddress to find each function at runtime.. im not sure why that is exactly but in an effort to simplify things i commented most of the lines out for the macros and instead just included GL/gl.h and GL/glu.h files and linked libGL
also i dont have to statically link GLU anymore either, it works fine
here are some of the relavant changes:
in GLCoreFunc.h i commented everything out EXCEPT:
//torque vertex buffer extension
GL_FUNCTION(GLboolean, glAvailableVertexBufferEXT, (void), return GL_FALSE; )
GL_FUNCTION(GLint, glAllocateVertexBufferEXT, (GLsizei size, GLint format, GLboolean preserve), return 0; )
GL_FUNCTION(void*, glLockVertexBufferEXT, (GLint handle, GLsizei size), return NULL; )
GL_FUNCTION(void, glUnlockVertexBufferEXT, (GLint handle), return; )
GL_FUNCTION(void, glSetVertexBufferEXT, (GLint handle), return; )
GL_FUNCTION(void, glOffsetVertexBufferEXT, (GLint handle, GLuint offset), return; )
GL_FUNCTION(void, glFillVertexBufferEXT, (GLint handle, GLint first, GLsizei count), return; )
GL_FUNCTION(void, glFreeVertexBufferEXT, (GLint handle), return; )
and put these lines up at the very top:
#define GL_GLEXT_PROTOTYPES
#include
#include
also GLExtFunc.h
i commented everything out and put:
#define GL_GLEXT_PROTOTYPES
#include
#include
also GLUFunct.h i put:
#define GL_GLEXT_PROTOTYPES
#include
#include
then in mk/conf.UNIX.mk i changed these lines near the bottom to be:
LINK.LIBS.GENERAL = $(LINK.LIBS.VORBIS) -lGL -lGLU -L/usr/X11R6/lib -lSDL -lpthread -ldl # -lefence
LINK.LIBS.TOOLS = $(LINK.LIBS.VORBIS) -lGL -lGLU -L/usr/X11R6/lib -lSDL -lpthread -ldl # -lefence
notice there is no static linking
also i added GL
i think the wacky linking was probably for windows, so if you want to compile for both you should probably put some sorta #ifdef stuff in there for if its linux only, then comment out everything
looks like it makes a macro for every gl function that calls a binding function that calls getprocaddress to find each function at runtime.. im not sure why that is exactly but in an effort to simplify things i commented most of the lines out for the macros and instead just included GL/gl.h and GL/glu.h files and linked libGL
also i dont have to statically link GLU anymore either, it works fine
here are some of the relavant changes:
in GLCoreFunc.h i commented everything out EXCEPT:
//torque vertex buffer extension
GL_FUNCTION(GLboolean, glAvailableVertexBufferEXT, (void), return GL_FALSE; )
GL_FUNCTION(GLint, glAllocateVertexBufferEXT, (GLsizei size, GLint format, GLboolean preserve), return 0; )
GL_FUNCTION(void*, glLockVertexBufferEXT, (GLint handle, GLsizei size), return NULL; )
GL_FUNCTION(void, glUnlockVertexBufferEXT, (GLint handle), return; )
GL_FUNCTION(void, glSetVertexBufferEXT, (GLint handle), return; )
GL_FUNCTION(void, glOffsetVertexBufferEXT, (GLint handle, GLuint offset), return; )
GL_FUNCTION(void, glFillVertexBufferEXT, (GLint handle, GLint first, GLsizei count), return; )
GL_FUNCTION(void, glFreeVertexBufferEXT, (GLint handle), return; )
and put these lines up at the very top:
#define GL_GLEXT_PROTOTYPES
#include
#include
also GLExtFunc.h
i commented everything out and put:
#define GL_GLEXT_PROTOTYPES
#include
#include
also GLUFunct.h i put:
#define GL_GLEXT_PROTOTYPES
#include
#include
then in mk/conf.UNIX.mk i changed these lines near the bottom to be:
LINK.LIBS.GENERAL = $(LINK.LIBS.VORBIS) -lGL -lGLU -L/usr/X11R6/lib -lSDL -lpthread -ldl # -lefence
LINK.LIBS.TOOLS = $(LINK.LIBS.VORBIS) -lGL -lGLU -L/usr/X11R6/lib -lSDL -lpthread -ldl # -lefence
notice there is no static linking
also i added GL
i think the wacky linking was probably for windows, so if you want to compile for both you should probably put some sorta #ifdef stuff in there for if its linux only, then comment out everything
About the author
Torque Owner J "hplus" W