Operating System - HP-UX
1748205 Members
4640 Online
108759 Solutions
New Discussion юеВ

Errors while compiling code through gcc

 
aarvee
Occasional Advisor

Errors while compiling code through gcc

Hello,
I am getting strange errors while compiling my code through GCC. Earlier it was showing "ld: Can't find library or mismatched ABI for -lutil" After compiling the libraries source this error was sorted out. Then it was not able to link the header files while compiling because of which it was showing errors and warning almost on each and every line.

I guess I am goofing up with the make file. Can any one of you please help me in correcting my makefile. Below are the contents I guess are used for my system.
This is an Itanium box OS v11.23.

======makefile.pre===========
ifeq (${PLATFORM}, HP-UX)
CC = /usr/local/bin/gcc
MAKEDEPEND = ${GENEVA_HOME}/Interface/makedepend
ARCH_FLAG = # Flag indicating chip architecture.
#ARCH_FLAG = -m -DSS_64BIT_SERVER # Flag indicating chip architecture.
#ARCH_FLAG = +DA2.0W +DS2.0 +DA2.0W +DS2.0 -DSS_64BIT_SERVER # Flag indicating chip architecture.
USE_SHLIB_PATH = -Wl,+s # Force use of SHLIB_PATH at run-time
#CPPFLAGS += -D_HPUX_SOURCE -DHPUX -march=2.0 -march=2.0 -DSS_64BIT_SERVER # C preprocessor flags
CPPFLAGS += -DSS_64BIT_SERVER # C preprocessor flags
#CPPFLAGS += -D_HPUX_SOURCE -DHPUX +DD64 +DS2.0 +DD64 +DS2.0 -DSS_64BIT_SERVER # C preprocessor flags
DONT_MAP_ADDRZERO = -z

CFLAGS = ${COPT} ${CPPFLAGS} ${DONT_MAP_ADDRZERO} ${ARCH_FLAG} ${USE_SHLIB_PATH}
LIB_EXTRA_LIBS =
# Shared Library stuff below here
SHLIB_ARCH_FLAG = +DD64 +DS2.0 +DD64 +DS2.0 -DSS_64BIT_SERVER # Flag indicating chip architecture.
SHLIB_CFLAGS = ${COPT} ${CPPFLAGS} ${DONT_MAP_ADDRZERO} ${SHLIB_ARCH_FLAG}
SHLIB_LDFLAGS = -b
export SHLIB_SUFFIX = sl
SHLIB_VERS_SUFFIX = ${library.version}
SHLIB_LIB = dl
SHLIB_EXTRA_LIBS =
SHLIB_MODE = 755
SMALLPICFLAGS=+z
BIGPICFLAGS=+Z
# Dynamic Library stuff below here (called from Geneva direct)
DYNLIB_ARCH_FLAG = +DD64
DYNLIB_CFLAGS = ${COPT} ${CPPFLAGS} ${DONT_MAP_ADDRZERO} ${DYNLIB_ARCH_FLAG}
endif
========makefile.pre End============


===========makefile.post============
.SUFFIXES:
.SUFFIXES: .sh .awk .pl .a .sl .so .o .opic .c .y .l .s .h .H \
.I .i .f .C .Y .L .lc .dat .dbl .bin .cfg .pc \
.sqc .sqh .sql .dot

.c:
$(CC) -ansi $(CFLAGS) -o $@ $< $(LIBS)

.c.o:
$(CC) -c -ansi $(CFLAGS) ${C_INCLUDE_PATH} -o $@ $< ${LIB_EXTRA_LIBS}


.c.opic:
$(CC) $(SMALLPICFLAGS) -c $(INC_FLAGS) $(LIB_CFLAGS) $< -o $@

.pc.c:
@ echo precompiling $<
${PROC} ${PROCFLAGS} ${ORA_INC_PATH} oname=$(*F).c $<
=========End makefile.post===========

