Hi.

I'm faced with a problem with the netrek build on OSX using gcc-4.0.1,
I'll try to outline it briefly, show error output, and show a minimal
example that reproduces the error.

Brief Outline:
Symbols defined in a .o file inserted into a .a file fail to be seen
by the linker at link time.

To Reproduced under OSX:
CFLAGS=-I/opt/local/include ./configure
make

End of error output looks like:
gcc -o message  -I/opt/local/include -Wall  -DRSA -I../include
message.o ../ntserv/libnetrek.a   -lresolv -lm
gcc  -I/opt/local/include -Wall  -DRSA -I../include   -c -o
newscores.o newscores.c
gcc -o newscores  -I/opt/local/include -Wall  -DRSA -I../include
newscores.o ../ntserv/libnetrek.a   -lresolv -lm
/usr/bin/ld: Undefined symbols:
_Global
_PlayerFile
_status
_Access_File
_Banned_File
_Basep
_Bypass_File
_Cambot
_Cambot_out
_Clue_Bypass
_ConqFile
_Daemon
_Error_File
_Feature_File
_GodLog
_Inl
_LogFile
_LogFileName
_Mars
_MesgLog
_Motd_Path
_Newbie
_NoCount_File
_PlFile
_PlayerIndexFile
_PreT
_Prog
_Puck
_RSA_Key_File
_Robodir
_Robot
_Scores
_Scum_File
_SysDef_File
_Time_File
collect2: ld returned 1 exit status
make[1]: *** [newscores] Error 1
make: *** [do_utilities] Error 2

Minimal Test Case:
Copy attached makefile to an empty directory, and run 'make'

Expected output:
$ make
echo 'extern void bar(); int main (int argc, char**argv) { bar();
return 0; }' > three.c
gcc -c -o three.o three.c
echo "char foo[256];" > one.c
gcc -c -o one.o one.c
echo 'extern char foo[]; void bar() { strcpy(foo, "test"); }' > two.c
gcc -c -o two.o two.c
ar cru libfoo.a one.o two.o
gcc -o completed three.o libfoo.a
$ ./completed ; echo $?
0

Output found when using gcc-4.0.1 on OSX:
$ make
echo 'extern void bar(); int main (int argc, char**argv) { bar();
return 0; }' > three.c
gcc -c -o three.o three.c
echo "char foo[256];" > one.c
gcc -c -o one.o one.c
echo 'extern char foo[]; void bar() { strcpy(foo, "test"); }' > two.c
gcc -c -o two.o two.c
two.c: In function 'bar':
two.c:1: warning: incompatible implicit declaration of built-in
function 'strcpy'
ar cru libfoo.a one.o two.o
gcc -o completed three.o libfoo.a
/usr/bin/ld: Undefined symbols:
_foo
collect2: ld returned 1 exit status
make: *** [completed] Error 1

Ignoring the warning brought on by doing a strcpy without the relevent
header file, you see clearly the undefined symbol. Also note this is
the output of 'nm' in the error case:

$ nm libfoo.a

libfoo.a(one.o):
00000100 C _foo

libfoo.a(two.o):
00000000 T _bar
         U _foo


-- 
Stephen Thorne

"Give me enough bandwidth and a place to sit and I will move the world."
  --Jonathan Lange
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Makefile
Type: application/octet-stream
Size: 543 bytes
Desc: not available
Url : http://mailman.us.netrek.org/pipermail/netrek-dev/attachments/20060517/ccab5ae9/attachment.obj