#1 2024-03-11 14:00:15

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,571
Website

SQLite3 static for 3.44.2 and pthread compilation problem

@ab - I'm trying to upgrade SQLite3 in my mORMot1 application from 3.31.0 to 3.44.2 (to the latest static version uploaded to the mORMot repository), but I get various linking errors related to pthread and dlopen (sorry for big fragment) under x86_64-linux (win64 is OK)

(9015) Linking bin/fpc-linux/ub
/usr/bin/ld: libs/Synopse/./static/x86_64-linux/sqlite3.o: in function `sqlite3_strlike':
sqlite3mc.c:(.text+0xc735): undefined reference to `_pthread_mutex_trylock'
/usr/bin/ld: libs/Synopse/./static/x86_64-linux/sqlite3.o: in function `sqlite3_free_filename':
sqlite3mc.c:(.text+0xe345): undefined reference to `_pthread_mutex_destroy'
/usr/bin/ld: libs/Synopse/./static/x86_64-linux/sqlite3.o: in function `sqlite3_create_filename':
sqlite3mc.c:(.text+0x20bbc): undefined reference to `_pthread_create'
/usr/bin/ld: libs/Synopse/./static/x86_64-linux/sqlite3.o: in function `sqlite3_uri_int64':
sqlite3mc.c:(.text+0x2bbc4): undefined reference to `_pthread_mutexattr_init'
/usr/bin/ld: sqlite3mc.c:(.text+0x2bbd1): undefined reference to `_pthread_mutexattr_settype'
/usr/bin/ld: sqlite3mc.c:(.text+0x2bbdc): undefined reference to `_pthread_mutex_init'
/usr/bin/ld: sqlite3mc.c:(.text+0x2bbe4): undefined reference to `_pthread_mutexattr_destroy'
/usr/bin/ld: sqlite3mc.c:(.text+0x2bc30): undefined reference to `_pthread_mutex_init'
/usr/bin/ld: sqlite3mc.c:(.text+0x2c7ce): undefined reference to `_pthread_join'
/usr/bin/ld: libs/Synopse/./static/x86_64-linux/sqlite3.o: in function `sqlite3_load_extension':
sqlite3mc.c:(.text+0x4246e): undefined reference to `_dlerror'
/usr/bin/ld: libs/Synopse/./static/x86_64-linux/sqlite3.o: in function `sqlite3_compileoption_used':
sqlite3mc.c:(.text+0xb804): undefined reference to `_dlclose'
/usr/bin/ld: sqlite3mc.c:(.text+0xb817): undefined reference to `_dlsym'
/usr/bin/ld: sqlite3mc.c:(.text+0xb829): undefined reference to `_dlopen'
/usr/bin/ld: libs/Synopse/./static/x86_64-linux/sqlite3.o: in function `sqlite3_strlike':
sqlite3mc.c:(.text+0xc721): undefined reference to `_pthread_mutex_unlock'
/usr/bin/ld: sqlite3mc.c:(.text+0xc751): undefined reference to `_pthread_mutex_lock'
UB.lpr(56,1) Error: (9013) Error while linking

I tried under Ubuntu 22.04 (GLIBC 2.35) and  Ubuntu 20.04 (GLIBC 2.31) with the same results..

I assume that you compile Linux static under newer OSes (newer libc) and this is the reason?

Online

#2 2024-03-11 15:30:27

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,571
Website

Re: SQLite3 static for 3.44.2 and pthread compilation problem

I'm confused a little, because the same sqlite3.o is used in mormot2.2_stable and TFB example compiles well. Any help is wellcome

Online

#3 2024-03-13 11:16:12

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,571
Website

Re: SQLite3 static for 3.44.2 and pthread compilation problem

I found this commit in sqlite3 build what replace all symbols pthread->_pthread + dl->_dl and issue #211
To solve my problem I do a backward replacement, and now linker is happy.
Linux script what do a replacing is here

Still do not understand why it compiles in mORMot2.

Online

#4 2024-03-13 11:24:37

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,571
Website

Re: SQLite3 static for 3.44.2 and pthread compilation problem

To solve a problem, described in #211 ( `GLIBC_2.34' not found ) I compile a production version of my product using docker with fpc what based on Ubuntu 20.04 (GLIBC 2.31)

Online

#5 2024-03-13 16:29:00

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,654
Website

Re: SQLite3 static for 3.44.2 and pthread compilation problem

Perhaps https://github.com/synopse/mORMot/commi … 237a1a138b
would fix the problem during our own static build.
When I run this script, now it compiles and links fine for both mORMot 1 and also mORMot 2.

I will release a new mORMot 1 + 2 static binaries soon.

Instead of a docker container, you can just use fpc-ootb binaries.
See https://github.com/synopse/mORMot2/blob … ild_fpc.sh

Offline

#6 2024-03-13 17:10:17

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,571
Website

Re: SQLite3 static for 3.44.2 and pthread compilation problem

Thanks a lot! BTW new binaries can be released with SQLite3 3.45.1 (where JSON and read performance improvements are introduced)

Online

Board footer

Powered by FluxBB