Please help me out. The same code is getting compiled on PA-RISC box without any issues.

FYI, Currently I am again getting error "ld: Can't find library or mismatched ABI for -lutil" and when compiling the library source I guess it is not able to link the header sys/unistd.h.
Please Help me get out of this problems.
18 REPLIES 18
Dennis Handly
Acclaimed Contributor

Re: Errors while compiling code through gcc

Where's your errors?

>export SHLIB_SUFFIX = sl

On Integrity, this should be "so".

>"ld: Can't find library or mismatched ABI for -lutil"

Where is libutil? What does file(1) show for that lib?

>it is not able to link the header sys/unistd.h.

You don't "link" headers, you include them.
aarvee
Occasional Advisor

Re: Errors while compiling code through gcc

Hi Dennis

>>Where's your errors?
I did not get this question. I am getting the errors when compiling the code. These doesnt seems to be any syntactic or symantic error. These are definitely because of makefile. Since the same code is working fine on PA-RISC box. The changes on the new box are its an Itanium box and instead of ANSI C we are using GCC. So need to change the makefile according to these changes. This is where I am struggling. Need your help in this.

>export SHLIB_SUFFIX = sl
>>On Integrity, this should be "so".
Changed the SHLIB_SUFFIX to "so" now it is giving error:
ld: Unrecognized argument: -Wl,+s
Fatal error.
collect2: ld returned 1 exit status

USE_SHLIB_PATH is set to "-Wl,+s".

>>"ld: Can't find library or mismatched ABI for -lutil"
>Where is libutil? What does file(1) show for that lib?
libutil is in custom directory, the custom directory is in the path.

>>it is not able to link the header sys/unistd.h.
>You don't "link" headers, you include them.
oops slip of tongue. I meant "include" only.

But I am unable to understand even though header files were in the same path as the .c files and .pc files why it was giving errors for the macros that were defined in the header files.
Dennis Handly
Acclaimed Contributor

Re: Errors while compiling code through gcc

>>Where's your errors?
>I did not get this question.

It's called cut & paste.

>These doesn't seems to be any syntactic or semantic error.

Then what are they?

>we are using GCC. So need to change the makefile according to these changes.

Where are your errors to show the problem?

>Changed the SHLIB_SUFFIX to "so" now it is giving error:

Not sure why, it should be cosmetic.
You should be defining LD as /usr/local/bin/gcc

>libutil is in custom directory, the custom directory is in the path.

One of your -L paths? what does file(1) show for libutil?

How are you including them? If you use "#include " they have to be in a -I path.
aarvee
Occasional Advisor

Re: Errors while compiling code through gcc

>>These doesn't seems to be any syntactic or semantic error.
>Then what are they?
These are related to the libraries or the errors in the makefile.

