[comp.unix.amiga] Problem with gcc

tll@nntp-server.caltech.edu (Tal Lewis Lancaster) (05/19/91)

After compiling all of my .c files using gcc, I get the following
message when it is trying to link:

Undefined symbols        First referenced in
----------------------------------------------
select                   /usr/lib/libsocket.so
syslog                   /usr/lib/libsocket.so
seteuid                  /usr/lib/libsocket.so

Now to the best of my knowledge I never mentioned any of these symbols
in any of my source.  Nor do I tell gcc to use /usr/lib/libsocket.so.
So I have two questions:

1. Who is the culpret for needing (referencing) these?
2. What other libraries do I need?

Thank-you,


Tal Lancaster

emmonsl@athena.ecs.csus.edu (L. Scott Emmons) (05/21/91)

In article <1991May19.144743.25904@nntp-server.caltech.edu> tll@nntp-server.caltech.edu (Tal Lewis Lancaster) writes:
>After compiling all of my .c files using gcc, I get the following
>message when it is trying to link:
>
>Undefined symbols        First referenced in
>----------------------------------------------
>select                   /usr/lib/libsocket.so
>syslog                   /usr/lib/libsocket.so
>seteuid                  /usr/lib/libsocket.so

The only way I could get socket stuff to work on my UX was to make sure that
/usr/ucb was in the path before /usr/ccs.  Also you need to execute gcc
thusly:

	gcc -o file file.c -lsocket -lucb
			   ^^^^^^^^ ^^^^^

/usr/ucb/ld will complain about some library (libsocket.so, I think) being
included twice, but it will work ok.

Strangely 'nuff, if you want to compile&link programs which don't use sockets
and BSD stuff, /usr/ucb must _not_ be in the path before /usr/ccs...very,very
strange behavior!

I posted an inquiry about this problem about 3 weeks ago to this newgroup, and
received only one reply; If you figger anything else out about this, please
let me know!

Good luck!

			L. Scott Emmons
			---------------
	emmons@csus.csus.edu  <or>  ...[ucbvax]!ucdavis!csus!emmons
		Packet: kc6nfp@kg6xx.#nocal.ca.usa.na

davidm@cbmvax.commodore.com (David Miller - CATS) (05/21/91)

In article <1991May19.144743.25904@nntp-server.caltech.edu> tll@nntp-server.caltech.edu (Tal Lewis Lancaster) writes:
|After compiling all of my .c files using gcc, I get the following
|message when it is trying to link:
|
|Undefined symbols        First referenced in
|----------------------------------------------
|select                   /usr/lib/libsocket.so
|syslog                   /usr/lib/libsocket.so
|seteuid                  /usr/lib/libsocket.so


In article <1991May21.045217.19569@csusac.csus.edu> emmonsl@athena.ecs.csus.edu (L. Scott Emmons) writes:
|The only way I could get socket stuff to work on my UX was to make sure that
|/usr/ucb was in the path before /usr/ccs.  Also you need to execute gcc
|thusly:
|
|	gcc -o file file.c -lsocket -lucb
|			   ^^^^^^^^ ^^^^^
|
|/usr/ucb/ld will complain about some library (libsocket.so, I think) being
|included twice, but it will work ok.
|
|Strangely 'nuff, if you want to compile&link programs which don't use sockets
|and BSD stuff, /usr/ucb must _not_ be in the path before /usr/ccs...very,very
|strange behavior!

By default, gcc and cc will use the System V include files and
libraries.  To compile BSD programs, you need to do the following:


	[g]cc -I/usr/ucbinclude -L/usr/ucblib -o file file.c -lsocket -lucb

This tells the preprocessor to look for include files in
/usr/ucbinclude before trying /usr/include and tells the linker to
look for libraries in /usr/ucblib.

DavidM
--
DavidM			CATS - Commodore Applications and Technical Support
+1 215 431 9425		davidm@cbmvax.commodore.com
"Commodore Amiga 3000UX - Born to Run UNIX SVR4"

wild@nessie.cs.id.ethz.ch (Markus Wild) (05/22/91)

In article <1991May21.045217.19569@csusac.csus.edu> emmonsl@athena.ecs.csus.edu (L. Scott Emmons) writes:
>In article <1991May19.144743.25904@nntp-server.caltech.edu> tll@nntp-server.caltech.edu (Tal Lewis Lancaster) writes:
>The only way I could get socket stuff to work on my UX was to make sure that
>/usr/ucb was in the path before /usr/ccs.  Also you need to execute gcc
>thusly:
>
>	gcc -o file file.c -lsocket -lucb
>			   ^^^^^^^^ ^^^^^

You are asking for troubles at the moment including -lucb... Besides,
gcc normally doesn't use /usr/ucbinclude (unless you tell it with
-Iucbinclude), and if you link with -lucb you might get unexpected
results due to incompatible headers with the libraries you use. In my
experience, the less I had to use from -lucb, the higher was the chance
to get a working executable in the first run;-)
So I'd strongly plea for having /usr/ccs/bin BEFORE /usr/ucb in your
path.

-Markus



-- 
Markus M. Wild    - mwild@iiic.ethz.ch  |  wild@nessie.cs.id.ethz.ch
--
Still looking for a REAL debugger for Release 4 ...