如何用静态库构建sqlite也可以用-fPIC编译?

时间:2015-11-23 07:45:13

标签: sqlite

我使用以下参数编译

#./configure --prefix=/usr/local CFLAGS=-fPIC --enable-static --enable-shared   \
            CFLAGS="-g -O2 -DSQLITE_ENABLE_FTS3=1 \
            -DSQLITE_ENABLE_COLUMN_METADATA=1     \
            -DSQLITE_ENABLE_UNLOCK_NOTIFY=1       \
            -DSQLITE_SECURE_DELETE=1              \
            -DSQLITE_ENABLE_DBSTAT_VTAB=1"
# make -j 8
# make install

使用sqlite后,我收到以下错误消息:

/usr/bin/g++ -o utools/utools.so -Wl,-Bsymbolic -g -O2 -shared -Wl,-z,defs utools/utools.plugin.o utools/lib/libutools.a core/lib/libunv.a fv/lib/libfv.a sb/lib/libsb.a -lz -ldl
/usr/bin/ld: /usr/local/sqlite/lib/libsqlite3.a(sqlite3.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/local/sqlite/lib/libsqlite3.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
scons: *** [stdarm/stdarm.so] Error 1
scons: building terminated because of errors.

1 个答案:

答案 0 :(得分:1)

/usr/local/lib/目录中,删除以下对我有用的文件

  • libsqlite3.a
  • libsqlite3.la
  • libsqlite3.o.0.bak
  • libsqlite3.so

我认为这些文件来自旧版本的libsqlite3, 因为当您键入并选中dpkg -L libsqlite3-dev时,都不会进入/usr/local/lib/

我引用了sqlite3 breakage