>>we are using GCC. So need to change the makefile according to these changes.
>Where are your errors to show the problem?
Below are the compiler message.
-----------------------------------------
/usr/local/bin/gcc -O -DSS_64BIT_SERVER -z -Wl,+s -o doc1bpp_soe transform_funcs.o transform_funcs_soe.o transform_funcs_edifact.o doc1bpp.o input_funcs.o output_funcs.o -L/bbsbtest/data/phdev1/Interface/lib/HP-UX -L/bbsbtest/data/phdev1/Interface/releases/delivery/lib/btgs1 -lutil -lprocutil `cat /dboracle/orabase/product/10.2.0.4/lib/sysliblist` -L/dboracle/orabase/product/10.2.0.4/precomp/lib -L/dboracle/orabase/product/10.2.0.4/lib -lclntsh `cat /dboracle/orabase/product/10.2.0.4/lib/sysliblist` -lm -lpthread -lpthread -L/lib
ld: Unrecognized argument: -Wl,+s
Fatal error.
collect2: ld returned 1 exit status
make[1]: *** [doc1bpp_soe] Error 1
make[1]: Leaving directory `/bbsbtest/data/phdev1/Interface/rakeshv/4-0-14-7/bin/HP-UX'
make: *** [exe] Error 2
-------------------------------------------

>Changed the SHLIB_SUFFIX to "so" now it is giving error:

Not sure why, it should be cosmetic.
You should be defining LD as /usr/local/bin/gcc

>>libutil is in custom directory, the custom directory is in the path.

>One of your -L paths? what does file(1) show for libutil?
libutil.a: archive file

>How are you including them? If you use "#include " they have to be in a -I path.
Header files are in a -I path.
Dennis Handly
Acclaimed Contributor

Re: Errors while compiling code through gcc

>Below are the compiler message.
>ld: Unrecognized argument: -Wl,+s

This is a linker error.
The first "-Wl,+s" should be fine, since it is sent to the driver. That leaves this file:
/dboracle/orabase/product/10.2.0.4/lib/sysliblist

Or possibly the variable LDOPTS.

>libutil.a: archive file

How did you create this file? Did you use HP's ar(1) or a foreign devil one?

>Header files are in a -I path.

You can look at the -E output to see which header is used.
aarvee
Occasional Advisor

Re: Errors while compiling code through gcc

>>ld: Unrecognized argument: -Wl,+s
>This is a linker error.
The first "-Wl,+s" should be fine, since it is sent to the driver. That leaves this file:
/dboracle/orabase/product/10.2.0.4/lib/sysliblist Or possibly the variable LDOPTS.

So what is the solution to this problem. If need be you can look at the makefile settings in my original posting.

>>libutil.a: archive file
>How did you create this file? Did you use HP's ar(1) or a foreign devil one?
HP's ar is used to create the file.

>>Header files are in a -I path.
>You can look at the -E output to see which header is used.

Right now I am not getting this error. If we can solve the Wl,+s problem I guess this will also get solved.
Dennis Handly
Acclaimed Contributor

Re: Errors while compiling code through gcc

>/dboracle/orabase/product/10.2.0.4/lib/sysliblist >Or possibly the variable LDOPTS.

>So what is the solution to this problem?

As I asked, is LDOPTS set? What is in sysliblist?

You may have to use tusc to trace what gcc is doing.

Also, you should remove +DS2.0, this is PA only.
Andre-Marcel Hellmund
Frequent Advisor

Re: Errors while compiling code through gcc

Hey,

>ld: Unrecognized argument: -Wl,+s
> Fatal error.
> collect2: ld returned 1 exit status
> make[1]: *** [doc1bpp_soe] Error 1

collect2 is a utility used by gcc to link programs, it finally calls the GNU ld (http://gcc.gnu.org/onlinedocs/gccint/Collect2.html).

You could also use the -v gcc option to check which options are finally passed to the collect2 executable. The strange thing is that gcc apparently passes the complete -Wl,+s to the linker without dropping the leading -Wl.

By the way, the GNU linker does not support the +s option. This must be HP linker only. For a list of GNU linker options, http://sourceware.org/binutils/docs-2.19/ld/Options.html#Options

Which version of GCC and BINUTILS are you using (gcc --version & ld --version)?

Best regards,
Andi
aarvee
Occasional Advisor

Re: Errors while compiling code through gcc

Dennis
>As I asked, is LDOPTS set? What is in sysliblist?
LDOPTS is not set.
sysliblist contains
-l:librt.so -l:libnss_dns.so.1 -l:libdld.so -lm -lpthread -lunwind -lnsl

>you should remove +DS2.0, this is PA only
My "ARCH_FLAG" reads "ARCH_FLAG = ", I have also removed DS2.0 from other flags as well.

Andy
>Which version of GCC and BINUTILS are you using (gcc --version & ld --version)?
I am using gcc-4.2.3 and ld_ia. How do I find which BINUTILS is it.

I am sorry I am novice in creating Makefiles.