LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 07-02-2007, 03:05 PM   #1
Alkibiades
LQ Newbie
 
Registered: Dec 2005
Posts: 21

Rep: Reputation: 15
Question undefined references when compiling PLIB program


Hello all,

I have some problems when I try to compile programs wherein I use the PLIB (http://plib.sourceforge.net/index.html). So I tried to compile one of the sample programs that go with it, and I get the same undefined reference errors. Am I specifying the wrong compiler options? This is what happens:

Quote:
$ g++ -g -Wall -I/usr/include -L/usr/lib -lglut -lGL -lGLU -L/usr/X11/lib -lX11 -lXext -lXmu -lm -L/usr/lib -lplibpu -lplibfnt -lplibsg -lplibul -o simple simple.cxx
/tmp/cccdQIhC.o: In function `displayfn()':
/home/jp/downloads/plib_examples-1.8.4/src/pui/simple.cxx:66: undefined reference to `puDisplay()'
/tmp/cccdQIhC.o: In function `mousefn(int, int, int, int)':
/home/jp/downloads/plib_examples-1.8.4/src/pui/simple.cxx:57: undefined reference to `puMouse(int, int, int, int)'
/tmp/cccdQIhC.o: In function `motionfn(int, int)':
/home/jp/downloads/plib_examples-1.8.4/src/pui/simple.cxx:51: undefined reference to `puMouse(int, int)'
/tmp/cccdQIhC.o: In function `puInitGLUT()':
/usr/include/plib/puGLUT.h:66: undefined reference to `puSetWindowFuncs(int (*)(), void (*)(int), void (*)(int*, int*), void (*)(int, int))'
/usr/include/plib/puGLUT.h:67: undefined reference to `puRealInit()'
/tmp/cccdQIhC.o: In function `puButton':
/usr/include/plib/pu.h:1031: undefined reference to `puObject:uObject(int, int, int, int)'
/usr/include/plib/pu.h:1031: undefined reference to `vtable for puButton'
/tmp/cccdQIhC.o: In function `puOneShot':
/usr/include/plib/pu.h:1053: undefined reference to `vtable for puOneShot'
/tmp/cccdQIhC.o: In function `puObject::setLegend(char const*)':
/usr/include/plib/pu.h:721: undefined reference to `puPostRefresh()'
collect2: ld returned 1 exit status
The source code of the sample program is:


Quote:
/*
PLIB - A Suite of Portable Game Libraries
Copyright (C) 2001 Steve Baker

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

For further information visit http://plib.sourceforge.net

$Id: simple.cxx,v 1.11 2002/09/01 12:04:51 ude Exp $
*/


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef WIN32
# include <windows.h>
#else
# include <unistd.h>
#endif
#include <math.h>

#ifdef FREEGLUT_IS_PRESENT
# include <GL/freeglut.h>
#else
# ifdef __APPLE__
# include <GLUT/glut.h>
# else
# include <GL/glut.h>
# endif
#endif

#include <plib/pu.h>

//#define VOODOO 1

void motionfn ( int x, int y )
{
puMouse ( x, y ) ;
glutPostRedisplay () ;
}

void mousefn ( int button, int updown, int x, int y )
{
puMouse ( button, updown, x, y ) ;
glutPostRedisplay () ;
}

void displayfn ( void )
{
glClearColor ( 0.1f, 0.4f, 0.1f, 1.0f ) ;
glClear ( GL_COLOR_BUFFER_BIT ) ;

puDisplay () ;

glutSwapBuffers () ;

/* The next line is not neccessary - you could remove it safely without
affecting the functionality of this simple example program.

It exists because in every application which does some more stuff
than creating user interface widgets, you normally do want to
redraw your scenery as often as possible for smooth animation. */

glutPostRedisplay () ;
}

void button_cb ( puObject * )
{
fprintf ( stderr, "Hello World.\n" ) ;
}


int main ( int argc, char **argv )
{
#ifdef VOODOO
glutInitWindowPosition ( 0, 0 ) ;
#endif
glutInitWindowSize ( 640, 480 ) ;
glutInit ( &argc, argv ) ;

/* Note that in order for PUI and this example program to work, you
definitely don't need a depth buffer.

However, most applications using PUI do some more things than rendering
PUI widgets. In every "real" program, you usually do need a depth
buffer - we are requesting one in the next line so that PLIB programmers
can write their applications upon this example code without running
into problems. */

glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ) ;

glutCreateWindow ( "PUI Application" ) ;
glutDisplayFunc ( displayfn ) ;
glutMouseFunc ( mousefn ) ;
glutMotionFunc ( motionfn ) ;

#ifdef VOODOO
glutPassiveMotionFunc ( motionfn ) ;
#endif

puInit () ;

#ifdef VOODOO
puShowCursor () ;
#endif

puOneShot *b = new puOneShot ( 50, 50, 200, 80 ) ;

b -> setLegend ( "Say Hello" ) ;
b -> setCallback ( button_cb ) ;

printf ( "%d\n", PLIB_VERSION ) ;

glutMainLoop () ;

return 0 ;
}
Someone who knows what I'm doing wrong?

Thanks in advance,
yours, Alkibiades
 
Old 07-03-2007, 07:06 AM   #2
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Looks like another library or object needs to be linked in. Rather than frustrate yourself, this is a problem best solved by the project administrator. You should post this question on their help board or email them directly. I'd suggest to them that they provide a makefile with the source code.
ta0kira
 
Old 07-04-2007, 02:32 AM   #3
Alkibiades
LQ Newbie
 
Registered: Dec 2005
Posts: 21

Original Poster
Rep: Reputation: 15
Thanks, but that was not the problem. It turned out I specified the libraries in the wrong order.

Thanks,
yours, Co
 
Old 03-13-2010, 02:18 PM   #4
OmarOthman
LQ Newbie
 
Registered: Mar 2010
Posts: 1

Rep: Reputation: 0
Quote:
Originally Posted by Alkibiades View Post
Thanks, but that was not the problem. It turned out I specified the libraries in the wrong order.
I think it's more useful on your behalf to specify the correct order, at least for other people to benefit from the post!
 
  


Reply

Tags
compile error


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
undefined gfortran references when compiling with g77 StudMuffin Linux - Software 4 02-17-2007 06:06 AM
Compiling garnome 2.14.1 fails in libgnome(undefined references to popt...) Spooled Linux - Software 2 05-10-2006 07:14 PM
Undefined references with static libraries Nightfox Programming 2 10-28-2005 06:43 PM
texinfo - undefined references during make fitret Linux - Software 1 06-18-2005 02:38 PM
Qt 3.3.3 undefined references when linking Ch. 7 tutorial QtCoder Programming 3 11-07-2004 11:59 AM


All times are GMT -5. The time now is 08:02 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration