Operating System - HP-UX
1823422 Members
2434 Online
109655 Solutions
New Discussion юеВ

Re: 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.
Andre-Marcel Hellmund
Frequent Advisor

Re: Errors while compiling code through gcc

Hey,

I do not think it is a BINUTILS issue as gcc as compile driver is passing the command line options to the linker. But nevertheless, you get the BINUTILS version corresponding to your linker by executing:

$ ld --version
GNU ld (GNU Binutils for Ubuntu) 2.18

Currently, I do not know why gcc does not pass the +s to the linker (you could debug a little bit with -v to gcc), but it is meaningless however, as +s does not exist as a valid option.

As a possible way to get it working (as I do not know if the GNU linker has a similar flag as the HP linker +s option), you could build your application without -Wl,+s. Then you could check with chatr(1) where the dynamic linker searches for dynamic libraries:

$ chatr
test:
64-bit ELF executable
shared library dynamic path search:
LD_LIBRARY_PATH enabled first
SHLIB_PATH enabled second
embedded path enabled third [...]

If LD_LIBRARY_PATH and SHLIB_PATH are disabled by default, you could enable them by doing:

$ chatr +s enable

Hope that helps ...

Andi

Andre-Marcel Hellmund
Frequent Advisor

Re: Errors while compiling code through gcc

Hey,

okay, I was probably a little bit wrong and/or a little bit too fast :)

That's the result if you just check on x86 (and not Itanium) and do not read the manual carefully. Collect2 does NOT call the GNU linker, but the native linker which is in this case (I assume) the HP linker. So, the +s option is valid, of course ...

This is how collect2 determines which linker to call:

"The program collect2 is installed as ld in the directory where the passes of the compiler are installed. When collect2 needs to find the real ld, it tries the following file names:

- a hard coded linker file name, if GCC was configured with the --with-ld option.
- real-ld in the directories listed in the compiler's search directories.
- real-ld in the directories listed in the environment variable PATH.
- The file specified in the REAL_LD_FILE_NAME configuration macro, if specified.
- ld in the compiler's search directories, except that collect2 will not execute itself recursively.
- ld in PATH."

Sorry for that :D

Nevertheless, try to compile without this -Wl,+s and could you probably post the output of your gcc call plus the -v option added. I guess there could be probably a configuration problem.

aarvee
Occasional Advisor

Re: Errors while compiling code through gcc

>you could build your application without -Wl,+s.

I tried that way too. but it gives whole lot of errors. It does not recognise the macros defined in the header file. Basically it does not include the header files while compiling.
Dennis Handly
Acclaimed Contributor

Re: Errors while compiling code through gcc

>>you could build your application without -Wl,+s.

>I tried that way too. but it gives whole lot of errors. It does not recognise the macros defined in the header file. Basically it does not include the header files while compiling.

There should be no connection between -Wl,+s and header includes.

Why don't you throw your makefile away and try compiling a simple C hello world program and pass in -Wl,+s with -v and show us the output.
aarvee
Occasional Advisor

Re: Errors while compiling code through gcc

