如何编译动态库?

时间:2009-09-27 19:55:06

标签: c++ iphone macos sqlite

我在网上搜索了几天,似乎无法找到有关如何执行此操作的明确说明。

SQLite没有数学函数,如正弦,余弦等。我找到了一个扩展SQLite的库并添加了这些函数,但我无法弄清楚如何编译库。

http://lhealy.livejournal.com/6306.html

我已经尝试过所有事情(解决方案除外)。我下载了SQLite源代码,配置并使用了make,然后尝试在扩展程序的源目录中使用以下命令构建动态库

  

gcc -fPIC func_ext.c -shared -o   libsqlitefunctions.so -Isqlite3   -Isqlite3 / SRC

我在此目录中有sqlite3源,因此-I标志应指向正确的目录。这是我得到的错误。

func_ext.c:91: error: static declaration of ‘acosh’ follows non-static declaration
func_ext.c:99: error: static declaration of ‘asinh’ follows non-static declaration
func_ext.c:107: error: static declaration of ‘atanh’ follows non-static declaration
func_ext.c:403: error: conflicting types for ‘isblank’
/usr/include/ctype.h:242: error: previous definition of ‘isblank’ was here
func_ext.c: In function ‘properFunc’:
func_ext.c:422: warning: pointer targets in passing argument 1 of ‘sqlite3StrDup’ differ in signedness
func_ext.c:422: warning: pointer targets in assignment differ in signedness
func_ext.c: In function ‘padlFunc’:
func_ext.c:463: warning: pointer targets in assignment differ in signedness
func_ext.c: In function ‘padrFunc’:
func_ext.c:509: warning: pointer targets in assignment differ in signedness
func_ext.c: In function ‘padcFunc’:
func_ext.c:556: warning: pointer targets in assignment differ in signedness
func_ext.c: In function ‘strfilterFunc’:
func_ext.c:607: warning: pointer targets in assignment differ in signedness
func_ext.c:608: warning: pointer targets in assignment differ in signedness
func_ext.c:616: warning: pointer targets in passing argument 1 of ‘sqlite3ReadUtf8’ differ in signedness
func_ext.c:618: warning: pointer targets in passing argument 1 of ‘sqlite3ReadUtf8’ differ in signedness
func_ext.c: In function ‘_substr’:
func_ext.c:654: warning: pointer targets in passing argument 1 of ‘sqlite3ReadUtf8’ differ in signedness
func_ext.c:659: warning: pointer targets in passing argument 1 of ‘sqlite3ReadUtf8’ differ in signedness
func_ext.c:664: warning: pointer targets in passing argument 1 of ‘sqlite3ReadUtf8’ differ in signedness
func_ext.c:665: warning: pointer targets in passing argument 1 of ‘sqlite3ReadUtf8’ differ in signedness
func_ext.c: In function ‘charindexFunc’:
func_ext.c:716: warning: pointer targets in passing argument 1 of ‘_substr’ differ in signedness
func_ext.c:716: warning: pointer targets in passing argument 2 of ‘_substr’ differ in signedness
func_ext.c: In function ‘rightFunc’:
func_ext.c:775: warning: pointer targets in assignment differ in signedness
func_ext.c:779: warning: pointer targets in passing argument 1 of ‘sqlite3ReadUtf8’ differ in signedness
func_ext.c: In function ‘ltrimFunc’:
func_ext.c:833: warning: pointer targets in assignment differ in signedness
func_ext.c: In function ‘rtrimFunc’:
func_ext.c:851: warning: pointer targets in assignment differ in signedness
func_ext.c: In function ‘trimFunc’:
func_ext.c:872: warning: pointer targets in assignment differ in signedness
func_ext.c: In function ‘replaceFunc’:
func_ext.c:914: warning: pointer targets in assignment differ in signedness
func_ext.c:915: warning: pointer targets in assignment differ in signedness
func_ext.c:916: warning: pointer targets in assignment differ in signedness
func_ext.c: In function ‘reverseFunc’:
func_ext.c:975: warning: pointer targets in assignment differ in signedness
func_ext.c:982: warning: pointer targets in passing argument 1 of ‘sqlite3ReadUtf8’ differ in signedness
func_ext.c: In function ‘differenceFunc’:
func_ext.c:1336: warning: pointer targets in passing argument 1 of ‘sqlite3ReadUtf8’ differ in signedness
func_ext.c:1336: warning: pointer targets in passing argument 1 of ‘sqlite3ReadUtf8’ differ in signedness

谢谢! 桑德罗

2 个答案:

答案 0 :(得分:1)

考虑使用g ++而不是gcc,它在编译c ++时自动设置正确的设置。例如,使用以下代码:

int f(int x)
{

}

int f(int x, int y)
{

}

int main(int argc, char* argv[])
{

}

...给出错误:

test.c:7: error: conflicting types for ‘f’
test.c:2: error: previous definition of ‘f’ was here

与g ++一样,没关系。可能是代码真的试图成为c并且定义了非法的重载并且是一个更大的问题,但是我先给它一个镜头。

答案 1 :(得分:0)

这些是编译器错误,而不是链接器错误 您需要先将程序编译(以正常方式),然后才能将其构建为共享库。