SQLite Forum

Error while linking sqlite shared library with the Application
Login

Error while linking sqlite shared library with the Application

(1.1) Originally by kunal (kyadav78) with edits by Richard Hipp (drh) on 2020-04-28 11:44:35 from 1.0 [source]

Hi, 
  I have compiled SQLite3.31.3 with below options:

/vobs/JDF/CSIAtom/source/build/ccache /vobs/buildtools/linux-i386/icc-10.1/bin/icc    -DNDEBUG -O1   -DUNICODE -D_UNICODE  -DXML_USE_PTHREADS -D_REENTRANT -DGTK_NO_CHECK_CASTS -D__WXGTK__   -D_linux_ -D__LINUX__ -Qlocation,asm,/vobs/buildtools/linux-i386/gcc-4.1.2/i686-pc-linux-gnu/bin -Qlocation,ld,/vobs/buildtools/linux-i386/gcc-4.1.2/i686-pc-linux-gnu/bin -tpp7 -we277 -we147 -we117 -we592 -we1011 -we175  -DCPU=i386 -DLINUX=1 -D_REENTRANT -DOEM_TARGET_CPU=I80X86 -DSTRICT_ALIGNMENT -D_FILE_OFFSET_BITS=64 -isystem/vobs/buildtools/linux-i386/fiery_debian/usr/include -isystem/vobs/linuxdev/xdev/usr/include -cxxlib-gcc=/vobs/buildtools/linux-i386/gcc-4.1.2 -L/vobs/buildtools/linux-i386/icc-10.1/lib -L/vobs/linuxdev/xdev/usr/lib -L/vobs/linuxdev/xdev/lib -Wl,-rpath-link,/vobs/linuxdev/xdev/lib -Wl,-rpath-link,/vobs/linuxdev/xdev/usr/lib -Wl,-rpath-link,/vobs/linuxdev/xdev/usr/X11R6/lib -DSEND_TRACE_TO_SYSLOG -fp -Wl,--allow-multiple-definition -Wl,-Bsymbolic -Wl,--warn-once  -DPIC -DCOMPILER_GNU -w -I"../../../../ExternalLibs/Sqlite_3_31_1/include/external" -I"../../../../ExternalLibs/Sqlite_3_31_1/include/internal" -c ../src/sqlite3.c -o Build/Linux/release/sqlite-3.31.1/sqlite3.o


Then i have created with .so file using below command:


/vobs/JDF/CSIAtom/source/build/ccache /vobs/buildtools/linux-i386/icc-10.1/bin/icc   -shared  -o  libsqlite-3.31.1.so  ./Build/Linux/release/sqlite-3.31.1/sqlite3.o


But while linking this so with my project and am getting below error:

ERROR:--------------------------
../../../ExternalLibs/Sqlite_3_31_1/bin/Linux/libsqlite-3.31.1.so: undefined reference to `__sync_synchronize'
Failed (exit code 1)... retry 1
i
-----------------------------------
Please help, what i am missing here?

Regards
Kunal

(2) By Warren Young (wyoung) on 2020-04-28 07:31:07 in reply to 1.0 [link] [source]

It looks like you're mixing compilers. __sync_synchronize is from GCC, but your command line appears to be for Intel's C compiler.

I'd suggest building everything with just one compiler, if possible.

Incidentally, you should study the Markdown formatting rules before posting again.

(3) By kunal (kyadav78) on 2020-04-28 09:28:28 in reply to 2 [link] [source]

Hi Warren, I have tried using same compiler used to build my project still i am facing same problem.

Compiler used for compiling sqlite3.c file:

/vobs/JDF/CSIAtom/source/build/ccache /vobs/buildtools/linux-i386/icc-10.1/bin/icc -DNDEBUG -O1 -DUNICODE -D_UNICODE -DNDEBUG -DXML_USE_PTHREADS -D_REENTRANT -DGTK_NO_CHECK_CASTS -D_WXGTK__ -D__LINUX__ -Qlocation,asm,/vobs/buildtools/linux-i386/gcc-4.1.2/i686-pc-linux-gnu/bin -Qlocation,ld,/vobs/buildtools/linux-i386/gcc-4.1.2/i686-pc-linux-gnu/bin -tpp7 -we277 -we147 -we117 -we592 -we1011 -we175 -DCPU=i386 -DLINUX=1 -D_REENTRANT -DOEM_TARGET_CPU=I80X86 -DSTRICT_ALIGNMENT -D_FILE_OFFSET_BITS=64 -isystem/vobs/buildtools/linux-i386/fiery_debian/usr/include -isystem/vobs/linuxdev/xdev/usr/include -cxxlib-gcc=/vobs/buildtools/linux-i386/gcc-4.1.2 -L/vobs/buildtools/linux-i386/icc-10.1/lib -L/vobs/linuxdev/xdev/usr/lib -L/vobs/linuxdev/xdev/lib -Wl,-rpath-link,/vobs/linuxdev/xdev/lib -Wl,-rpath-link,/vobs/linuxdev/xdev/usr/lib -Wl,-rpath-link,/vobs/linuxdev/xdev/usr/X11R6/lib -D_linux -fp -Wl,--allow-multiple-definition -Wl,-Bsymbolic -Wl,--warn-once -I"../../../../ExternalLibs/Sqlite_3_31_1/include/external" -I"../../../../ExternalLibs/Sqlite_3_31_1/include/internal" -c ../src/sqlite3.c -o Build/Linux/release/sqlite-3.31.1/sqlite3.o

Compiler used to create Shared object which is same as my Project compiler used to create binary:

/vobs/buildtools/linux-i386/icc-10.1/bin/icpc -shared -o libsqlite-3.31.1.so ./Build/Linux/release/sqlite-3.31.1/sqlite3.o

Regards Kunal

(4) By anonymous on 2020-04-28 10:23:45 in reply to 1.0 [link] [source]

Searching the Internet for "icc __sync_synchronize" gives a few results. In particular, ICC 10 that you seem to be using doesn't have the __sync_synchronize() intrinsic (it was introduced in ICC 11), while SQLite source code tries to use it, seeing that the __GNUC__ preprocessor symbol is defined.

As a workaround, you can define the SQLITE_MEMORY_BARRIER preprocessor symbol to asm volatile("mfence":::"memory"). SQLite will see the symbol and use it instead of assuming that the compiler has __sync_synchronize().