The output is:
gcc: ../hellomake.c: No such file or directory
Using built-in specs.
Target: ia64-hp-hpux11.23
Configured with: ../gcc/configure
Thread model: posix
gcc version 4.2.3
gcc: ../hellofunc.c: No such file or directory
Using built-in specs.
Target: ia64-hp-hpux11.23
Configured with: ../gcc/configure
Thread model: posix
gcc version 4.2.3
gcc: hellomake.o: No such file or directory
gcc: hellofunc.o: No such file or directory
Using built-in specs.
Target: ia64-hp-hpux11.23
Configured with: ../gcc/configure
Thread model: posix
gcc version 4.2.3
[phdev1]/bbsbtest/data/phdev1/Interface/rakeshv/4-0-8-10/bin/test $ mv a HP-UX/
[phdev1]/bbsbtest/data/phdev1/Interface/rakeshv/4-0-8-10/bin/test $ cd HP-UX/
[phdev1]/bbsbtest/data/phdev1/Interface/rakeshv/4-0-8-10/bin/test/HP-UX $ a
Using built-in specs.
Target: ia64-hp-hpux11.23
Configured with: ../gcc/configure
Thread model: posix
gcc version 4.2.3
/usr/local/libexec/gcc/ia64-hp-hpux11.23/4.2.3/cc1 -quiet -v -I../ -I/bbsbtest/data/phdev1/Interface/include -I/bbsbtest/data/phdev1/Interface/delivery/include/btgs1:/usr/include -I/dboracle/orabase/product/10.2.0.4/precomp/public -D_HPUX_SOURCE -DHPUX -DSS_64BIT_SERVER ../hellomake.c -quiet -dumpbase hellomake.c -ansi -auxbase-strip hellomake.o -O -ansi -version -o /var/tmp//ccp2VXCm.s
ignoring nonexistent directory "NONE/include"
ignoring nonexistent directory "/usr/local/lib/gcc/ia64-hp-hpux11.23/4.2.3/../../../../ia64-hp-hpux11.23/include"
ignoring nonexistent directory "/bbsbtest/data/phdev1/Interface/delivery/include/btgs1:/usr/include"
#include "..." search starts here:
#include <...> search starts here:
[phdev1]/bbsbtest/data/phdev1/Interface/rakeshv/4-0-8-10/bin/test/HP-UX $ a
Using built-in specs.
Target: ia64-hp-hpux11.23
Configured with: ../gcc/configure
Thread model: posix
gcc version 4.2.3
/usr/local/libexec/gcc/ia64-hp-hpux11.23/4.2.3/cc1 -quiet -v -I../ -I/bbsbtest/data/phdev1/Interface/include -I/bbsbtest/data/phdev1/Interface/delivery/include/btgs1:/usr/include -I/dboracle/orabase/product/10.2.0.4/precomp/public -D_HPUX_SOURCE -DHPUX -DSS_64BIT_SERVER ../hellomake.c -quiet -dumpbase hellomake.c -ansi -auxbase-strip hellomake.o -O -ansi -version -o /var/tmp//ccx5RRJj.s
ignoring nonexistent directory "NONE/include"
ignoring nonexistent directory "/usr/local/lib/gcc/ia64-hp-hpux11.23/4.2.3/../../../../ia64-hp-hpux11.23/include"
ignoring nonexistent directory "/bbsbtest/data/phdev1/Interface/delivery/include/btgs1:/usr/include"
#include "..." search starts here:
#include <...> search starts here:
../
/bbsbtest/data/phdev1/Interface/include
/dboracle/orabase/product/10.2.0.4/precomp/public
/usr/local/include
/usr/local/lib/gcc/ia64-hp-hpux11.23/4.2.3/include
/usr/include
End of search list.
GNU C version 4.2.3 (ia64-hp-hpux11.23)
compiled by GNU C version 4.2.3.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: a60fba7fb6c876ab3d8a00a8d3192d93
/usr/local/bin/as -x -o hellofunc.o /var/tmp//cc2ZZNer.s
Using built-in specs.
Target: ia64-hp-hpux11.23
Configured with: ../gcc/configure
Thread model: posix
gcc version 4.2.3
/usr/local/libexec/gcc/ia64-hp-hpux11.23/4.2.3/collect2 -z +Accept TypeMismatch -u main -o hellomake -z -Wl,+s /usr/lib/hpux32/unix98.o -L/bbsbtest/data/phdev1/Interface/lib/HP-UX -L/bbsbtest/data/phdev1/Interface/releases/delivery/lib/btgs1 -L/usr/local/lib/gcc/ia64-hp-hpux11.23/4.2.3 -L/usr/ccs/lib -L/usr/local/lib/gcc/ia64-hp-hpux11.23/4.2.3/../../.. hellomake.o hellofunc.o -lutil -lprocutil -l:librt.so -l:libnss_dns.so.1 -l:libdld.so -lm -lpthread -lunwind -lnsl -lgcc -lc -lgcc
ld: Unrecognized argument: -Wl,+s
Fatal error.
collect2: ld returned 1 exit status
Dennis Handly
Acclaimed Contributor

Re: Errors while compiling code through gcc

>The output is:
/usr/local/libexec/gcc/ia64-hp-hpux11.23/4.2.3/collect2 -z +Accept TypeMismatch -u main -o hellomake -z -Wl,+s ...
ld: Unrecognized argument: -Wl,+s

What's in the script "a"? Besides gcc hellofunc.c?

This shows collect and ld getting -Wl,+s directly.

If you can't show where -Wl,+s comes, you are going to have to use the tusc hammer:
tusc -fp -ae -o tusc.out gcc hellofunc.c
Andre-Marcel Hellmund
Frequent Advisor

Re: Errors while compiling code through gcc

Hey,

your output is a little bit confusing because you apparently pasted the output of two different compilation runs: hellomake.c and hellofunc.c :)

For me it seems that there is a kind of configuration problem, although I do not know which one :) Where did you get the gcc exectuable from? Did you compile them yourself or did you download them from the HP-UX porting archive.

I made some tests on 11.31 and 11.23 with the executables and files from the HP-UX porting archive (http://hpux.connect.org.uk) and I had no problems with the -Wl,+s.

So, my suggestion would be to download the following three files for 11.23:

http://hpux.connect.org.uk/hppd/hpux/Development/Libraries/libiconv-1.13/
http://hpux.connect.org.uk/hppd/hpux/Gnu/gettext-0.17/
http://hpux.connect.org.uk/hppd/hpux/Gnu/gcc-4.2.3/

The files should be installed in the default directory (/usr/local) ... otherwise you would get some "library not found" errors when running gcc/as.


Steven Schweda
Honored Contributor

Re: Errors while compiling code through gcc

> [...] I had no problems with the -Wl,+s.

Knowing nothing, I'd guess that "ld" would
be happy with "+s", and that the compiler
(compiler driver) would turn "-Wl,+s" on its
command line into "+s" on its "ld" command
line, but I might expect a problem if someone
found a way to get "-Wl,+s" onto the "ld"
command line itself, which is what
ld: Unrecognized argument: -Wl,+s
looks like to me.
Andre-Marcel Hellmund
Frequent Advisor

Re: Errors while compiling code through gcc

Hey Steven,

yes, you are right. But the compiler driver (gcc) apparently did not drop the "-Wl," before calling collect2 (which then calls ld).

>aarvee: collect2 -z +Accept TypeMismatch -u main -o hellomake -z -Wl,+s [...]

If I do a test compile "gcc [..] -Wl,+s", collect2 is called with +s only.