当前位置: 技术问答>linux和unix
Solaris 生成共享库的问题
来源: 互联网 发布时间:2015-12-20
本文导语: 从开源项目中抽取makefile中的部分,即如下makefile文件执行后可以 生成一个可执行文件myplayer。现在想将此可执行文件以动态链接库的 形式提供,于是将myplayr.cpp中的main函数改成startmain,用来接收 相应的参数。同时修...
从开源项目中抽取makefile中的部分,即如下makefile文件执行后可以
生成一个可执行文件myplayer。现在想将此可执行文件以动态链接库的
形式提供,于是将myplayr.cpp中的main函数改成startmain,用来接收
相应的参数。同时修改makefile生成动态链接库文件(.so)。但试了很
多次都不行。我的是在Solaris 9上编译。敬请高人指点,在生成动态库
时的makefile相关项应该怎么写才好?
由于长度限制分两次发。
#LIBPATH = /usr/local/lib
LIBPATH = .
#deine player lib version infomation
VERSION_MAJOR = 1
VERSION_MINOR = 0
srcdir = .
top_srcdir = ../..
pkgdatadir = $(datadir)/mpeg4ip
pkglibdir = $(libdir)/mpeg4ip
pkgincludedir = $(includedir)/mpeg4ip
top_builddir = ../..
datadir = ${prefix}/share
#libdir = ${exec_prefix}/lib
includedir = ${prefix}/include
prefix = /usr/local
include_HEADERS =
codec_plugin.h
rtp_plugin.h
text_plugin.h
mpeg4ip.h
codec_plugin_private.h
player_session.h
player_media.h
player_util.h
our_msg_queue.h
ip_port.h
media_utils.h
playlist.h
our_config_file.h
video.h
video_sdl.h
mpeg4ip_getopt.h
mpeg2t/mpeg2_transport.h
mpeg2ps/mpeg2_ps.h
@HAVE_MAC_OSX_FALSE@SDL_AUDIO_FLAGS =
@HAVE_MAC_OSX_TRUE@SDL_AUDIO_FLAGS = -framework CoreAudio -framework AudioToolbox
@HAVE_MAC_OSX_FALSE@SDL_AUDIO_LIB = $(top_builddir)/lib/SDLAudio/src/libmpeg4ipSDL.la
@HAVE_MAC_OSX_TRUE@SDL_AUDIO_LIB = $(top_builddir)/player/lib/audio/portaudio/libportaudio.la
@HAVE_MAC_OSX_FALSE@SDL_AUDIO_INC = -I$(top_srcdir)/lib/SDLAudio/include
@HAVE_MAC_OSX_TRUE@SDL_AUDIO_INC = -I$(top_srcdir)/player/lib/audio/portaudio
@HAVE_MAC_OSX_FALSE@ADD_CFLAGS =
@HAVE_MAC_OSX_TRUE@ADD_CFLAGS = -Ddarwin -D_THREAD_SAFE -DNEED_SDL_VIDEO_IN_MAIN_THREAD
SDL_AUDIO_FLAGS =
#SDL_AUDIO_FLAGS = -framework CoreAudio -framework AudioToolbox
SDL_AUDIO_LIB = $(top_builddir)/lib/SDLAudio/src/libmpeg4ipSDL.la
#SDL_AUDIO_LIB = $(top_builddir)/player/lib/audio/portaudio/libportaudio.la
SDL_AUDIO_INC = -I$(top_srcdir)/lib/SDLAudio/include
#SDL_AUDIO_INC = -I$(top_srcdir)/player/lib/audio/portaudio
ADD_CFLAGS =
#ADD_CFLAGS = -Ddarwin -D_THREAD_SAFE -DNEED_SDL_VIDEO_IN_MAIN_THREAD
# lib target.
#LIB_TARGET = libmyplayer.so.$(VERSION_MAJOR).$(VERSION_MINOR)
#LIB_TARGET = libmyplayer.so
#PROG_TARGET = myplayer
myplayer_LDFLAGS = $(SDL_AUDIO_FLAGS)
myplayer_LDADD =
-lm $(SDL_AUDIO_LIB)
libmp4player.la
libmp4syncbase.la
libmp4syncsdl.la
libmp4sdlvideo.la
libmp4syncbase.la
libmp4playerutils.la
$(top_builddir)/lib/audio/libaudio.la
$(top_builddir)/lib/ismacryp/libismacryp.la
-L/usr/local/lib -R/usr/local/lib -lSDL -lpthread -lposix4
#
#COMMOBJS = myplayer.o
MAINOBJS = myplayer.o
#HEADERS = myplayer.h
HEADERS = $(include_HEADERS)
CC = gcc -g -fPIC
DEFS = -DHAVE_CONFIG_H
CPPFLAGS =
CXXFLAGS = -g -O2 -DMPEG4IP -I/usr/local/include/SDL -D_REENTRANT
AM_CFLAGS = -D_REENTRANT -Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -Wno-char-subscripts -Wno-unknown-pragmas -Wformat=2 -Wdeclaration-after-statement -Wpointer-arith -Wsign-compare -Wswitch-enum -Wnested-externs -Wswitch-enum -DPLAYER_PLUGIN_DIR="${exec_prefix}/lib/mp4player_plugin" $(ADD_CFLAGS)
AM_CXXFLAGS = -D_REENTRANT -DNOCONTROLS -fexceptions -Wall -Wno-char-subscripts -Woverloaded-virtual -Wno-unknown-pragmas -Wno-deprecated -Wformat=2 -Wpointer-arith -Wsign-compare -DPLAYER_PLUGIN_DIR="${exec_prefix}/lib/mp4player_plugin" $(ADD_CFLAGS)
CFLAGS = -g -O2 -DMPEG4IP -I/usr/local/include/SDL -D_REENTRANT
CPP = gcc -E
CXX = g++
CXXCPP = g++ -E
CXXDEPMODE = depmode=gcc3
SHELL = /bin/bash
LIBS = -ldl -lnsl -lsocket
LIBTOOL = $(SHELL) $(top_builddir)/libtool
PROGS = myplayer
#PROGS = myplayer.so
INCLUDES =
-I$(top_srcdir)/include
-I$(top_srcdir)/player/lib
-I$(top_srcdir)/player/lib/audio
-I$(top_srcdir)/player/lib/libhttp
-I$(top_srcdir)/player/lib/rtsp
$(SDL_AUDIO_INC)
-I/usr/local/include
-I/usr/local/include/SDL
-I$(top_srcdir)/lib
-I$(top_srcdir)/lib/avi
-I$(top_srcdir)/lib/ismacryp
-I$(top_srcdir)/lib/mp4av
-I$(top_srcdir)/lib/mp4
-I$(top_srcdir)/lib/mp4v2
-I$(top_srcdir)/lib/mpeg2ps
-I$(top_srcdir)/lib/msg_queue
-I$(top_srcdir)/lib/rtp
-I$(top_srcdir)/lib/sdp
-I$(top_srcdir)/lib/utils
-I$(top_srcdir)/lib/audio
-I/usr/openwin/include
am__DEPENDENCIES_1 = $(top_builddir)/lib/SDLAudio/src/libmpeg4ipSDL.la
am_myplayer_OBJECTS = myplayer.o
myplayer_OBJECTS = $(am_myplayer_OBJECTS)
myplayer_DEPENDENCIES = $(am__DEPENDENCIES_1) libmp4player.la
libmp4syncbase.la libmp4syncsdl.la libmp4sdlvideo.la
libmp4syncbase.la libmp4playerutils.la
$(top_builddir)/lib/audio/libaudio.la
$(top_builddir)/lib/ismacryp/libismacryp.la
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS)
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS)
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS)
$(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS)
$(AM_LDFLAGS) $(LDFLAGS) -o $@
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS)
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS)
$(AM_CXXFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) --tag=CXX --mode=link $(CXXLD) $(AM_CXXFLAGS)
$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
生成一个可执行文件myplayer。现在想将此可执行文件以动态链接库的
形式提供,于是将myplayr.cpp中的main函数改成startmain,用来接收
相应的参数。同时修改makefile生成动态链接库文件(.so)。但试了很
多次都不行。我的是在Solaris 9上编译。敬请高人指点,在生成动态库
时的makefile相关项应该怎么写才好?
由于长度限制分两次发。
#LIBPATH = /usr/local/lib
LIBPATH = .
#deine player lib version infomation
VERSION_MAJOR = 1
VERSION_MINOR = 0
srcdir = .
top_srcdir = ../..
pkgdatadir = $(datadir)/mpeg4ip
pkglibdir = $(libdir)/mpeg4ip
pkgincludedir = $(includedir)/mpeg4ip
top_builddir = ../..
datadir = ${prefix}/share
#libdir = ${exec_prefix}/lib
includedir = ${prefix}/include
prefix = /usr/local
include_HEADERS =
codec_plugin.h
rtp_plugin.h
text_plugin.h
mpeg4ip.h
codec_plugin_private.h
player_session.h
player_media.h
player_util.h
our_msg_queue.h
ip_port.h
media_utils.h
playlist.h
our_config_file.h
video.h
video_sdl.h
mpeg4ip_getopt.h
mpeg2t/mpeg2_transport.h
mpeg2ps/mpeg2_ps.h
@HAVE_MAC_OSX_FALSE@SDL_AUDIO_FLAGS =
@HAVE_MAC_OSX_TRUE@SDL_AUDIO_FLAGS = -framework CoreAudio -framework AudioToolbox
@HAVE_MAC_OSX_FALSE@SDL_AUDIO_LIB = $(top_builddir)/lib/SDLAudio/src/libmpeg4ipSDL.la
@HAVE_MAC_OSX_TRUE@SDL_AUDIO_LIB = $(top_builddir)/player/lib/audio/portaudio/libportaudio.la
@HAVE_MAC_OSX_FALSE@SDL_AUDIO_INC = -I$(top_srcdir)/lib/SDLAudio/include
@HAVE_MAC_OSX_TRUE@SDL_AUDIO_INC = -I$(top_srcdir)/player/lib/audio/portaudio
@HAVE_MAC_OSX_FALSE@ADD_CFLAGS =
@HAVE_MAC_OSX_TRUE@ADD_CFLAGS = -Ddarwin -D_THREAD_SAFE -DNEED_SDL_VIDEO_IN_MAIN_THREAD
SDL_AUDIO_FLAGS =
#SDL_AUDIO_FLAGS = -framework CoreAudio -framework AudioToolbox
SDL_AUDIO_LIB = $(top_builddir)/lib/SDLAudio/src/libmpeg4ipSDL.la
#SDL_AUDIO_LIB = $(top_builddir)/player/lib/audio/portaudio/libportaudio.la
SDL_AUDIO_INC = -I$(top_srcdir)/lib/SDLAudio/include
#SDL_AUDIO_INC = -I$(top_srcdir)/player/lib/audio/portaudio
ADD_CFLAGS =
#ADD_CFLAGS = -Ddarwin -D_THREAD_SAFE -DNEED_SDL_VIDEO_IN_MAIN_THREAD
# lib target.
#LIB_TARGET = libmyplayer.so.$(VERSION_MAJOR).$(VERSION_MINOR)
#LIB_TARGET = libmyplayer.so
#PROG_TARGET = myplayer
myplayer_LDFLAGS = $(SDL_AUDIO_FLAGS)
myplayer_LDADD =
-lm $(SDL_AUDIO_LIB)
libmp4player.la
libmp4syncbase.la
libmp4syncsdl.la
libmp4sdlvideo.la
libmp4syncbase.la
libmp4playerutils.la
$(top_builddir)/lib/audio/libaudio.la
$(top_builddir)/lib/ismacryp/libismacryp.la
-L/usr/local/lib -R/usr/local/lib -lSDL -lpthread -lposix4
#
#COMMOBJS = myplayer.o
MAINOBJS = myplayer.o
#HEADERS = myplayer.h
HEADERS = $(include_HEADERS)
CC = gcc -g -fPIC
DEFS = -DHAVE_CONFIG_H
CPPFLAGS =
CXXFLAGS = -g -O2 -DMPEG4IP -I/usr/local/include/SDL -D_REENTRANT
AM_CFLAGS = -D_REENTRANT -Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -Wno-char-subscripts -Wno-unknown-pragmas -Wformat=2 -Wdeclaration-after-statement -Wpointer-arith -Wsign-compare -Wswitch-enum -Wnested-externs -Wswitch-enum -DPLAYER_PLUGIN_DIR="${exec_prefix}/lib/mp4player_plugin" $(ADD_CFLAGS)
AM_CXXFLAGS = -D_REENTRANT -DNOCONTROLS -fexceptions -Wall -Wno-char-subscripts -Woverloaded-virtual -Wno-unknown-pragmas -Wno-deprecated -Wformat=2 -Wpointer-arith -Wsign-compare -DPLAYER_PLUGIN_DIR="${exec_prefix}/lib/mp4player_plugin" $(ADD_CFLAGS)
CFLAGS = -g -O2 -DMPEG4IP -I/usr/local/include/SDL -D_REENTRANT
CPP = gcc -E
CXX = g++
CXXCPP = g++ -E
CXXDEPMODE = depmode=gcc3
SHELL = /bin/bash
LIBS = -ldl -lnsl -lsocket
LIBTOOL = $(SHELL) $(top_builddir)/libtool
PROGS = myplayer
#PROGS = myplayer.so
INCLUDES =
-I$(top_srcdir)/include
-I$(top_srcdir)/player/lib
-I$(top_srcdir)/player/lib/audio
-I$(top_srcdir)/player/lib/libhttp
-I$(top_srcdir)/player/lib/rtsp
$(SDL_AUDIO_INC)
-I/usr/local/include
-I/usr/local/include/SDL
-I$(top_srcdir)/lib
-I$(top_srcdir)/lib/avi
-I$(top_srcdir)/lib/ismacryp
-I$(top_srcdir)/lib/mp4av
-I$(top_srcdir)/lib/mp4
-I$(top_srcdir)/lib/mp4v2
-I$(top_srcdir)/lib/mpeg2ps
-I$(top_srcdir)/lib/msg_queue
-I$(top_srcdir)/lib/rtp
-I$(top_srcdir)/lib/sdp
-I$(top_srcdir)/lib/utils
-I$(top_srcdir)/lib/audio
-I/usr/openwin/include
am__DEPENDENCIES_1 = $(top_builddir)/lib/SDLAudio/src/libmpeg4ipSDL.la
am_myplayer_OBJECTS = myplayer.o
myplayer_OBJECTS = $(am_myplayer_OBJECTS)
myplayer_DEPENDENCIES = $(am__DEPENDENCIES_1) libmp4player.la
libmp4syncbase.la libmp4syncsdl.la libmp4sdlvideo.la
libmp4syncbase.la libmp4playerutils.la
$(top_builddir)/lib/audio/libaudio.la
$(top_builddir)/lib/ismacryp/libismacryp.la
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS)
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS)
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS)
$(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS)
$(AM_LDFLAGS) $(LDFLAGS) -o $@
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS)
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS)
$(AM_CXXFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) --tag=CXX --mode=link $(CXXLD) $(AM_CXXFLAGS)
$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
|
一般都要加上fPIC的。
你可以用file命令看一下这个libmpeg4ipSDL.la文件,看看系统返回什么。
你可以用file命令看一下这个libmpeg4ipSDL.la文件,看看系统返回什么。