LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 2299|回复: 8

what is the fellow meaning?: undefined reference to `sqlite3_open'

[复制链接]
发表于 2005-10-10 10:44:20 | 显示全部楼层 |阅读模式
/tmp/ccUqbXeV.o(.text+0xd7): In function `main':
: undefined reference to `sqlite3_open'
/tmp/ccUqbXeV.o(.text+0xf1): In function `main':
: undefined reference to `sqlite3_errmsg'
/tmp/ccUqbXeV.o(.text+0x113): In function `main':
: undefined reference to `sqlite3_close'
/tmp/ccUqbXeV.o(.text+0x13e): In function `main':
: undefined reference to `sqlite3_exec'
/tmp/ccUqbXeV.o(.text+0x16e): In function `main':
: undefined reference to `sqlite3_close'
collect2: ld returned 1 exit status

my program begin with as fellow:
#include <stdlib.h>
#include <stdio.h>
#include <sqlite3.h>
...
moreover, I have sqlite3.h file under the directory of /usr/include and /usr/local/include
certainly, the sqlite3.h include functions which as above report errors. how can I to do? anybody give any suggestion? thanks!
发表于 2005-10-10 11:12:51 | 显示全部楼层
Have got the library for sqlite3 ?
I think this is what you need : http://www.sqlite.org/sqlite-source-3_2_7.zip

btw: you mistake fellow for follow
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-10-10 12:02:29 | 显示全部楼层
I have just downloaded the sqlite-source-3.2.7.tar.gz source code from the www.sqlite.org ,then as follow step:
#./configure -----successful
#make        -----successful
#make install-----successful
there are some files like libsqlite3.so, libsqlite3.so.0, libsqlite3.so.0.8.6 under the /usr/local/lib , BTW,  I downloaded others libs ,for instance ,sqlite-2.8.16.so and sqlite-3.2.7.so.  I edited the /etc/ld.so.conf to make sure my libs position is correct later.
any suggestion? thank you so very much!
回复 支持 反对

使用道具 举报

发表于 2005-10-10 12:30:27 | 显示全部楼层
I have no idea if you really compile your source code like this: gcc test.c -lsqlite3 -o test
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-10-10 13:37:25 | 显示全部楼层
I am very appreiate you,  I think that anyword is blank for me, thank you so much. the way of my complie is incorrect:
#gcc -o test test.c
but I want to know that where is my error.
回复 支持 反对

使用道具 举报

发表于 2005-10-10 14:08:17 | 显示全部楼层
man gcc
回复 支持 反对

使用道具 举报

发表于 2005-10-10 16:21:18 | 显示全部楼层
When you compile(actually static link time),the compiler(gcc) will put some information in the exectable file(elf) to help find the real address of the function in the shared object at runtime, so you need to tell the compiler where, i.e. from which shared object file,to find the function,

btw: appreiate will spell like this, appreciate
ps: Thx for providing such a chance for me to improve my poor English
回复 支持 反对

使用道具 举报

发表于 2005-10-10 16:34:44 | 显示全部楼层
Post by rickxbx
When you compile(actually static link time),the compiler(gcc) will put some information in the exectable file(elf) to help find the real address of the function in the shared object at runtime, so you need to tell the compiler where, i.e. from which shared object file,to find the function,

btw: appreiate will spell like this, appreciate
ps: Thx for providing such a chance for me to improve my poor English


Oh my goodness. I always get stunned when reading alphabetic language. Reading Chinese is much more comfortable.

By the way, I wonder whether the work that you mentioned, i.e. "put some info in the elf file to find the real address of the function in the shared object file at runtime", is done by the very, narrow-sense compiler or by the linker. I guess that is the job of the linker.

Mr. Banzhu, if I ever made any spelling error, please point it out, just like you did above
回复 支持 反对

使用道具 举报

发表于 2005-10-10 16:52:27 | 显示全部楼层
Post by Illidan

By the way, I wonder whether the work that you mentioned, i.e. "put some info in the elf file to find the real address of the function in the shared object file at runtime", is done by the very, narrow-sense compiler or by the linker. I guess that is the job of the linker.


narrow-sense compiler will convert the source code, i.e. .c files to the object code, i.e. .o files,it has nothing to do with others but the c files
linker will do the symbol resolution,relocation,etc.

So,I think you have got your answer.

Mr. Banzhu, if I ever made any spelling error, please point it out, just like you did above


Will Banzhu count?
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表