cruentatio Tux's lil' helper
Joined: 16 Nov 2004 Posts: 125
|
Posted: Mon May 02, 2005 8:01 am Post subject: [OT] Compilare le plib [RISOLTO] |
|
|
Salve, stavo cercando di compilare gli esempi che ci sono sul sito ufficiale delle Plib, ma ho un problema!
Questa è la stringa di compilazione che uso:
Code: | gcc -o prova -Wall -pipe -L /usr/X11R6/lib -L /usr/lib -lpthread -lglut -lGLU -lGL -lXmu -lXi -lXext -lX11 -lm -lplibsg sg_quat_test.cxx |
E questo è l'errore che ottengo:
Code: | /tmp/ccaSuVYm.o(.text+0x3e7): In function `Redisplay()':
: undefined reference to `sgQuatToMatrix(float (*) [4], float const*)'
/tmp/ccaSuVYm.o(.gnu.linkonce.t._Z13sgMakeRotMat4PA4_fPKf+0x49): In function `sgMakeRotMat4(float (*) [4], float const*)':
: undefined reference to `sgMakeCoordMat4(float (*) [4], float, float, float, float, float, float)'
/tmp/ccaSuVYm.o(.gnu.linkonce.t._Z13sgPostRotQuatPffPKf+0x1b): In function `sgPostRotQuat(float*, float, float const*)':
: undefined reference to `sgAngleAxisToQuat(float*, float, float const*)'
/tmp/ccaSuVYm.o(.gnu.linkonce.t._Z14sgPostMultQuatPfPKf+0x2d): In function `sgPostMultQuat(float*, float const*)':
: undefined reference to `sgMultQuat(float*, float const*, float const*)'
collect2: ld returned 1 exit status |
Praticamente non trova i riferimenti alal classe sg, ma io l'ho messa nella stringa "-lplibsg" e anche dove si trova "-L /usr/lib".
L'esempio è molto banale:
Code: |
#ifdef WIN32
# include <windows.h>
#else
# include <unistd.h>
#endif
#ifdef FREEGLUT_IS_PRESENT
# include <GL/freeglut.h>
#else
# ifdef __APPLE__
# include <GLUT/glut.h>
# else
# include <GL/glut.h>
# endif
#endif
#include <plib/sg.h>
#define XSIZE 320
#define YSIZE 320
static sgVec3 Euler ;
static sgVec3 EulerPos ;
static sgVec3 EulerRot ;
static sgVec3 Quat ;
static sgVec3 QuatPos ;
static sgQuat QuatRot ;
static const GLfloat cube_vertices[] =
{
-1.0, -1.0, 1.0, 1.0, 0.0, 0.0,
1.0, -1.0, 1.0, 0.5, 0.5, 0.0,
1.0, 1.0, 1.0, 0.0, 1.0, 0.0,
-1.0, 1.0, 1.0, 0.0, 0.5, 0.5,
-1.0, -1.0, -1.0, 0.0, 0.0, 1.0,
1.0, -1.0, -1.0, 0.5, 0.0, 0.5,
1.0, 1.0, -1.0, 1.0, 0.0, 0.0,
-1.0, 1.0, -1.0, 0.5, 0.5, 0.0
} ;
static const GLubyte frontIndices[] = { 0, 1, 2, 3 } ;
static const GLubyte backIndices[] = { 5, 4, 7, 6 } ;
static const GLubyte rightIndices[] = { 1, 5, 6, 2 } ;
static const GLubyte leftIndices[] = { 4, 0, 3, 7 } ;
static const GLubyte topIndices[] = { 3, 2, 6, 7 } ;
static const GLubyte bottomIndices[] = { 4, 5, 1, 0 } ;
static void InitEulerCube( )
{
sgSetVec3( Euler, 1, 1, 1 ) ;
sgSetVec3( EulerRot, 0, 0, 0 ) ;
sgSetVec3( EulerPos, -2, 0, -5 ) ;
}
static void RotateEulerCube( )
{
if( Euler[ SG_X ] )
{
EulerRot[ SG_X ] += 5.0 ;
if( EulerRot[ SG_X ] > 360. )
EulerRot[ SG_X ] = 0.0 ;
}
if( Euler[ SG_Y ] )
{
EulerRot[ SG_Y ] += 5.0 ;
if( EulerRot[ SG_Y ] > 360. )
EulerRot[ SG_Y ] = 0.0 ;
}
if( Euler[ SG_Z ] )
{
EulerRot[ SG_Z ] += 5.0 ;
if( EulerRot[ SG_Z ] > 360. )
EulerRot[ SG_Z ] = 0.0 ;
}
}
static void InitQuatCube( )
{
sgSetVec3( Quat, 1, 1, 1 ) ;
sgMakeIdentQuat( QuatRot ) ;
sgSetVec3( QuatPos, 2, 0, -5 ) ;
}
static void RotateQuatCube( )
{
if( Quat[ SG_X ] )
sgRotQuat( QuatRot, 5.0, 1.0, 0.0, 0.0 ) ;
if( Quat[ SG_Y ] )
sgRotQuat( QuatRot, 5.0, 0.0, 1.0, 0.0 ) ;
if( Quat[ SG_Z ] )
sgRotQuat( QuatRot, 5.0, 0.0, 0.0, 1.0 ) ;
}
static void DrawCube( )
{
glDrawElements( GL_QUADS, 4, GL_UNSIGNED_BYTE, frontIndices ) ;
glDrawElements( GL_QUADS, 4, GL_UNSIGNED_BYTE, backIndices ) ;
glDrawElements( GL_QUADS, 4, GL_UNSIGNED_BYTE, rightIndices ) ;
glDrawElements( GL_QUADS, 4, GL_UNSIGNED_BYTE, leftIndices ) ;
glDrawElements( GL_QUADS, 4, GL_UNSIGNED_BYTE, topIndices ) ;
glDrawElements( GL_QUADS, 4, GL_UNSIGNED_BYTE, bottomIndices ) ;
}
static void Redisplay( void )
{
sgMat4 matrix ;
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
glLoadIdentity( ) ;
glTranslatef( 0, 0, -5 ) ;
glPushMatrix( ) ;
{
glTranslatef( QuatPos[ SG_X ], QuatPos[ SG_Y ], QuatPos[ SG_Z ] ) ;
sgQuatToMatrix( matrix, QuatRot ) ;
glMultMatrixf( (float*)matrix ) ;
DrawCube( ) ;
}
glPopMatrix( ) ;
glPushMatrix( ) ;
{
glTranslatef( EulerPos[ SG_X ], EulerPos[ SG_Y ], EulerPos[ SG_Z ] ) ;
sgMakeRotMat4( matrix, EulerRot ) ;
glMultMatrixf( (float*)matrix ) ;
DrawCube( ) ;
}
glPopMatrix( ) ;
glutSwapBuffers( ) ;
}
static void Idle( )
{
static int lastTime = 0;
int time = glutGet((GLenum)GLUT_ELAPSED_TIME);
if (time > lastTime + 10)
{
RotateQuatCube( ) ;
RotateEulerCube( ) ;
lastTime = time;
}
glutPostRedisplay( ) ;
}
static void Keyboard( unsigned char key, int xPos, int yPos )
{
switch( key )
{
case 27:
exit( 0 ) ;
case 'q':
Quat[ SG_X ] = !Quat[ SG_X ] ;
break ;
case 'w':
Quat[ SG_Y ] = !Quat[ SG_Y ] ;
break ;
case 'e':
Quat[ SG_Z ] = !Quat[ SG_Z ] ;
break ;
case 'r':
InitQuatCube( ) ;
break ;
case 't':
sgSetVec3( Quat, 0, 0, 0 ) ;
break ;
case 'a':
Euler[ SG_X ] = !Euler[ SG_X ] ;
break ;
case 's':
Euler[ SG_Y ] = !Euler[ SG_Y ] ;
break ;
case 'd':
Euler[ SG_Z ] = !Euler[ SG_Z ] ;
break ;
case 'f':
InitEulerCube( ) ;
break ;
case 'g':
sgSetVec3( Euler, 0, 0, 0 ) ;
break ;
}
}
static void Reshape( int w, int h )
{
if( h == 0 )
{
h = 1 ;
}
glViewport( 0, 0, w, h ) ;
glMatrixMode( GL_PROJECTION ) ;
glLoadIdentity( ) ;
gluPerspective( 45.0f, (GLfloat)w / (GLfloat)h, 0.1f, 100.0f ) ;
glMatrixMode( GL_MODELVIEW ) ;
glLoadIdentity( ) ;
}
static void Init( void )
{
glClearColor( 0.0, 0.0, 0.0, 0.0 ) ;
glEnable(GL_DEPTH_TEST);
glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);
glEnableClientState( GL_VERTEX_ARRAY ) ;
glEnableClientState( GL_COLOR_ARRAY ) ;
glVertexPointer( 3, GL_FLOAT, 6*sizeof(GLfloat), cube_vertices ) ;
glColorPointer( 3, GL_FLOAT, 6*sizeof(GLfloat), &cube_vertices[3] ) ;
InitEulerCube( ) ;
InitQuatCube( ) ;
Reshape( XSIZE, YSIZE ) ;
}
int main( int argc, char **argv )
{
glutInit( &argc, argv ) ;
glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH ) ;
glutInitWindowSize( XSIZE, YSIZE ) ;
glutCreateWindow( "Quaternion Demo" ) ;
Init( ) ;
glutDisplayFunc( Redisplay ) ;
glutReshapeFunc( Reshape ) ;
glutKeyboardFunc( Keyboard ) ;
glutIdleFunc( Idle ) ;
glutShowWindow( ) ;
glutMainLoop( ) ;
return 0 ;
}
|
Sarà una cavolata, ma non riesco a capire cosa sbaglio!!
Grazie a chi mi saprà aiutare!!
Last edited by cruentatio on Mon May 02, 2005 2:33 pm; edited 1 time in total |
|