1. 程式人生 > 實用技巧 >ubuntu sqlite3 undefined reference to `sqlite3_column_table_name'

ubuntu sqlite3 undefined reference to `sqlite3_column_table_name'

自己編譯的sqlite3, 結果在編譯gdal的時候出現

/usr/bin/ld: /home/xuqinghan/下載/gdal-3.1.1/.libs/libgdal.so: undefined reference to `sqlite3_column_origin_name'
/usr/bin/ld: /home/xuqinghan/下載/gdal-3.1.1/.libs/libgdal.so: undefined reference to `sqlite3_column_table_name'

google一番,發現是sqlite3需要配置一個巨集

https://www.sqlite.org/compile.html

SQLITE_ENABLE_COLUMN_METADATA

When this C-preprocessor macro is defined, SQLite includes some additional APIs that provide convenient access to meta-data about tables and queries. The APIs that are enabled by this option are:

具體做法是在原始碼資料夾下

cd ./sqlite-autoconf-3320300

xed ./sqlite3.c

新增

#define SQLITE_CORE 1
#define SQLITE_AMALGAMATION 1
#ifndef SQLITE_PRIVATE
# define SQLITE_PRIVATE static
#endif
#define SQLITE_ENABLE_COLUMN_METADATA 1

/************** Begin file ctime.c ******************************************
*/ /*

然後

./configure

make

sudo make install