LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 10-23-2005, 02:48 PM   #1
csst0136
LQ Newbie
 
Registered: Oct 2005
Location: greece
Posts: 20

Rep: Reputation: 0
compile error srgp library in C


i compile the program:

#include <stdio.h>
#include "srgp.h"

int main()
{
SRGP_begin("hw", 500, 300, 1, TRUE);
SRGP_end();
return 1;
}

and i get

/tmp/cc4ddcut.o(text+0x27):In function 'main':
:undefined reference to 'SRGP_begin'

/tmp/cc4ddcut.o(text+0x2f):In function 'main':
:undefined reference to 'SRGP_end'
collect 2:ld returned 1 exit status
 
Old 10-24-2005, 11:25 AM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
You didn't link the lib that contains
SRGP_begin and SRGP_end on the compiler command line.

Or you didn't mention srgp.c after the -o option on the compiler command line.
 
Old 10-24-2005, 11:43 AM   #3
csst0136
LQ Newbie
 
Registered: Oct 2005
Location: greece
Posts: 20

Original Poster
Rep: Reputation: 0
how do i link the libraries?there is a file libsrgp.a which contains files with extension .o.I have put libsrgp.a into /usr/lib

i compile the program like :
gcc name_program.c
i dont use -o
 
Old 10-24-2005, 12:18 PM   #4
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
To link libraries, you add -l<libraryname> to your comand line. Library name is the name of a library that is usually in the form lib<libraryname>.so (or .a). So in your case, try using -lsrgp. You may also have to include -static to link static libraries (which is what a .a is), but I don't remember for sure.
 
Old 10-24-2005, 03:04 PM   #5
csst0136
LQ Newbie
 
Registered: Oct 2005
Location: greece
Posts: 20

