[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

./executeable: relocation error: ./executeable: undefined symbol: fstat

Posted on 2010-01-05
75
Medium Priority
?
1,214 Views
Last Modified: 2013-12-13
hi,
i have successfully compiled my code of C program i was getting error of fstat before which was removed by restoring the stat.h to original form. but now when i start executing the program  like ./executable  param1   it give the above error.  
I searched the net and saw nm -D command when i ran it "nm -D executable" it gives
        U strcasecmp
         U strcat
         U strchr
         U strcmp
         U strcpy
         U strerror
         U strftime
         U strlen
         U strncat
         U strncmp
         U strncpy
         U strptime
         U strrchr
         U strspn
         U strstr
         U strtok
         U fstat
and many more,
how do i resolve it . my make file executes this command at the last.
cc -g  -D__IBM__  -DORACLE_DB -D__ENGLISH__ -D__PERFORMANCE__ -D__DBV__ -DPING_BY_SH   -DPOSIX -DMSG -DSQLTRACE -DSBULK -o executable ./folder1/executable.o ./folder1/xmlf.o ./datb.o ./folder1/folder1.o ./folder1/metercon.o ./folder1/convert.o ./folder1/readinfo.o ./folder1/aconv.o ./folder1/asF.o ./folder1/azg.o ./folder1/timewrap.o ./folder1/timetools.o ./folder1/byteorder.o ./folder1/reversebuf.o ./folder1/filter.o ./folder1/qdb.o ./folder1/dbfconvert.o ./folder1/atimes.o ./folder1/cdb.o ./folder1/sq.o ./common/mqpost.o ./common/ipc_name.o ./common/error.o ./common/strwrap.o ./common/wrapunix.o ./common/getprofile.o ./common/margv.o ./common/tracefile.o ./common/checkpid.o ./common/applog.o ./common/lock.o ./common/earg.o ./common/mq.o ./abs1/afile.o ./abs1/asn1.o ./abs1/public.o ./abs1/adic.o ./abs1/abi.o ./abs1/filter.o ./abs1/sq.o  -lm  -I./include  -I ./abs1/ -I/u01/app/oracle/product/9.2.0//precomp/public  -lm -I./include -I/u01/app/oracle/product/9.2.0//precomp/public -I/home/abc/socsap2.1 -L/home/abc/socsap2.1 -I/oracle_install/dblib.ora -L/oracle_install/dblib.ora -I/home/abc/ftib -L/home/abc/ftib -L. -L/usr/lib /oracle_install/dblib.ora/dblib.o -L/u01/app/oracle/product/9.2.0//lib -lclntsh -lpthread  -L/home/abc/socsap2.1 -lzxtsap -L/usr/lib/  -lrt

please tell me how to resolve fstat problem and all the other nm -D coming with "U" will they give problem and how to resolve them .
0
Comment
Question by:asaeed
  • 30
  • 19
  • 15
  • +1
74 Comments
 
LVL 40

Expert Comment

by:evilrix
ID: 26188395
The -D flag only has meaning when used against a DSO (Dynamic Shared Object)

From the man page...

-D
       --dynamic
           Display the dynamic symbols rather than the normal symbols.  This is only meaningful for dynamic objects, such as certain types of shared libraries.


All the symbols listed are standard C library functions that should just be linked in. Try compiling the code below. This runs fine on my machine and gives the following output using nm -D .a.out

nm -D a.out
080484ac R _IO_stdin_used
         U __fxstat
         w __gmon_start__
         U __libc_start_main

You can also use the ldd command to look at DSO dependencies. Again for the small test code below I get the following...

 ldd a.out
      linux-gate.so.1 =>  (0xb7f3e000)
      libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7ddb000)
      /lib/ld-linux.so.2 (0xb7f3f000)

What do you get?

#include <sys/stat.h>

int main()
{
   struct stat s;
   fstat(0, &s);
   return 0;
}

Open in new window

0
 
LVL 2

Author Comment

by:asaeed
ID: 26188435
OK  above mentioned code works, it means it doesnt have to do anything with my code ? but mine does not work
0
 
LVL 2

Author Comment

by:asaeed
ID: 26188453
testing1 test]$ ldd a.out
        /etc/libcwait.so => /etc/libcwait.so (0xb75e7000)
        libc.so.6 => /lib/tls/libc.so.6 (0xb749e000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0xb75eb000)
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 40

Expert Comment

by:evilrix
ID: 26188507
Thanks looks fine. And what ldd output do you get for your real program?
0
 
LVL 2

Author Comment

by:asaeed
ID: 26188572
ldd conversion
        /etc/libcwait.so => /etc/libcwait.so (0xb75e7000)
        libm.so.6 => /lib/tls/libm.so.6 (0xb75b4000)
        libclntsh.so.9.0 => /u01/app/oracle/oui/bin/linux/libclntsh.so.9.0 (0xb6ca6000)
        libpthread.so.0 => /lib/tls/libpthread.so.0 (0xb6c96000)
        librt.so.1 => /lib/tls/librt.so.1 (0xb6c81000)
        libc.so.6 => /lib/tls/libc.so.6 (0xb6b49000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0xb75eb000)
        libwtc9.so => /u01/app/oracle/oui/bin/linux/libwtc9.so (0xb6b46000)
        libdl.so.2 => /lib/libdl.so.2 (0xb6b43000)
        libnsl.so.1 => /lib/libnsl.so.1 (0xb6b2e000)
