由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Linux版 - ask a question about compile shared library using libtool (转载)
相关主题
dropbox工作的机器不能安装,大家是如何解决的?请教一个Openmpi编译的问题
Intel HD2000显卡Linux驱动问题?Windows Word file: 怎么弄不同的footnote/headnote (转载)
怎样把snoop的结果抽出来(假设已变成hexadecimal and ASCII format)?Cisco VPN for 64-bit ubuntu 11.04
我自己写了一个程序,专门对付GFW的,给我妈用 (转载)问个网络问题
9.10 update 出问题,网络不能用了Can't call method "header" on an undefined value at /.../login.pl line 19.
把Linux 下 C++程序建成WEB SERVICEjavascript问题,怎么让浏览器下载一个文件不是直接打开?
装FREENAS,出现这个错误,高手给看看python code performance --- normal or too slow? (转载)
scripting language luarpm怎么用?
相关话题的讨论汇总
话题: shared话题: library话题: function
进入Linux版参与讨论
1 (共1页)
g***l
发帖数: 2753
1
【 以下文字转载自 Programming 讨论区 】
发信人: gmail (Gmail is Nothing --Lanxiang/SJTU), 信区: Programming
标 题: ask a question about compile shared library using libtool
发信站: BBS 未名空间站 (Thu Apr 7 01:55:44 2011, 美东)
Sorry, no Chinese input here.
I met a strange issue when creating a shared library using libtool.
In this project,I am using two C files, base.c and base2.c, and one H header
file,base.h, to create libbasefunc.so. All the function declarations are
done in the header file and the function implementations are done in these
two C files.
In another project, some functions in libbasefunc.so will be called in other
C files which are used to create another shared library libinstance.so.
The main application will uses libinstance.so to do something.
The problem is :
If I put all the function implementations in only one c file, and generate
libbasefunc.so. and generate libinstance.so using -lbasefunc option,
everything is fine.The main application can use libinstance.so smoothly.
However, if I put the function implementations into two different C files
and all the function declarations in one header file, I can create the
libbasefunc.so and libinstance.so without any issues, but when the
application uses libinstance.so, it will report "undefined symbol: your_test
_func2". Actually "your_test_func2()" is declared in the header file and
implemented in base2.c.
Here is the copy of the Makefile.am
basefunc_LTLIBRARIES = libbasefunc.la
# sources used to compile this plug-in
libbasefunc_la_SOURCES = base.c base2.c
# flags used to compile this plug-in
# add other _CFLAGS and _LIBS as needed
libbasefunc_la_CFLAGS = $(GLIB_CFLAGS)
libbasefunc_la_LIBADD = $(GLIB_LIBS)
libbasefunc_la_LDFLAGS = $(GLIB_LDFLAGS)
libbasefunc_la_LIBTOOLFLAGS = --tag=disable-static
# headers we need copy to ${prefix}/include
include_HEADERS = base.h
#=========End of Makefile.am =======================
lately, I found that if I add another option "--tag=disable-shared" to
libbasefunc_la_LIBTOOLFLAGS, everything will be fine. The application can
use libinstance.so correctly. But there will be no shared library
libbasefunc.so generated, instead a statically linked library libbasefunc.a
was created. This is not what I want.
I have used nm command to check the symbol table in libbasefunc.so, actually
symbol "your_test_func2" was in the code section with a valid address. I
just don't understand why it works only if we put all the source code into
one file.
Would you please input some words to help me to fix this issue?
I want to put the function implementations into two different files and
still want to create a usable shared library libbasefunc.so.
thanks
1 (共1页)
进入Linux版参与讨论
相关主题
rpm怎么用?9.10 update 出问题,网络不能用了
bash to implement Map>把Linux 下 C++程序建成WEB SERVICE
Anyone using gigolo?装FREENAS,出现这个错误,高手给看看
A bash question!scripting language lua
dropbox工作的机器不能安装,大家是如何解决的?请教一个Openmpi编译的问题
Intel HD2000显卡Linux驱动问题?Windows Word file: 怎么弄不同的footnote/headnote (转载)
怎样把snoop的结果抽出来(假设已变成hexadecimal and ASCII format)?Cisco VPN for 64-bit ubuntu 11.04
我自己写了一个程序,专门对付GFW的,给我妈用 (转载)问个网络问题
相关话题的讨论汇总
话题: shared话题: library话题: function