[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Question concerning behavior of GNU-linker on Linux
From: |
Alex Vinokur |
Subject: |
Question concerning behavior of GNU-linker on Linux |
Date: |
Tue, 24 May 2011 04:54:30 -0700 (PDT) |
User-agent: |
G2/1.0 |
Hi,
We came across different behavior of HP-linker on HP-UX and GNU-linker
on Linux.
We have two libraries:
*) libaaa.so and libbbb.so,
*) libbbb.so depends on libaaa.so.
HP-UX linker allows to build exe-file as follows:
aCC <options> main.o libbbb.so
GNU linker on Linux requires the following build of exe-file
icpc <options> main.o libaaa.so libbbb.so
Note.
Command line
icpc <options> main.o libbbb.so
produces error-message.
What is a reason for such behavior og GNU-linker?
Thanks.
Details below.
>>>>>> 1. SOURCE FILES <<<<<<
------ File aaa.h ------
#ifndef AAA_HH
#define AAA_HH
struct AAA
{
AAA();
virtual ~AAA();
};
#endif
------------------------
----- File aaa.cpp -----
#include "./aaa.h"
AAA::AAA()
{
}
AAA::~AAA()
{
}
------------------------
------ File bbb.h ------
#ifndef BBB_HH
#define BBB_HH
#include "./aaa.h"
struct BBB : public AAA
{
BBB();
~BBB();
};
#endif
------------------------
----- File bbb.cpp -----
#include "./bbb.h"
BBB::BBB()
:
AAA()
{
}
BBB::~BBB()
{
}
------------------------
----- File main.cpp ----
#include "./bbb.h"
int main()
{
BBB b;
return 0;
}
------------------------
>>>>>> 2. MAKEFILES <<<<<<
====== Makefile.hp (HP-UX) ======
CC = aCC +DD64 -AA -mt -c -g -I`pwd`
LDLIB = aCC +DD64 -AA -mt -b -g
LDEXE = aCC +DD64 -AA -mt -g
RM = rm -rf
ECHO = echo
all: info clean objs libs exe
info:
@$(ECHO) ====== INFO ======
@$(ECHO) $(CC)
@$(ECHO) $(LDLIB)
@$(ECHO) $(LDLIB)
clean:
@$(ECHO) ====== CLEAN ======
$(RM) ./*.o ./*.so ./*.out
objs:
@$(ECHO) ====== OBJS ======
$(CC) aaa.cpp
$(CC) bbb.cpp
$(CC) main.cpp
libs:
@$(ECHO) ====== LIBS ======
$(LDLIB) -o ./libaaa.so ./aaa.o
$(LDLIB) -o ./libbbb.so ./bbb.o ./libaaa.so
exe:
@$(ECHO) ====== EXE ======
$(LDEXE) -o ./hp1.out ./main.o ./libaaa.so ./libbbb.so
$(LDEXE) -o ./hp2.out ./main.o ./libbbb.so
==================================
------ Makefile.lin (Linux) ------
CC = icpc -c -m64 -fPIC -g
LDLIB = icpc -shared -g
LDEXE = icpc -g
RM = rm -rf
ECHO = echo
all: info clean objs libs exe
info:
@$(ECHO) ====== INFO ======
@$(ECHO) $(CC)
@$(ECHO) $(LDLIB)
@$(ECHO) $(LDLIB)
clean:
@$(ECHO) ====== CLEAN ======
$(RM) ./*.o ./*.so ./*.out
objs:
@$(ECHO) ====== OBJS ======
$(CC) aaa.cpp
$(CC) bbb.cpp
$(CC) main.cpp
libs:
@$(ECHO) ====== LIBS ======
$(LDLIB) -o ./libaaa.so ./aaa.o
$(LDLIB) -o ./libbbb.so ./bbb.o ./libaaa.so
exe:
@$(ECHO) ====== EXE ======
$(LDEXE) -o ./lin1.out ./main.o ./libaaa.so ./libbbb.so
$(LDEXE) -o ./lin2.out ./main.o ./libbbb.so
==================================
>>>>>> 3. COMPILATION <<<<<<
------ Compilation on HP-UX ------
HP-UX B.11.23 U ia64 1139467043 unlimited-user license
aCC: HP C/aC++ B3910B A.06.25.01 [May 16 2010]
92453-07 linker ld HP Itanium(R) B.12.54 IPF/IPF
REL Tue, Dec 8, 2009 01:08:02 PM PST
> make -f Makefile.hp
====== INFO ======
aCC +DD64 -AA -mt -c -g -I/devjuser/jp/ccjp/avinokur/investigation/
002_hp
aCC +DD64 -AA -mt -b -g
aCC +DD64 -AA -mt -b -g
====== CLEAN ======
rm -rf ./*.o ./*.so ./*.out
====== OBJS ======
aCC +DD64 -AA -mt -c -g -I`pwd` aaa.cpp
aCC +DD64 -AA -mt -c -g -I`pwd` bbb.cpp
aCC +DD64 -AA -mt -c -g -I`pwd` main.cpp
====== LIBS ======
aCC +DD64 -AA -mt -b -g -o ./libaaa.so ./aaa.o
aCC +DD64 -AA -mt -b -g -o ./libbbb.so ./bbb.o ./libaaa.so
====== EXE ======
aCC +DD64 -AA -mt -g -o ./hp1.out ./main.o ./libaaa.so ./libbbb.so
aCC +DD64 -AA -mt -g -o ./hp2.out ./main.o ./libbbb.so
----------------------------------
------ Compilation on Linux ------
Linux 2.6.18-238.1.1.el5 #1 SMP Tue Jan 4 13:32:19 EST 2011 x86_64
x86_64 x86_64 GNU/Linux
Intel(R) C++ Intel(R) 64 Compiler XE for applications running on
Intel(R) 64, Version 12.0.0.084 Build 20101006
Copyright (C) 1985-2010 Intel Corporation. All rights reserved.
GNU ld version 2.17.50.0.6-14.el5 20061020
> make -f Makefile.lin
====== INFO ======
icpc -c -m64 -fPIC -g
icpc -shared -g
icpc -shared -g
====== CLEAN ======
rm -rf ./*.o ./*.so ./*.out
====== OBJS ======
icpc -c -m64 -fPIC -g aaa.cpp
icpc -c -m64 -fPIC -g bbb.cpp
icpc -c -m64 -fPIC -g main.cpp
====== LIBS ======
icpc -shared -g -o ./libaaa.so ./aaa.o
icpc -shared -g -o ./libbbb.so ./bbb.o ./libaaa.so
====== EXE ======
icpc -g -o ./lin1.out ./main.o ./libaaa.so ./libbbb.so
/opt/intel/compiler/lib/intel64/libimf.so: warning: warning:
feupdateenv is not implemented and will always fail
icpc -g -o ./lin2.out ./main.o ./libbbb.so
ld: warning: ./libaaa.so, needed by ./libbbb.so, not found (try using -
rpath or -rpath-link)
/opt/intel/compiler/lib/intel64/libimf.so: warning: warning:
feupdateenv is not implemented and will always fail
./libbbb.so: undefined reference to `typeinfo for AAA'
./libbbb.so: undefined reference to `AAA::~AAA()'
./libbbb.so: undefined reference to `AAA::AAA()'
make: *** [exe] Error 1
----------------------------------
- Question concerning behavior of GNU-linker on Linux,
Alex Vinokur <=