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。

Archives

Pages

Powered by Movable Type 7.0.4

April 2019

Sun Mon Tue Wed Thu Fri Sat
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30        

Recent Assets

  • oppo 350.jpg
  • oppo 357.jpg
  • oppo 353.jpg
  • oppo 345.jpg
  • oppo 343.jpg
  • oppo 342.jpg
  • oppo 340.jpg
  • QQ图片20181209001102.png
  • oppo 336.jpg
  • oppo 334.jpg
Creative Commons License
This blog is licensed under a Creative Commons License.

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.