libtool
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

portland compiler, convenience libraries and templates


From: Markus Christen
Subject: portland compiler, convenience libraries and templates
Date: Thu, 02 Dec 2004 18:11:13 +0100
User-agent: Mozilla Thunderbird 0.8 (X11/20040917)


hi

first of all: thanks for libtool, it helped a lot in adding flexibility to the compilation of my project!


problem:
linking a program to a library (shared or static) built from a convenience library fails if the convenience library contains template functions : unresolved reference.

thanks for supporting the portland group c++ compiler:
http://lists.gnu.org/archive/html/libtool/2004-11/msg00470.html

ltmain.sh (GNU libtool 1.1771 2004/11/30 20:46:21) 2.1a
autoconf (GNU Autoconf) 2.59
automake (GNU automake) 1.9.1

pgCC 5.2-2

full desctiption:

Makefile.am:
noinst_LTLIBRARIES = libaclib.la

libaclib_la_SOURCES = aclib.cc

lib_LTLIBRARIES = libalib.la

include_HEADERS = alib.h
libalib_la_SOURCES = alib.cc

libalib_la_LIBADD = libaclib.la

bin_PROGRAMS = prog

prog_SOURCES = prog.cc

LDADD = libalib.la
---

"normal" library alib:
alib.h:
int f(int);
---

alib.cc:
#include "alib.h"

template<typename T>
T q(T b){
               return b * 2;
}

int f(int i){
               return q(i);
}
---

"convenience" library aclib:
aclib.h:
int cf(int);
---

aclib.cc:
#include "aclib.h"
template<typename T>
T cq(T b){
               return b * 3;
}

int cf(int i){
               // return cq(i);
               return 3 * i;
}
---

and an example program:
prog.cc:
#include <iostream>
#include "alib.h"
#include "aclib.h"

using namespace std;

int main(){
               cout << "a sample prog" << endl;
               cout << "f(3) = " << f(3) << endl;
               cout << "cf(3) = " << cf(3) << endl;
               return 0;
}
===

CC=pgcc
CXX=pgCC

