*BSD News Article 26892


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!munnari.oz.au!ariel.ucs.unimelb.EDU.AU!ucsvc.ucs.unimelb.edu.au!lugb!latcs1!wongm
Newsgroups: comp.os.386bsd.questions
Subject: [FreeBSD-1.0.2] : Problem of long .o filenames in library (.a file)
Message-ID: <CKr9zw.G92@latcs1.lat.oz.au>
From: wongm@latcs1.lat.oz.au (M.C. Wong)
Date: Sat, 5 Feb 1994 14:38:19 GMT
Organization: Comp Sci, La Trobe Uni, Australia
Lines: 87

Hi,
  I am experiencing some problems with building libary (*.a file) with
long *.o member files names, ie longer than 15 characters. Here is an
example :
	Having compiled longlonglonglongf1.c and longlonglonglongf2.c, I did : 
ar cqv liblong.a longlonglonglongf1.o longlonglonglongf2.o 
ranlib liblong.a
cc -o main main.c liblong.a
ld: bad magic number in liblong.a(#1) 

  But this works on SunOS! 
  Also, if I did :
cp longlonglonglongf1.o f1.o
cp longlonglonglongf2.o f2.o
ar cqv libshort.a f1.o f2.o
cc -o main main.c libshort.a
  
  and this works just fine, Also, in some instanc, when I got many many *.o
files with long names, I failed during ranlib, I run into erros as well,
here is an example :

slip33# make
rm -f _Bumpgame.a
ar q _Bumpgame.a _Bumpgame.o _Bumpgame.tc.o _Bumpgame.ch.o
ar: creating archive _Bumpgame.a.
ar q _Bumpgame.a _Daemon.o _Daemon.tc.o _Daemon.ch.o
ar q _Bumpgame.a _Player.o _Player.tc.o _Player.ch.o
ar q _Bumpgame.a _Manager.o _Manager.tc.o _Manager.ch.o
ar q _Bumpgame.a _Distributor.o _Distributor.tc.o _Distributor.ch.o
ar q _Bumpgame.a _Game.o _Game.tc.o _Game.ch.o
ar q _Bumpgame.a _GameMachineBody.o _GameMachineBody.tc.o _GameMachineBody.ch.o
ranlib _Bumpgame.a
ranlib: _Bumpgame.a: Inappropriate file type or format
*** Error code 1

  I don't do ranlib, then when I attempt to link with that library, I will
get this error :
ld: bad magic number in _Bumpgame.a(#1)
*** Error code 1

Stop.

  I wonder is someone know of the way of getting around this problem WITHOUT
using -T switch in ar to truncate the *.o filenames ? 

  Thanks in advance, and email replies please.
  The following are the files I tested on:
################################################################################
/* main.c */
#include <stdio.h>
#include "longlonglonglongf1.h"
#include "longlonglonglongf2.h"

main()
{
  longlonglonglongf1();
  longlonglonglongf2();
}

################################################################################
/* longlonglonglongf1.h */
void longlonglonglongf1();
################################################################################
/* longlonglonglongf1.c */
#include <stdio.h>
#include "longlonglonglongf1.h"

void longlonglonglongf1()
{
  puts("Inside longlonglonglongf1()");
}
################################################################################
/* longlonglonglongf2.h */
void longlonglonglongf2();
################################################################################
/* longlonglonglongf2.c */
#include <stdio.h>
#include "longlonglonglongf2.h"

void longlonglonglongf2()
{
  puts("Inside longlonglonglongf2()");
}
################################################################################
- wongm@latcs1.lat.oz.au (M.C Wong)
-- 
- wongm@latcs1.lat.oz.au