libtool的一个问题

    libtools生成so的时候,发现在rhel5.3和fedora15下,结果竟然不一样,Makefile.am这样写道:
dydir    = $(bindir)/pwd
dy_PROGRAMS    = libdy.so
libdy_so_SOURCES = dy.cpp dy.h
libdy_so_CXXFLAGS = -fPIC
libdy_so_LDFLAGS = -shared -fpic

在fedora15下,这里面dy.cpp里面必须包括main函数,否则编译不过,而rhel5.3则没有这个问题,查了过程发现fedora15和rhel5.3的编译过程分别如下所示:
fedora15:
/bin/sh ../../../libtool --tag=CXX   --mode=link g++ -fPIC -g -O2 -shared -fpic  -o libdy.so libdy_so-dy.o 
libtool: link: g++ -fPIC -g -O2 -fpic -o libdy.so libdy_so-dy.o
/usr/lib/gcc/i686-redhat-linux/4.6.0/../../../crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status

rhel5.3
/bin/sh ../../../libtool --tag=CXX --mode=link g++  -g -O2   -o libdy.so -shared -fpic libdy_so-dy.o 

g++ -g -O2 -o libdy.so -shared -fpic libdy_so-dy.o
应该是libtool在fedora15上丢失了-shared参数所致,fedora15的libtool版本为2.4,而rhel5.3的libtool版本为1.5.22。

Monthly Archives

Pages

Powered by Movable Type 7.7.2

About this Entry

This page contains a single entry by Cnangel published on August 9, 2011 8:42 PM.

郁闷的SSH was the previous entry in this blog.

新一代 Linux 文件系统 btrfs 简介 is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.