Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 09-15-2007, 04:05 AM   #1
LQ Newbie
Registered: Sep 2007
Posts: 12

Rep: Reputation: 0
problem with g2 library

I have download and install g2-0.72 and trying to run the program bellow
compiling 'gcc test.c', its giving me the following errors

#include <g2.h>
#include <g2_PS.h>

int id;
id = g2_open_PS("", g2_A4, g2_PS_land);
g2_rectangle(id, 20, 20, 150, 150);

># gcc test.c

/tmp/cc8u4Gof.o(.text+0x29): In function `main':
: undefined reference to `g2_open_PS'
/tmp/cc8u4Gof.o(.text+0x6a): In function `main':
: undefined reference to `g2_rectangle'
/tmp/cc8u4Gof.o(.text+0x78): In function `main':
: undefined reference to `g2_close'
collect2: ld returned 1 exit status
any help...........
Old 09-15-2007, 05:01 PM   #2
Senior Member
Registered: Oct 2003
Location: hopefully not here
Distribution: Gentoo
Posts: 2,038

Rep: Reputation: 51
Its a linker problem, the linker is unable to locate the g2 functions. This is simply because you never told the linker what libraries to link to. I dont know what the g2 library is called, if you look in the library directories and see something like or whatever, just cut off the first part, the "lib", and then you have the library name to link to, as so:

gcc test.c -lg2
assuming the actual library file is called "libg2.whatever"

the "-l" switch tells the compiler what libraries to link against, immediately following that switch, without a space, is the library name.

Last edited by SciYro; 09-15-2007 at 05:02 PM.


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
LINUX - linking archive (static library) with shared (dynamic) library gurkama Programming 5 03-04-2007 11:11 PM
howto compile bin with my library using all-static and shared linked standart library stpg Programming 4 06-29-2004 04:20 AM
what is the function library of the basic graphics library in rethat9.0? zerwolve Red Hat 0 04-29-2004 09:18 PM
gd library problem! ganninu Linux - General 1 03-13-2004 12:22 PM
Shared library problem (BIG problem) jlg Slackware 1 03-25-2003 10:56 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:45 AM.

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