Link to home
Start Free TrialLog in
Avatar of asaeed
asaeed

asked on

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

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 .
Avatar of evilrix
evilrix
Flag of United Kingdom of Great Britain and Northern Ireland image

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

Avatar of asaeed
asaeed

ASKER

OK  above mentioned code works, it means it doesnt have to do anything with my code ? but mine does not work
Avatar of asaeed

ASKER

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)
Thanks looks fine. And what ldd output do you get for your real program?
Avatar of asaeed

ASKER

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)
Avatar of asaeed

ASKER

for info -> i used this code on IBM AIX but now ported it to linux
You might have to leave out  -D__IBM__ (and possibly replace it with a Linux equivalent).
Check for any other IBM AIX specific issues in your makefile, and port them to Linux too.
Avatar of asaeed

ASKER

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;
}  
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)?
mean to remember you used fstat as a variable. it is a function declared in stat.h and must not used as variable.
Avatar of asaeed

ASKER

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.  
SOLUTION
Avatar of js-profi
js-profi

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
better from a download that fits to the system runtimes.
stat.h comes with the system - don't use a custom one - use the one provided by the system.
Avatar of asaeed

ASKER

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 ??
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.
Avatar of asaeed

ASKER

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
undefined symbol means the fstat wasn't linked to the executable.
Avatar of asaeed

ASKER

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
you need to remove the -D__IBM__  what already was said.
Avatar of asaeed

ASKER

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?
>> 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).
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>> best you uninstall compiler and reinstall again.
I doubt that's necessary since a simple test program compiles and runs just fine.
Avatar of asaeed

ASKER

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
>> 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).
Avatar of asaeed

ASKER

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

Avatar of asaeed

ASKER

other exes are in same makefile and they dont give fstat error
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 ?
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.
Avatar of asaeed

ASKER

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
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.
Avatar of asaeed

ASKER

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
>> 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.
>> 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 ;)
Avatar of asaeed

ASKER

yes i think so too. seems somthing is fishy in compiling or linking.
>> 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 :)
Avatar of asaeed

ASKER

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.
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.

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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)
Avatar of asaeed

ASKER

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
try to call stat function instead of fstat. no solution but only workaround.
Avatar of asaeed

ASKER

yes i have already tried stat it doesnt work too.
is then 'stat' missing at runtime? if still fstat was missing you linked against a dynamic library which was not newly built.
Avatar of asaeed

ASKER

yes stat gives same error.
if still fstat was missing you linked against a dynamic library which was not newly built.  <- means ?
Avatar of asaeed

ASKER

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.?
yes for any change of a header - special system header - you should have a 'make clean' and build *all* your executables and libraries.
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.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of asaeed

ASKER

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 :)
>> when i ran it with make command "make executable"

The 'make executable' contains a lot more code than your simple test application ;)
Avatar of asaeed

ASKER

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
>> 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.
Avatar of asaeed

ASKER

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?
Avatar of asaeed

ASKER

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?
Avatar of asaeed

ASKER

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.
>> 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).
Avatar of asaeed

ASKER

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.
>> libclntsh is oracle's own library.

I know. But where did you get it from ?
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.
Or put differently : was the Oracle you installed the right version/delivery for your platform ? Was it installed correctly and completely ?
>> @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.
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.
That's what we've been trying to establish this whole time ;)
evilrix objected in comment no 26198018 (and later ones which were deleted now) when i firstly suggested that.
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.
Avatar of asaeed

ASKER

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
Avatar of asaeed

ASKER

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.?
>> 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.
Avatar of asaeed

ASKER

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
That's good news. The risks of working on an old system :)
@asaeed, good news.

@ Infinity08 & js-profi, good work chaps.