if i make like this, everything works.
(even though nm shows the templated function in the library as unresolved:
nm libalib.a

alib.o:
        U __pgdbg_stub
00000010 T f__Fi
00000000 t pgCC_compiled.
        U q__tm__2_i__FZ1Z_Z1Z

aclib.o:
        U _GLOBAL_OFFSET_TABLE_
        U __pgdbg_stub
00000010 T cf__Fi
00000000 t pgCC_compiled.

===

if i use the template call in the convenience library (aclib.cc), i get unresolved symbols: libtool: link: pgCC -g -o .libs/prog prog.o ./.libs/libalib.so -lm -Wl,--rpath -Wl,/home/markus/temp/pg/lib
./.libs/libalib.so: undefined reference to `cq__tm__2_i__FZ1Z_Z1Z'

and if i check:
nm libaclib.a

aclib.o:
00000010 T cf__Fi
        U cq__tm__2_i__FZ1Z_Z1Z
        U _GLOBAL_OFFSET_TABLE_
00000000 t pgCC_compiled.
        U __pgdbg_stub

so, it's the same as in the "normal" library, but here the symbol stays unresolved in the final linkage...


i obviously do not understand enough how pgCC instantiates templates, but it is working with the normal library and not with the convenience library.
anybody any clue?

thanks a lot,
markus


PS: sorry for the long mail...
PPS: of course it works with g++, then the symbol is defined as weak:

nm libaclib.a

aclib.o:
        U _GLOBAL_OFFSET_TABLE_
00000000 T _Z2cfi
00000000 W _Z2cqIiET_S0_

=========================================================
and maybe the full output:

./configure && make
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking for gcc... pgcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... no
checking whether pgcc accepts -g... yes
checking for pgcc option to accept ANSI C... none needed
checking dependency style of pgcc... none
checking for a sed that does not truncate output... /bin/sed
checking for egrep... grep -E
checking for fgrep... grep -F
checking for non-GNU ld... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD-compatible nm... /usr/bin/nm -B
checking whether ln -s works... yes
checking the maximum length of command line arguments... 32768
checking for /usr/bin/ld option to reload object files... -r
checking how to recognise dependent libraries... pass_all
checking for ar... ar
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from  object... ok
checking whether we are using the GNU C++ compiler... no
checking whether pgCC accepts -g... yes
checking dependency style of pgCC... none
checking how to run the C++ preprocessor... pgCC -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking whether we are using the GNU C++ compiler... (cached) no
checking whether pgCC accepts -g... (cached) yes
checking dependency style of pgCC... (cached) none
checking how to run the C++ preprocessor... pgCC -E
checking for objdir... .libs
checking for pgcc option to produce PIC... -fpic -DPIC
checking if pgcc PIC flag -fpic -DPIC works... yes
checking if pgcc static flag -static works... no
checking if pgcc supports -c -o file.o... yes
checking if pgcc supports -c -o file.o... (cached) yes
checking whether the pgcc linker (/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking whether the pgCC linker (/usr/bin/ld) supports shared libraries... yes
checking for pgCC option to produce PIC... -fpic -DPIC
checking if pgCC PIC flag -fpic -DPIC works... yes
checking if pgCC static flag -static works... no
checking if pgCC supports -c -o file.o... yes
checking if pgCC supports -c -o file.o... (cached) yes
checking whether the pgCC linker (/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking whether we are using the GNU C++ compiler... (cached) no
checking whether pgCC accepts -g... (cached) yes
checking dependency style of pgCC... (cached) none
checking whether make sets $(MAKE)... (cached) yes
checking for ANSI C header files... (cached) yes
checking for an ANSI C-conforming const... yes
checking for inline... inline
checking for size_t... yes
checking for sqrt in -lm... yes
checking whether the compiler supports the STL... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands

Total time                              : 0:16.70s
CPU utilisation (percentage)            : 53.7%
make  all-am
make[1]: Entering directory `/home/markus/temp/pg'
source='alib.cc' object='alib.lo' libtool=yes \
DEPDIR=.deps depmode=none /bin/sh ./config/depcomp \
/bin/sh ./libtool --tag=CXX --mode=compile pgCC -DHAVE_CONFIG_H -I. -I. -I. -g -c -o alib.lo alib.cc libtool: compile: pgCC -DHAVE_CONFIG_H -I. -I. -I. -g -c alib.cc -fpic -DPIC -o .libs/alib.o libtool: compile: pgCC -DHAVE_CONFIG_H -I. -I. -I. -g -c alib.cc -o alib.o >/dev/null 2>&1
source='aclib.cc' object='aclib.lo' libtool=yes \
DEPDIR=.deps depmode=none /bin/sh ./config/depcomp \
/bin/sh ./libtool --tag=CXX --mode=compile pgCC -DHAVE_CONFIG_H -I. -I. -I. -g -c -o aclib.lo aclib.cc libtool: compile: pgCC -DHAVE_CONFIG_H -I. -I. -I. -g -c aclib.cc -fpic -DPIC -o .libs/aclib.o libtool: compile: pgCC -DHAVE_CONFIG_H -I. -I. -I. -g -c aclib.cc -o aclib.o >/dev/null 2>&1 /bin/sh ./libtool --tag=CXX --mode=link pgCC -g -o libaclib.la aclib.lo -lm
libtool: link: ar cru .libs/libaclib.a .libs/aclib.o
libtool: link: ranlib .libs/libaclib.a
libtool: link: creating libaclib.la
libtool: link: ( cd ".libs" && rm -f "libaclib.la" && ln -s "../libaclib.la" "libaclib.la" ) /bin/sh ./libtool --tag=CXX --mode=link pgCC -g -o libalib.la -rpath /home/markus/temp/pg/lib alib.lo libaclib.la -lm libtool: link: (cd .libs/libalib.lax/libaclib.a && ar x /home/markus/temp/pg/./.libs/libaclib.a) libtool: link: pgCC -shared .libs/alib.o .libs/libalib.lax/libaclib.a/aclib.o -lm -Wl,-soname -Wl,libalib.so.0 -o .libs/libalib.so.0.0.0 C++ prelinker: executing: /usr/pgi/linux86/5.2/bin/pgCC -DHAVE_CONFIG_H -I. -I. -I. -g -fpic -DPIC -o .libs/alib.o -c alib.cc libtool: link: (cd ".libs" && rm -f "libalib.so.0" && ln -s "libalib.so.0.0.0" "libalib.so.0") libtool: link: (cd ".libs" && rm -f "libalib.so" && ln -s "libalib.so.0.0.0" "libalib.so") libtool: link: (cd .libs/libalib.lax/libaclib.a && ar x /home/markus/temp/pg/./.libs/libaclib.a) libtool: link: ar cru .libs/libalib.a alib.o .libs/libalib.lax/libaclib.a/aclib.o
libtool: link: ranlib .libs/libalib.a
libtool: link: rm -fr .libs/libalib.lax .libs/libalib.lax
libtool: link: creating libalib.la
libtool: link: ( cd ".libs" && rm -f "libalib.la" && ln -s "../libalib.la" "libalib.la" )
source='prog.cc' object='prog.o' libtool=no \
DEPDIR=.deps depmode=none /bin/sh ./config/depcomp \
pgCC -DHAVE_CONFIG_H -I. -I. -I.     -g -c -o prog.o prog.cc
/bin/sh ./libtool --tag=CXX --mode=link pgCC -g -o prog prog.o libalib.la -lm libtool: link: pgCC -g -o .libs/prog prog.o ./.libs/libalib.so -lm -Wl,--rpath -Wl,/home/markus/temp/pg/lib
./.libs/libalib.so: undefined reference to `cq__tm__2_i__FZ1Z_Z1Z'
make[1]: *** [prog] Error 2
make[1]: Leaving directory `/home/markus/temp/pg'
make: *** [all] Error 2
Exit 2

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]