0
 
LVL 2

Author Comment

by:asaeed
ID: 26188594
for info -> i used this code on IBM AIX but now ported it to linux
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 26188628
You might have to leave out  -D__IBM__ (and possibly replace it with a Linux equivalent).
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 26188638
Check for any other IBM AIX specific issues in your makefile, and port them to Linux too.
0
 
LVL 2

Author Comment

by:asaeed
ID: 26188682
this option is only for some code specifics inside the code. like
#ifdef __IBM__
#pragma option align=packed
typedef struct
{
    unsigned l : 4;      
    unsigned h : 4;
}  
0
 
LVL 40

Expert Comment

by:evilrix
ID: 26188702
The ldd output doesn't seem to show any missing dependencies.

>> i was getting error of fstat before which was removed by restoring the stat.h to original form
What did you mean by that?

Also, have you tried building and running this on a different machine (in case it's a machine specific issue)?
0
 
LVL 7

Expert Comment

by:js-profi
ID: 26188743
mean to remember you used fstat as a variable. it is a function declared in stat.h and must not used as variable.
0
 
LVL 2

Author Comment

by:asaeed
ID: 26188804
i removed the _inline_ from the stat.h previously but now restored it.
machines are different too. i am using it on vmware env.
just checked no variable defined by this name.  
0
 
LVL 7

Assisted Solution

by:js-profi
js-profi earned 800 total points
ID: 26188966
try to get a stat.h from a new download.
0
 
LVL 7

Expert Comment

by:js-profi
ID: 26188974
better from a download that fits to the system runtimes.
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 26188977
stat.h comes with the system - don't use a custom one - use the one provided by the system.
0
 
LVL 2

Author Comment

by:asaeed
ID: 26197292
i think its some thing to do with compilation cuz i put the main() and put fstat in the first file where fstat is working. and it compiled ok and ran ok. I also make 2 testing files and compiled them together and called fstat in them and that worked ok too( no fstat error). so fstat seems ok. there is some compilation problem its not linking /compiling correctly ??
0
 
LVL 7

Expert Comment

by:js-profi
ID: 26197437
did you restore the stat.h to the file that originally comes with the compiler? your problems could be explained by either using two different stat.h files or by not having it restored to the original. can you moreover post the full error you get. i still don't know whether it is at compile, link or runtime.
0
 
LVL 2

Author Comment

by:asaeed
ID: 26197550
its runtime like when i execute
./executeable  param1
./executeable: relocation error: ./executeable: undefined symbol: fstat

one more thing this error is only coming in this executable. i have other executeables that are using same *.o files and they are working fine (I just checked them and was surprised to see they are working fine) the other exes are creating files, same files that this exe also creates and opens.
i debugged them and they also call the same function fstat() from same file/function. so i am thinking may be its the exe's compliation is going wrong
0
 
LVL 7

Expert Comment

by:js-profi
ID: 26197652
undefined symbol means the fstat wasn't linked to the executable.
0
 
LVL 2

Author Comment

by:asaeed
ID: 26197815
is there any special way to link it. my last cc is something like this
cc -g -DMETERSTD -D__IBM__  -DORACLE_DB -D__ENGLISH__ -D__PERFORMANCE__ -D__DBV__ -DPING_BY_SH   -DPOSIX -DMSG -DSQLTRACE -DSBULK -o executeable ./folder1/executeable.o ./common/mmq.o ./common/earg.o ./folder1/xml.o ./db.o ./folder1/folder1.o  -I./include  -I ./abc1/ -I/u01/app/oracle/product/9.2.0//precomp/public  -I./include -I/u01/app/oracle/product/9.2.0//precomp/public  -I/oracle_install/ctlib.ora -L/oracle_install/ctlib.ora   -L. -L/usr/lib /oracle_install/ctlib.ora/ctlib.o -L/u01/app/oracle/product/9.2.0//lib -lclntsh -lpthread  -lzxtsap -L/usr/lib/ -lrt
0
 
LVL 7

Expert Comment

by:js-profi
ID: 26197832
you need to remove the -D__IBM__  what already was said.
0
 
LVL 2

Author Comment

by:asaeed
ID: 26197897
actually the other exes also have same _IBM_ with them and they are running correctly. and stat.h dont use _IBM_ , and its used in my code for executing some functions. so is it absolutely neccessary to remove it?
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 26197965
>> so is it absolutely neccessary to remove it?

More specifically : you need to get rid of anything that is platform specific to the IBM AIX platform (and that is not compatible with the Linux platform), and replace it with equivalents for the Linux platform.

Furthermore, as has been said earlier : if you are using a custom stat.h header file, don't do that - use the one provided by the platform instead. Otherwise the linker might be looking for the wrong symbols.

Finally, the fact that the error occurs at runtime, as you say, indicates that the library is dynamically linked to the executable - was that your intention ?


>> i have other executeables that are using same *.o files and they are working fine

On the same platform ? Then look for the difference between the two (in the code, in the compilation commands, in the link commands).
0
 
LVL 7

Assisted Solution

by:js-profi
js-profi earned 800 total points
ID: 26198015
best you uninstall compiler and reinstall again.
0
 
LVL 40

Expert Comment

by:evilrix
ID: 26198018
>> best you uninstall compiler and reinstall again.
I doubt that's necessary since a simple test program compiles and runs just fine.
0
 
LVL 2

Author Comment

by:asaeed
ID: 26198079
infinity08 -> stat.h is now in orignal form. I have also tested fstat in sample program
On the same platform ? yes same platform and same file is used in different exe. like mmq.o is used in executable.o and also another_exe.o
library is dynamically linked to the executable - was that your intention ? No its not my requirement to link dynamically. it should be static/normal.
Actually the code used in _IBM_ is not platform specific till now. its for facilitating the AIX 4.X user if messageque is not available or shared mem not available it makes its own shared mem. so it doesn't matter for _IBM_ to stay.  
So the following is not linking ?? cuz i think it should be linking in this command. do i need any other parameter to link ?
cc -g -DMETERSTD -D__IBM__  -DORACLE_DB -D__ENGLISH__ -D__PERFORMANCE__ -D__DBV__ -DPING_BY_SH   -DPOSIX -DMSG -DSQLTRACE -DSBULK -o executeable ./folder1/executeable.o ./common/mmq.o ./common/earg.o ./folder1/xml.o ./db.o ./folder1/folder1.o  -I./include  -I ./abc1/ -I/u01/app/oracle/product/9.2.0//precomp/public  -I./include -I/u01/app/oracle/product/9.2.0//precomp/public  -I/oracle_install/ctlib.ora -L/oracle_install/ctlib.ora   -L. -L/usr/lib /oracle_install/ctlib.ora/ctlib.o -L/u01/app/oracle/product/9.2.0//lib -lclntsh -lpthread  -lzxtsap -L/usr/lib/ -lrt
I am checking the linking also.
p.s. thanks all for ur time and help
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 26198102
>> Actually the code used in _IBM_ is not platform specific till now

Ok. That makes things easier. But the makefiles might still contain platform dependent stuff. Could you maybe post your makefile. Could you also post the makfile for one of the executables that DOES work ?

If possible, it would also be useful if you could provide two code samples - one that doesn't work, and one that does (including the compilation/linking commands used).
0
 
LVL 2

Author Comment

by:asaeed
ID: 26198454
makefile attached
PLATFORM	= IBM
platform	= ibm
DATABASE	= ORACLE

#LANGUAGE	= CHINESE
LANGUAGE	= ENGLISH

EXEHOME	= .

UNIXSAPDIR	= /home/media/tsocsap2.1
clibDIR	= /oracle_install/clib.ora
FLDIR	= /home/media/ftplib

EXECOMMDIR	= $(EXEHOME)/common
#COLLECTMDDIR	= $(EXEHOME)/folder1
MDDIR	= $(EXEHOME)/folder1
COMMDIR	= $(EXEHOME)/common
AASSDIR	= $(EXEHOME)/as1
EXEFTPDIR	= $(EXEHOME)/ftp
EXEFTPIDIR	= $(EXEHOME)/fm
EXEGODIR	= $(EXEHOME)/dish
EXEMONDIR	= $(EXEHOME)/wg
EXESCHDIR = $(EXEHOME)/sce
EXEFLDIR = $(EXEHOME)/workflow

IBMCC		= cc 
HPCC		= cc
SUNCC		= cc
COMPAQCC	= cc

CCC	= $($(PLATFORM)CC)

SUNFLAGS	= -Xa
HPFLAGS		= -Ae
#IBMFLAGS	= -qlanglvl=EXT 
COMPAQFLAGS	= -D__COMPAQ5__
#COMPAQFLAGS	= 

CCFLAGS	= -g -DMETERSTD -D__$(PLATFORM)__ $($(PLATFORM)FLAGS) -D$(DATABASE)_DB -D__$(LANGUAGE)__ -D__PERFORMANCE__ -D__DBV__ -DPING_BY_SH #-DMEMORY_DEBUG
#-DCOMPARE_ONE_BYTE
#-D__AREACODE__
#-DCHECKSEQ
#-DHOURBEGIN
#-D__CHECKFILECONTENT__

SUNOPTIONS		= -Ae
HPOPTIONS		= -Ae
IBMOPTIONS		= 
COMPAQOPTIONS	= 

CCOPTIONS	= $($(PLATFORM)OPTIONS) -DPOSIX -DMSG -DSQLTRACE -DSBULK
#-DDEBUG

INFORMIXINC	= -I$(INFORMIXDIR)/incl/esql
SYBASEINC	= -I$(SYBASEDIR)/include
ORACLEINC	= -I$(ORACLE_HOME)/precomp/public

INFORMIXLIBS	= -L$(INFORMIXDIR)/lib -L$(INFORMIXDIR)/lib/esql -lthsql
SYBASELIBS      = -L$(SYBASEDIR)/lib -ltcl -lcomn -lintl -lblk -lct -lcs
ORACLELIBS      = -L$(ORACLE_HOME)/lib -lclntsh

LOCAL 		= -I$(EXEHOME)/include \
		$($(DATABASE)INC) -I$(UNIXSAPDIR) -L$(UNIXSAPDIR) \
		-I$(clibDIR) -L$(clibDIR) \
		-I$(FLDIR) -L$(FLDIR) -L. -L/usr/lib

CLOC=  -I$(EXEHOME)/include  -I $(EXEHOME)/as1/ -I$(ORACLE_HOME)/precomp/public

SUNLIBS		= -lpthread -lposix4 -lsocket -lnsl -lm -lxnet -lresolv
#IBMLIBS		= -lpthread  
IBMLIBS		= -lpthread 
HPLIBS		= -lpthread -lrt -lxnet  -lnsl 
COMPAQLIBS	= -lpthread -lmysem -lrt -lxnet 

LIBS	= $($(DATABASE)LIBS) $($(PLATFORM)LIBS) -L$(UNIXSAPDIR) -lzxtsap -L/usr/lib/ -lrt

INFORMIXCC	= esql -thread -keepccomment
SYBASECC    = cc
ORACLECC    = cc

ECC		= $($(DATABASE)CC) $(CCFLAGS) $(CCOPTIONS)


clib 	 	= $(clibDIR)/clib.o

HPexportarg		=$(EXECOMMDIR)/exportarg_hp.o
SUNexportarg	=$(EXECOMMDIR)/exportarg.o
IBMexportarg	=$(EXECOMMDIR)/exportarg.o
COMPAQexportarg	=$(EXECOMMDIR)/exportarg.o

IBMCOMMON = $(EXECOMMDIR)/shmw.o $(EXECOMMDIR)/shmr.o
HPCOMMON =
SUNCOMMON =
COMPAQCOMMON =



#DEBUGFLAGS       = -DMSG -DMEMORY_DEBUG -DDEBUG
DEBUGFLAGS       = -DMSG -DDEBUG
#----------------------Conversion---------------------#
MDOBJS=$(MDDIR)/convertmain.o \
$(MDDIR)/convert.o \
$(MDDIR)/folder1.o \
$(MDDIR)/eonv.o \
$(MDDIR)/fonv.o \
$(MDDIR)/mon.o \
$(MDDIR)/readinfo.o \
$(MDDIR)/dbft.o \
$(MDDIR)/timewrap.o \
$(MDDIR)/timetools.o \
$(MDDIR)/bytrder.o \
$(MDDIR)/revbuf.o \
$(MDDIR)/filer.o \
$(MDDIR)/aces.o \
$(MDDIR)/cose.o \
$(MDDIR)/fiseq.o \
$(MDDIR)/qdb.o \
$(EXEHOME)/db.o \
$(MDDIR)/xml.o \
$(COMMDIR)/getp.o \
$(COMMDIR)/mqp.o \
$(COMMDIR)/ipc_name.o \
$(COMMDIR)/error.o \
$(COMMDIR)/strwrap.o \
$(COMMDIR)/wrunix.o \
$(COMMDIR)/margv.o \
$(COMMDIR)/tracefile.o \
$(COMMDIR)/checkpid.o \
$(COMMDIR)/applog.o \
$(COMMDIR)/lock.o \
$(COMMDIR)/mymq.o \
$(AASSDIR)/ase.o  \
$(AASSDIR)/a1.o \
$(AASSDIR)/public.o \
$(AASSDIR)/reaic.o \
$(AASSDIR)/real.o  \
$(AASSDIR)/filer.o \
$(AASSDIR)/filseq.o \
$($(PLATFORM)earg) 
        
MD2DIR=$(MDDIR)/conversion.o \
$(COMMDIR)/mq.o\
$(MDDIR)/xml.o \
$(EXEHOME)/dbase.o \
$(MDDIR)/folder1.o \
$$(MDDIR)/folder1.o \
$(MDDIR)/eonv.o \
$(MDDIR)/fonv.o \
$(MDDIR)/mon.o \
$(MDDIR)/readinfo.o \
$(MDDIR)/dbft.o \
$(MDDIR)/timewrap.o \
$(MDDIR)/timetools.o \
$(MDDIR)/bytrder.o \
$(MDDIR)/revbuf.o \
$(MDDIR)/filer.o \
$(MDDIR)/aces.o \
$(MDDIR)/cose.o \
$(MDDIR)/fiseq.o \
$(MDDIR)/qdb.o \
$(EXEHOME)/db.o \
$(MDDIR)/xml.o \
$(COMMDIR)/getp.o \
$(COMMDIR)/mqp.o \
$(COMMDIR)/ipc_name.o \
$(COMMDIR)/error.o \
$(COMMDIR)/strwrap.o \
$(COMMDIR)/wrunix.o \
$(COMMDIR)/margv.o \
$(COMMDIR)/tracefile.o \
$(COMMDIR)/checkpid.o \
$(COMMDIR)/applog.o \
$(COMMDIR)/lock.o \
$(COMMDIR)/mymq.o \
$(AASSDIR)/ase.o  \
$(AASSDIR)/a1.o \
$(AASSDIR)/public.o \
$(AASSDIR)/reaic.o \
$(AASSDIR)/real.o  \
$(AASSDIR)/filer.o \
$(AASSDIR)/filseq.o \
$($(PLATFORM)earg) 


#------------------------------------------#

COMMOBJECTS= $(EXECOMMDIR)/lock.o 	\
$(EXECOMMDIR)/getprofile.o \
$(EXECOMMDIR)/mmq.o \
$(EXECOMMDIR)/mqp.o \
$(EXECOMMDIR)/ipc_name.o \

$(EXECOMMDIR)/daemon_init.o \
$($(PLATFORM)exarg) \
$($(PLATFORM)COMMON)


MAINOBJECTS= $(EXEHOME)/ac.o \
$(EXEHOME)/ping.o \
$(EXEHOME)/proc_v4.o \
$(EXEHOME)/proc_v6.o \
$(EXEHOME)/readloop.o \
$(EXEHOME)/send_v4.o \
$(EXEHOME)/send_v6.o \
$(EXEHOME)/sig_alrm.o \
$(EXEHOME)/tv_sub.o \
$(EXEHOME)/inet_ntop.o \
$(EXEHOME)/inet_pton.o \
$(EXEHOME)/db.o \
$(EXEHOME)/qdb.o \
$(EXEHOME)/llc_ping.o \
$(EXEHOME)/proc_llc.o \
$(EXECOMMDIR)/getp.o \
$(EXECOMMDIR)/mqp.o \
$(EXECOMMDIR)/error.o \
$(EXECOMMDIR)/daemon_init.o \
$(EXECOMMDIR)/ipc_name.o \
$(EXECOMMDIR)/wrunix.o \
$(EXECOMMDIR)/zxcp.o \
$(EXECOMMDIR)/strwrap.o \
$(EXECOMMDIR)/applog.o \
$(EXECOMMDIR)/mmq.o \
$(EXECOMMDIR)/checkpid.o\
$($(PLATFORM)earg) 



WOBJ = $(EXEMONDIR)/acquire.o \
$(EXECOMMDIR)/ipc_name.o \
$(EXECOMMDIR)/error.o \
$(EXECOMMDIR)/applog.o \
$(EXECOMMDIR)/mmq.o \
$(EXECOMMDIR)/wrunix.o \
$(EXECOMMDIR)/getp.o \
$(EXECOMMDIR)/chpid.o \
$($(PLATFORM)exportarg) 



.c.o:
	$(CCC) $(CCFLAGS) -c $<  -o $*.o $(LOCAL)


common:		$(COMMOBJECTS)

watch:	$(WATCHOBJECTS)
	$(CCC)  -o $(EXEMONDIR)/acquire $(WATCHOBJECTS) $(LOCAL) $($(PLATFORM)LIBS) -lsocsap -lrt
	cp $(EXEMONDIR)/acq $(EXEHOME)/
watchclean:
	rm -f acquire $(EXEMONDIR)/acquire  $(EXEMONDIR)/*.o

cs: 	$(MAINOBJECTS)
	$(CCC) $(DEBUG) $(CCOPTIONS) -o $(@F) $(MAINOBJECTS) $(clib) $(LOCAL) $(LIBS) 

convmain: conversion convert

executable:$(MD2DIR) $(ASOBJS)
	$(CCC) -o $(@F) $(MD2DIR) $(ASNOBJS) $(CLOC)  $(LOCAL) $(clib) $(LIBS)
#convert: $(MDOBJS)
#	$(CCC) -o $(@F) $(MDOBJS) $(CLOC) $(LOCAL) $(clib) $(LIBS)

exec1: 	$(COBJECTS)	
	$(ECC)  $(CCOPTIONS) -o convert $(MDOBJS) $(CLOC) $(clib) $(LOCAL) $(LIBS) 
#	cp $(COLLECTMDDIR)/convert $(EXEHOME)/

shmunlink:	$(SHMOBJECTS)
	$(CCC) -o $(@F) $(SHMOBJECTS) $($(PLATFORM)LIBS)  $(LOCAL)  $(LIBS) -lsocsap 

semunlink:	$(SEMOBJECTS)
	$(CCC) -o $(@F) $(SEMOBJECTS) $($(PLATFORM)LIBS)  $(LOCAL) $(LIBS) -lsocsap

Open in new window

0
 
LVL 2

Author Comment

by:asaeed
ID: 26198455
other exes are in same makefile and they dont give fstat error
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 26198534
What's this ?

>> clib              = $(clibDIR)/clib.o

It looks suspiciously like a replacement for the standard C library ... Is that what it is ? If not, what is it ?


What are ASOBJS and ASNOBJS set to ?


>> other exes are in same makefile and they dont give fstat error

Which ones work, and which ones don't ?
0
 
LVL 7

Expert Comment

by:js-profi
ID: 26198541
they only can give fstat error at runtime when they were calling the fstat.

as you got the fstat error so late it means that a dynamically loaded library has the missing symbol. i still think that you were using libraries which were compiled with different stat.h. reinstall the compiler and make a new build for all executables and their libraries.
0
 
LVL 2

Author Comment

by:asaeed
ID: 26198562
i have cut short the file clibDIR is actually database and its not its actual name. "executable" (MDOBJ) etc doesnt work, watch (WOBJ) works , Main works
0
 
LVL 40

Expert Comment

by:evilrix
ID: 26198582
js-profi,

Until the problem has been correctly identified advising re-installation of the compiler is a drastic step to take that could have other consiquences and might introduce other problems. If we just reinstall the compiler we're changing the environment and as well as possibly not fixing the issue these changes may actually make it even harder to diagnose what's going on (since we may introduce other issues). Whilst I accept this might, in the end, be a solution I think we're jumping the gun a little here. Let's find out what the cause of the problem is first and then suggest solutions.

Since the asker is able to successfully link and run a test program I think the focus should be on trying to identify what is different between this and the one that doesn't work (as Infinity08 is attempting to do).

-Rx.
0
 
LVL 2

Author Comment

by:asaeed
ID: 26198596
js-profi   i am using
Linux MYCOMPUTER 2.4.21-15.EL #1 Thu Apr 22 00:27:41 EDT 2004 i686 i686 i386 GNU/Linux
gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-34)

please suggest website where i can get gcc for above mentioned OS version (rpm)
thanks
0
 
LVL 40

Expert Comment

by:evilrix
ID: 26198606
>> please suggest website where i can get gcc for above mentioned OS version (rpm)
Please see my comment above -- I don't think we're at this point yet.
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 26198642
>> watch (WOBJ) works , Main works

But those are using different object files than the ones that don't work. You said earlier they were using the same object files.

I'm not gonna be on-line for the rest of the day, so, people, feel free to continue where I left off ;)
0
 
LVL 2

Author Comment

by:asaeed
ID: 26198655
yes i think so too. seems somthing is fishy in compiling or linking.
0
 
LVL 40

Expert Comment

by:evilrix
ID: 26198662
>> so, people, feel free to continue where I left off ;)
Unfortunately, I just don't have the time to look at this right now either (snowed under with RL workload).

js-profi, by all means carry on with this if but please keep the idea of reinstalling the compiler as a last resort. Let's try and find out why this is happening before we suggest solutions. I'll carry on monitoring in case I can offer some assistance.

Good luck :)
0
 
LVL 2

Author Comment

by:asaeed
ID: 26198664
watch and main both use a file mmq.o which is the same file for my exe. when i run watch and main both run sucessfuly but executable dont.
0
 
LVL 7

Expert Comment

by:js-profi
ID: 26198736
don't think you were right. reinstalling the compiler isn't much difficult and is not very likely to give more problems than already exists (of course the old environment should be backuped before). it might be the only chance if system headers or libs were changed what seems the case here. i stick on my recommendation.

you would get compiler at http://gcc.gnu.org/releases.html or search your disk for already existing download archive.

0
 
LVL 40

Assisted Solution

by:evilrix
evilrix earned 400 total points
ID: 26199839
I'd like to suggest that, if possible, it's worth trying this on a different machine first -- to see if we can identify it might be an environment problem as js-profi suggests. If that proves to be the case then the suggestion of reinstalling the compiler may be worth exploring further; however, this is not an option without risk (it is possible a reinstall of the compiler may introduce other issues and not fix this one) so I'd suggest that is done as a last resort -- it is, of course, your decision to make.

It's also worth continuing to exploring the path Infinity08 was following. I'm sure Infinity08 will pick up where he left off when he eventually comes back online (he never leaves a question dangling).
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 26203020
Ok. I'm back :) I see there hasn't been much progress.

>> watch and main both use a file mmq.o which is the same file for my exe. when i run watch and main both run sucessfuly but executable dont.

Do all three of these binaries call fstat ? Is the fstat call located in the mmq.o object file that they share ?


Furthermore, I'd like you to confirm that you made sure that the (unmodified) platform stat.h header file is used everywhere. Just to make sure we're on the same page.
(don't assume it is so - check it)
0
 
LVL 2

Author Comment

by:asaeed
ID: 26207147
infinity08 -> yes same mmq and fstat is used in other exes. i have debugged and it calls the same function, same location.
right now i observed that there are many more warnings in the current "executable" than the other exes. so I am removing those warnings. wll this help ?
I also am trying to reinstall this package in mean while
0
 
LVL 7

Expert Comment

by:js-profi
ID: 26207448
try to call stat function instead of fstat. no solution but only workaround.
0
 
LVL 2

Author Comment

by:asaeed
ID: 26207816
yes i have already tried stat it doesnt work too.
0
 
LVL 7

Expert Comment

by:js-profi
ID: 26207877
is then 'stat' missing at runtime? if still fstat was missing you linked against a dynamic library which was not newly built.
0
 
LVL 2

Author Comment

by:asaeed
ID: 26207944
yes stat gives same error.
if still fstat was missing you linked against a dynamic library which was not newly built.  <- means ?
0
 
LVL 2

Author Comment

by:asaeed
ID: 26207950
u know i changed the stat.h to orignal do i need to recompile something for it to give effect? i dont think so , what u say.?
0
 
LVL 7

Expert Comment

by:js-profi
ID: 26208005
yes for any change of a header - special system header - you should have a 'make clean' and build *all* your executables and libraries.
0
 
LVL 7

Expert Comment

by:js-profi
ID: 26208069
a missing symbol in an executable means a function called or variable accessed where the linker before assumed it would be added externally, e. g. by a dynamically library or if the missing symbol is in the library by the main executable. in your case at runtime it turns out that the missing symbol can't get resolved. fstat is a function of the runtime libraries. if it was missing at runtime in my opinion there was already some bad at compile or linker time what could happen if for example there were different versions of stat.h used by modules (compiled object files). then the offset to functions - the address - could not be found at runtime, when those different stat.h files had different size. such different size also could be due to macros set for one module and not set for a second module. the only way out is to make a full rebuild. and even that can not help if there are different versions of libraries mixed up or libraries used from a different compiler platform.
0
 
LVL 53

Accepted Solution

by:
Infinity08 earned 800 total points
ID: 26208226
>> so I am removing those warnings. wll this help ?

It won't hurt ;) It's always a good idea to get rid of all warnings.


>> u know i changed the stat.h to orignal

Thank you for confirming that. This is absolutely necessary to make your code work.


>> do i need to recompile something for it to give effect?

The compiler (and the linker) gets its symbol information from the header files, so if a header file is changed, that symbol information might have been changed too ... So a rebuild of every source that includes the header file (directly or indirectly) is in order.
0
 
LVL 2

Author Comment

by:asaeed
ID: 26208381
i am rebuilding all my *.c files in the project. now here's something interesting
i changed the executable.c and put only
#include <stdio.h>
#include <fcntl.h>  
#include <sys/types.h>
#include <unistd.h>
#include <sys/stat.h>
#include <stdlib.h>

#include <sys/stat.h>
main()
{
struct stat s;
   fstat(0, &s);
   return 0;


}
in it and compiled the executable.c  and made a.out and ran a.out and its ok. BUT
when i ran it with make command "make executable" it compiles but when i run the "./executable", it gives the same error :). its making me MAD :)
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 26208402
>> when i ran it with make command "make executable"

The 'make executable' contains a lot more code than your simple test application ;)
0
 
LVL 2

Author Comment

by:asaeed
ID: 26208505
ok i think the problem is narrowing donw i have "-lclntsh" which seems to be giving problem, going home will work from there to resolve it, stay with me tommrow , thanks
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 26209079
>> i have "-lclntsh" which seems to be giving problem

What kind of problem ?

This library is related to Oracle - make sure you have the right version of it for your platform.
0
 
LVL 2

Author Comment

by:asaeed
ID: 26276465
C for linux gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-34)  
Redhat 2.4.21 E
and oracle is 9.2.0.4  libclntsh is 9.2.0.1 . are these compatible?
0
 
LVL 2

Author Comment

by:asaeed
ID: 26281034
i want to install newr version of gcc "gcc-3.3.3-7.i386.rpm" but cannot find any downloadable rpm. all the links i have seen till now are broken. I need it for Redhat 2.4.21 ES. can anyone help?
0
 
LVL 2

Author Comment

by:asaeed
ID: 26281049
what kind of problem <-   when i add this library to a test file too. it gives fstat error. so i thought may be this error is coming cuz libclntsh.so when installed it linked to wrong stat.h(changed) and now it cannot link with it. but i reinstalled the oracle and it was still giving the problem so i thought may be new compiler would help.
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 26281372
>> libclntsh.so

Where did you get this file ? Did you build it yourself ? Or did you download it ? From where ?


>> gcc version 3.2.3

This version dates from 2003. It's still somewhat recent, but there might have been changes between this version, and the one the libclntsh.so was compiled for. It's not common, but it can happen.

I wouldn't immediately decide to upgrade your gcc version ... Because that can have other unintended consequences.


>> 2.4.21

I assume this is the kernel version. In that case it also dates from 2003. Meaning that your RedHat machine looks pretty old, and semmingly hasn't been kept up-to-date. This might be a possible cause of your current problem. 7 years is a long time in computer history ;)

From the date (2003), I also assume that you have the latest version of RedHat. Which has basically been replaced by Fedora around that time. Consider to upgrade your machine at some point (not necessarily now, assuming we can fix the problem without upgrading, but soon to avoid further issues).
0
 
LVL 2

Author Comment

by:asaeed
ID: 26281508
libclntsh is oracle's own library. yes its old but i am fearing if i put all this on new linux os then the code I have will give more problems cuz that is also an old code.
so i just wanted to install the gcc again or a one-step newer version of gcc so that it doesnt give problem at that system.
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 26281565
>> libclntsh is oracle's own library.

I know. But where did you get it from ?
0
 
LVL 40

Expert Comment

by:evilrix
ID: 26281582
My apologies for interrupting flow...

@asaeed, above I suggested trying this on another Linux box. Is this something you could do? If you don't have another box you could always try using a Live CD or a VMWare/VirtualBox image. This would, to some extent, help take the guess work out of whether it might be an environmental issue or not.

I8 has this well in hand though so my apologies for butting in.

-Rx.
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 26281592
Or put differently : was the Oracle you installed the right version/delivery for your platform ? Was it installed correctly and completely ?
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 26281621
>> @asaeed, above I suggested trying this on another Linux box. Is this something you could do?

Good idea. Have you tried that ? Preferably a more recent system.
0
 
LVL 7

Expert Comment

by:js-profi
ID: 26281813
did you ever make a successful development on that linux? if not there is no reason to not installing a new gcc. next is the make files and libraries from aix. the libraries from aix should not be used. try to get equivalent libs for linux and gcc. the aix compile and link options definitively must be overworked and changed.
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 26281819
That's what we've been trying to establish this whole time ;)
0
 
LVL 7

Expert Comment

by:js-profi
ID: 26283429
evilrix objected in comment no 26198018 (and later ones which were deleted now) when i firstly suggested that.
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 26285773
Suggested what ?

You neither suggested to wait with upgrading to see if we can find a simpler solution by further investigating the problem (like evilrix and me did), nor did you suggest to upgrade to a more recent system (OS and/or compiler) (which is the current back-up solution).

Re-installing gcc (to the same version) like you suggested in the beginning is not likely to solve this problem imo. It looks more and more like a version conflict, which is resolved by matching the versions of the components involved.

My previous comment was not in response to the first part of your post (about installing a new gcc), but rather to the second part of your post (about making sure that the porting from AIX is done correctly) in which you repeat something that we've been working on all this time.

The suggestion that evilrix objected to is still not appropriate imo. It's too early, especially since it's not proven (or likely for that matter) that it will solve the problem.
0
 
LVL 2

Author Comment

by:asaeed
ID: 26290147
1. Oracle library <- installed when i installed and then reinstalled oracle.
2. i am trying in new vmware environment, but i dont have the same version of red hat linux and have installed new version ES 5 (in vmware)  but i fear now the code will give other errors (which i so labourously removed from previous error giving installation).
3. I am trying to get newer (gcc 3.3) version so that compiler should not have much difference from 3.2.3.  
4. if all this doesnt work then i will resolve to oracle 10 g and red had 5 ES and put the code on ES 5. but i am really trying to avoid that. cuz for now my aim is to run the code successfully with current setup, but if it doesnt work, i would have to get back to drawing board.
so i wanted to diagnose the exact problem and target it if possible.
what u suggest.
p.s thank you all for your time
0
 
LVL 2

Author Comment

by:asaeed
ID: 26291417
A little help here i downloaded gcc complir 3.2.3 and ran rpm -i, ./configure , make , make install.
but the gcc and stat.h file showing is old one.  what shlould i do.?
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 26302487
>> 1. Oracle library <- installed when i installed and then reinstalled oracle.

What do you mean by re-installed ? Was it the correct version for your system ?


>> 2. i am trying in new vmware environment

You don't have an actual other (more recent) Linux system available ?


>> A little help here i downloaded gcc complir 3.2.3 and ran rpm -i, ./configure , make , make install.

As I've said several times already : I wouldn't have done that. Now you'll have to clean up and stabilize your system first before you can continue.
0
 
LVL 2

Author Comment

by:asaeed
ID: 26331495
OK. here is the current status.
i installed 3.2.3 again but it didnt work.
i installed 3.4.* and then re-installed oracle and the eror was corrected.  
so it seems that may be the compiler was older or my adventure with stat.h was the actual problem.
thanks all for ur untiring help
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 26331647
That's good news. The risks of working on an old system :)
0
 
LVL 40

Expert Comment

by:evilrix
ID: 26331696
@asaeed, good news.

@ Infinity08 & js-profi, good work chaps.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever run into that annoying problem where the computer won't boot?  Wouldn't it be great if you had a tool that would make that disk boot again?  I have found one tool that works more often than not ...
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
Video by: Tony
This video teaches viewers how to export a project from Adobe Premiere Pro and the various file types involved.
The viewer will learn how to successfully download and install the SARDU utility on Windows 8, without downloading adware.

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question