LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


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

Rep: Reputation: 0
problem with g2 library


Hi,
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>

main()
{
int id;
id = g2_open_PS("rect.ps", g2_A4, g2_PS_land);
g2_rectangle(id, 20, 20, 150, 150);
g2_close(id);
}

># 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, 06:01 PM   #2
SciYro
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 libg2.so or whatever, just cut off the first part, the "lib", and then you have the library name to link to, as so:

Code:
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 06:02 PM.
 
  


Reply


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


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

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration