🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.help
Article #860

Problem with static linking on aix with gcc2.6.3

#860
From: Knut Ole Hovda
Date: Mon, 18 Dec 1995 11:17
71 lines
3358 bytes
Hello,

I have an application written in C++, which also links in a library 
written in Fortran. It uses no X11 libraries, it simply reads a file,
processes the data, and writes an ASCII file.

The application is running fine on my machine (RS6000 model 250 running 
aix3.2.5), but crashes when our customers run it:

  "child killed: Illegal instruction (core dumped)"

This happens on the same version of the operating system, and for two 
different customers. None of them probably have gcc installed, though.

So far we have assumed that this indicates that the application isn't 
properly statically linked. On aix, this can be checked with the dump -H 
command, which gives

                        ***Import File Strings***
INDEX  PATH                          BASE                MEMBER              
0      /system/madeira_3c/pubdom/aix/lib:/usr/lib:/lib                                        
1                                    libc.a              shr.o               
2                                    libxlf90.a          xlfsys.o            
3                                    libxlf90.a          io.o                

Using the option -static to gcc however, gives a much larger executable, 
and dump -H now gives

                        ***Import File Strings***
INDEX  PATH                          BASE                MEMBER              
0      
/system/madeira_3c/pubdom/aix/lib/gcc-lib/powerpc-ibm-aix3.2.5/2.6.3:/sy
stem/madeira_3c/pubdom/ 
1      /                             unix                                    

which should indicate it now is statically linked. But our customers 
still have the same problem: The executable crashes, even though it runs 
fine here!

So my question is how one can achieve static linking on aix when using 
gcc. Or can there be another explanation to the problem?

>From the makefile:

C+ = g++
../$(SYS)/c-orion-1 : $(OBJECTS) $(LIB1) $(LIB2) $(LIB1)
        $(C+) $(LDFLAGS) $(OBJECTS) $(LIB1) $(LIB2) $(LIB1) 
$(POST_LDFLAGS)

CFLAGS = -D$(SYS) -DINSERT_UNDERSCORE
LDFLAGS  = -static -o ../$(SYS)/c-orion-1 
POST_LDFLAGS  = /usr/lpp/xlf/lib/lowsys.exp -lxlf90 -lm 
#
LIB1 = ${SCPSSHOME}/helaux-1.2/aix/object/helaux-1.2.a

The IBM Fortran manual suggests:

LDFLAGS  = -bnso -bI:/usr/lib/syscalls.exp -o ../$(SYS)/c-orion-1 

With this, it links fine, but the executable crashes with a segmentation 
fault!

Any hints are appreciated. Please respond directly to kho@scandpower.no,
as I usually don't have access to news.

--
Knut Hovda                                      E-mail: kho@scandpower.no
Consultant, Software Development                Phone: +47 63 81 49 20
Division for Nuclear and Petroleum Engineering  Fax: +47 63 81 88 22
Scandpower A/S, International Consultants       Address: P.O. Box 3
--                                              N-2007 Kjeller, NORWAY
Technical Details
Message-ID: <4b3ijh$lqp@nntp.nta.no>
Path: arc1-ca.pugleaf.net!hydra.unik.no!knuthov

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!hydra.unik.no!knuthov
From: knuthov@hydra.unik.no (Knut Ole Hovda)
Newsgroups: gnu.g++.help,gnu.gcc.help,comp.unix.aix,comp.lang.c++
Subject: Problem with static linking on aix with gcc2.6.3
Date: 18 Dec 1995 11:17:04 GMT
Organization: UNIK - Center for Technology at Kjeller, Norway
Distribution: world
Message-ID: <4b3ijh$lqp@nntp.nta.no>
NNTP-Posting-Host: hydra.unik.no
Keywords: gcc, aix, fortran, static, linking