【发布时间】:2011-03-27 03:36:31
【问题描述】:
据我所知,我需要按照以下步骤准备制作共享库:
gcc -fPIC libfoo.c -o libfoo.o
然后我链接它。我曾尝试制作一个 makefile 来帮助执行这些步骤,但现在似乎发生了错误。
当我运行 make 文件时会发生这种情况:
foo@box:~/Projects/so$ gcc -fPIC ./libfoo.c -o libfoo.o
/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status
如果没有 main 函数,我如何编译库文件,因为它不是程序并且旨在成为库?
如果对我的程序有帮助的话,基本上就是这样(解释)
(stdio and openssl headers here)
(debugging macro definitions here)
(two functions, gettime() and opensslrandom() defined here)
我似乎对宏的理解也有问题,因为它们最终会在共享库中,它们在共享库中毫无用处?我将它们包含在要包含的 libfoo.h 中,尽管我还没有查看宏是否有效。
【问题讨论】:
标签: c gcc shared-libraries