Original Poster
Rep: Reputation: 0
i linked -lsrgp and i get more errors like the others
/tmp/****.o
undefined reference ****
 
Old 10-24-2005, 03:13 PM   #6
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
That's probably because srgp relies on additional libraries. Without seeing exact errors, we can't tell you what additional libraries you need to link, but one trick you can use to find out is to use grep.

For instance, say it is complaining about an undefined reference to xxxxxxx.

Type the following to see if there is a .so file in /usr/lib that has that function.

grep "xxxxxxx" /usr/lib/*.so

(Note: This sometimes find files that rely on that function as well, so it doesn't necessarily mean that the function is exported from all the .so files it finds...)

Now, assuming it found a reference xxxxxxx in libyyyyy.so, you could then try adding -lyyyyy.

Edit: You may also have to look in other library directories such as /usr/X11R6/lib. If you find a library you need in any directory that is not part of the standard library search path, you can add it to the search path by adding -L/path/to/library to your command line. Using my previous example, if you found that /usr/X11R6/lib/libyyyyy.so had what you needed you would add:

-L/usr/X11R6/lib -lyyyyy

Last edited by deiussum; 10-24-2005 at 03:28 PM.
 
Old 10-24-2005, 04:07 PM   #7
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

As I mentioned in a separate post: please e-mail me the link where you downloaded your version of srgp, and I'll try test building it myself and let you know what I find.

There's every chance it's a simple syntax error in your "makefile", or something not configured correctly in your environment.

On the other hand, it's also possible that this library isn't even intended for Linux, and it might be more trouble that it's worth trying to get it to compile and link.

Please let me know.

Your .. PSM
 
Old 10-24-2005, 04:17 PM   #8
csst0136
LQ Newbie
 
Registered: Oct 2005
Location: greece
Posts: 20

Original Poster
Rep: Reputation: 0
i run command grep and i found some libraries like
libKXL.so
libMagick.so
libplot.so
libgdraw.so
etc..

i linked just one of them for example libplot and i didnt get errors but when i run it with ./a.out i got

SRGP:Color table too full to share
A solution is to have the SRGP application request
0 planes in the 4th parameter to SRGP_begin.
For now, the application will have its own
color table rather than try to share.

SRGP FATAL ERROR:
X SERVER ERROR:
(examining the core will be usefull only if using X in synchronous mode):
Badmatch (invalid parameter attributes)

I AM ABOUT TO INVENTIONALLY CRASH SO YOU CAN LOOK
AT THE ACTIVATION STACK USING A DEBUGGER
If your application is an SRGP application ,please remember:
if the error message above says
that you sent a bad argument to a certain function,
you should run your program with tracing ON in order
to see exactly what you sent
If you already had tracing enabled,remember to look in
'SRGPlogfile' for the tracing messages
Aborted.
 
Old 10-24-2005, 04:22 PM   #9
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
He posted the location in his other duplicate thread as, http://www.cs.brown.edu/software/.

I took a quick look myself, and the examples makefile there also links in -lX11. My guess is that though this is an old library, it should work in Linux.

So, try add ing -L/usr/X11R6/lib -lX1ll.

If it still doesn't work, post the exact undefined references and/or try to find the appropriate library with grep.

Give a man a fish, he eats for a day. Teach a man to fish, he eats for a lifetime...
 
Old 10-24-2005, 04:31 PM   #10
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
Ok, looks like you got it to compile while I was posting my last response. You can find the SRGP docs at http://www.niksula.cs.hut.fi/~tik86120/X_srgp.html.

It says this about that fourth parameter of SRGP_begin:

Quote:
The fourth parameter is meaningful only on a display supporting color. It specifies how many planes of the color table should be reserved for SRGP's use; i.e., it places an upper bound on the number of colors that may be displayed simultaneously in the SRGP window. (The upper bound is colors, where is the number of planes.) The fourth parameter is ignored when the program is run on a bilevel display.

If the program is being run on a color display, and you send the special value "0" as the fourth parameter, SRGP will take over the entire color table, giving your application color support as rich as the hardware can offer. (After initializing SRGP, you can inquire the "canvas depth" to determine how many planes are available.) The disadvantage: it will be impossible for the user to simultaneously see the SRGP window's proper coloring and the other clients' windows' proper coloring. Thus, you should request "0" planes only when your application truly needs full control of the color table.
Are you running this from X? I might try passing 0 there to see what happens. Passing 1 sounds like you are requesting only 1 color. It does say it ignores it on a "bilevel display," but I'm not exactly sure what it means by that. I don't think I've ever heard that term used before, but my guess would be it means some sort of GUI system like X11...
 
Old 10-24-2005, 05:05 PM   #11
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Thank you very much, deiussum.

I'm exiting stage left for now. The main points that I found (posted in csst0136's other thread) are:

1. srgp.tar.Z extracts nicely into its own subdirectory. You don't need to copy anything into other
places (and certainly not into /usr/lib).

2. You can build the examples with the syntax:

make PROG=xxx (e.g. "make PROG=testpaint", from the "SRGP_DISTRIB/examples" subdirectory)

3. Before you do this, however, you must rebuild "libsrgp.a" (it does not appear to be a Linux/ELF archive)

4. You must add "-I../include", "-L../lib" (both in the sample Makefile) and "-L/usr/X11R6/lib" (SRGP pre-dates X11R6).

5. After you do all this, you can successfully build an SRGP app under Linux/X11R6.

I was not, however, able to successfully run it. For starters, it defaults to some assumptions about colormaps which don't appear to be true for contemporary X11 servers. Changing the 4th parameter from "3" to "0" didn't help. It's unclear what - if any - further problems csst0136 might run into if he were to debug the colormap problem.

'Hope that helps ... at least a little!

PS:
Any recommendations on a good API for "Learning Graphics 101 under Linux"? My top vote would be for Java (which has very good 2D and 3D APIs), but I'm very curious about SDL.

Do you have any recommendations, deiussum?
 
Old 10-24-2005, 05:18 PM   #12
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
Good findings, paulsm. I'm not at home right now so I can't mess with this srgp API at all myself.

Personally, I like OpenGL since most of the graphics I do is 3D based. (You can do 2D stuff too in the form of textured quads, but if you're looking for a typical 2D API it's probably not what you want.) With OpenGL, however, you still need a windowing API of some sort as it leaves window creation/events/etc. up to someone else. SDL is pretty good for creating a simple OpenGL window, but you can use pretty much any windowing API if you know what you are doing.
 
Old 10-25-2005, 08:24 AM   #13
csst0136
LQ Newbie
 
Registered: Oct 2005
Location: greece
Posts: 20

Original Poster
Rep: Reputation: 0
thanx a lot for helping me you already help me a lot especially to paulsm4 and deiussum

the problem has solved to run the examples.i just change the depth color from 16 bit to 8 bit from YAST.SRGP runs only for 8 bit.But the strange thing is that when i run the program it opens
a new window which is the place where i draw what the program does but everything becomes black.I can see just the bounds of the windows,the minimize and close button at top right of the window and the mouse cursor with white color.If i click out of the window then all becomes with color(very fine) but when i click into the window again it becomes all black again and what i draw is with white color.
 
Old 10-25-2005, 09:36 PM   #14
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

I suspect the problem with the "weird colors" is a combination of:

1. The library assumes an excessively low color resolution (you had to go into YaST2 and set the X server to 8-bit/256 color mode?)
... and ..
2. The library is using private (instead of shared) colors.

Again, this was all common practice 10 years ago ... but technology has changed.

I'm afraid I don't have time to go poking around SRGP myself to see if I can make it a little more "Linux-circa-2005-friendly". You're certainly welcome to try; I'd definitely encourage to you to post any questions to LQ.

I couldn't find any good, short web articles on Xlib colormaps that didn't have a lot of extraneous stuff but, if you're feeling ambitious, here are some links that'll tell you everything you need to know ... and then some!

http://www.rahul.net/kenton/colormap.html

http://tronche.com/gui/x/xlib/color/

http://tronche.com/gui/x/xlib/color/cell.html

http://www.rahul.net/kenton/40errs.html#Error37

... and ...

http://www.rahul.net/kenton/40errs.html#Error34

'Hope that helps .. PSM
 
  


Reply



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
library srgp csst0136 Programming 1 10-17-2005 11:28 AM
install srgp library 2D graphics csst0136 Solaris / OpenSolaris 2 10-17-2005 10:17 AM
installing srgp library csst0136 SUSE / openSUSE 1 10-16-2005 07:16 AM
NSS will not compile due to nspr4 library error juliensteel Linux - General 0 01-21-2005 08:40 AM
howto compile bin with my library using all-static and shared linked standart library stpg Programming 4 06-29-2004 04:20 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:52 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
Open Source Consulting | Domain Registration