GCC 链接出现未定义错误

发布于 2022-10-15 06:59:39 字数 6367 浏览 14 评论 0

本帖最后由 aini1987114 于 2011-05-15 00:39 编辑

交叉链接时出现的未定义错误:命令没问题了gcc sync_sqlite3.c -L /usr/lib -lcurl -ljson -luuid -lsync_sqlite3    -o  sync_sqlite3

huang@huang-desktop:~/lunwen/sync_sqlite3$gcc sync_sqlite3.c -L /usr/lib -lcurl -ljson -luuid -lsync_sqlite3    -o  sync_sqlite3
sync_sqlite3.c: In function ‘update_hook’:
sync_sqlite3.c:16: warning: format ‘%d’ expects type ‘int’, but argument 4 has type ‘sqlite3_int64’
sync_sqlite3.c:31: warning: format ‘%d’ expects type ‘int’, but argument 7 has type ‘sqlite3_int64’
sync_sqlite3.c:33: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘sqlite3_int64’
sync_sqlite3.c: In function ‘sqlite3_sync_set_sync_url’:
sync_sqlite3.c:76: warning: conversion lacks type at end of format
sync_sqlite3.c: In function ‘sqlite3_sync_set_fiter_condition’:
sync_sqlite3.c:86: warning: conversion lacks type at end of format
/usr/lib/gcc/i486-linux-gnu/4.4.3/../../../../lib/crt1.o: In function `_start':
(.text+0x1: undefined reference to `main'
/tmp/cc0yEPs9.o: In function `update_hook':
sync_sqlite3.c.text+0x15e): undefined reference to `sqlite3_get_table'
sync_sqlite3.c.text+0x2b3): undefined reference to `sqlite3_exec'
/tmp/cc0yEPs9.o: In function `uuidgen':
sync_sqlite3.c.text+0x349): undefined reference to `sqlite3_result_text'
/tmp/cc0yEPs9.o: In function `sqlite3_sync_set_userpwd':
sync_sqlite3.c.text+0x3e3): undefined reference to `sqlite3_exec'
/tmp/cc0yEPs9.o: In function `sqlite3_sync_set_sync_url':
sync_sqlite3.c.text+0x46a): undefined reference to `sqlite3_exec'
/tmp/cc0yEPs9.o: In function `sqlite3_sync_set_fiter_condition':
sync_sqlite3.c.text+0x4f1): undefined reference to `sqlite3_exec'
/tmp/cc0yEPs9.o: In function `sqlite3_sync_config':
sync_sqlite3.c.text+0x534): undefined reference to `sqlite3_exec'
sync_sqlite3.c.text+0x55f): undefined reference to `sqlite3_exec'
/tmp/cc0yEPs9.o:sync_sqlite3.c.text+0x58a): more undefined references to `sqlite3_exec' follow
/tmp/cc0yEPs9.o: In function `sqlite3_sync_config':
sync_sqlite3.c.text+0x5ba): undefined reference to `sqlite3_get_table'
sync_sqlite3.c:(.text+0x5ec): undefined reference to `sqlite3_exec'
sync_sqlite3.c:(.text+0x5f7): undefined reference to `sqlite3_free_table'
/tmp/cc0yEPs9.o: In function `sqlite3_upload_sync':
sync_sqlite3.c:(.text+0x70: undefined reference to `sqlite3_get_table'
sync_sqlite3.c:(.text+0x970): undefined reference to `sqlite3_free_table'
sync_sqlite3.c:(.text+0xa2a): undefined reference to `sqlite3_get_table'
sync_sqlite3.c:(.text+0xa7: undefined reference to `sqlite3_free_table'
sync_sqlite3.c:(.text+0xc6b): undefined reference to `sqlite3_get_table'
sync_sqlite3.c:(.text+0xc84): undefined reference to `sqlite3_free_table'
sync_sqlite3.c:(.text+0xd70): undefined reference to `sqlite3_exec'
sync_sqlite3.c:(.text+0xd9a): undefined reference to `sqlite3_exec'
/tmp/cc0yEPs9.o: In function `sqlite3_download_sync':
sync_sqlite3.c:(.text+0xfb5): undefined reference to `sqlite3_get_table'
sync_sqlite3.c:(.text+0xffc): undefined reference to `sqlite3_free_table'
sync_sqlite3.c:(.text+0x1062): undefined reference to `sqlite3_get_table'
sync_sqlite3.c:(.text+0x10ff): undefined reference to `sqlite3_free_table'
collect2: ld returned 1 exit status

C文件中没有没有定义上述函数
     

这是我的sync_sqlite3.h文件

#endif
   void update_hook(void* inData,int modifyType,char const * dbName,char const * tableName,sqlite3_int64 rowid);
   void uuidgen(sqlite3_context* ctx,int argc,sqlite3_value ** argv);
   int sqlite3_sync_set_userpwd(char* username,char* password,sqlite3* conn);
   int sqlite3_sync_set_sync_url(char* sync_url,sqlite3* conn);
   int sqlite3_sync_set_fiter_condition(char* fiter_condition,sqlite3* conn);
   int sqlite3_sync_config(sqlite3 * conn);
   //size_t print_response(void* ptr,size_t size,size_t nmemb,void* stream);
   int sqlite3_upload_sync(sqlite3* db,char* table_name,int modify_type);
   int sqlite3_download_sync(sqlite3* db,char* table_name,int modify_type);
   
#ifdef        __cplusplus

这个问题如何解决?是否要修改c源程序,定义相关函数?还是在头文件(sync_sqlite3.h)中修改,定义上面未定义函数?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文