SQLite Forum

(Deleted)
Login

(1) By anonymous on 2021-02-05 13:25:00 [source]

Building an extension in C returns this error:

-------------- Build: Debug in UIC (compiler: GNU GCC Compiler)---------------

gcc -shared obj/Debug/UIC.o -o bin/Debug/libUIC.so
/usr/bin/ld: obj/Debug/UIC.o: warning: relocation against sqlite3_api' in read-only section.text' /usr/bin/ld: obj/Debug/UIC.o: relocation R_X86_64_PC32 against symbol `sqlite3_api' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: final link failed: bad value collect2: error: ld returned 1 exit status Process terminated with status 1 (0 minute(s), 0 second(s)) 1 error(s), 1 warning(s) (0 minute(s), 0 second(s))

The sample code used looks like this: /* Add your header comment here */

#include <sqlite3ext.h> SQLITE_EXTENSION_INIT1;

#include <assert.h>

#include "uic.h"

/* ** Implementation of the test_func() function. ** */ static void uic(sqlite3_context *context, int argc, sqlite3_value **argv){

int check_number = sqlite3_value_int(argv[0]);
int check_digit = check_number;

sqlite3_result_int(context, check_digit);

}

int sqlite3_extension_init(sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi){

SQLITE_EXTENSION_INIT2(pApi);

sqlite3_create_function(db, "uic", 1, SQLITE_INTEGER, 0, uic, 0, 0);

return SQLITE_OK; }