loading extension csv.c

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

loading extension csv.c

chiahui chen
Hi,

After few attempts to load csv extension, (already tried

    gcc -arch x86_64 -g -fPIC -dynamiclib csv.c -o csv.dylib

and

    gcc  -g -fPIC -dynamiclib csv.c -o csv.dylib
)
Mac terminal returns errors as followings:

csv.c:115:3: error: no member named '__builtin___vsnprintf_chk' in 'struct
sqlite3_api_routines'

  sqlite3_vsnprintf(CSV_MXERR, p->zErr, zFormat, ap);

  ^~~~~~~~~~~~~~~~~

/usr/include/sqlite3ext.h:437:53: note: expanded from macro
'sqlite3_vsnprintf'

#define sqlite3_vsnprintf              sqlite3_api->vsnprintf

                                       ~~~~~~~~~~~  ^

/usr/include/secure/_stdio.h:75:3: note: expanded from macro 'vsnprintf'

  __builtin___vsnprintf_chk (str, len, 0, __darwin_obsz(str), format, ap)

  ^

csv.c:115:21: warning: incompatible integer to pointer conversion passing
'int' to parameter of type 'const void *' [-Wint-conversion]

  sqlite3_vsnprintf(CSV_MXERR, p->zErr, zFormat, ap);

                    ^~~~~~~~~

csv.c:67:19: note: expanded from macro 'CSV_MXERR'

#define CSV_MXERR 200

                  ^~~

/usr/include/secure/_stdio.h:75:57: note: expanded from macro 'vsnprintf'

  __builtin___vsnprintf_chk (str, len, 0, __darwin_obsz(str), format, ap)

                                                        ^~~

/usr/include/secure/_common.h:39:54: note: expanded from macro
'__darwin_obsz'

#define __darwin_obsz(object) __builtin_object_size (object,
_USE_FORTIFY_LEVEL > 1 ? 1 : 0)

                                                     ^~~~~~

csv.c:568:5: error: use of undeclared identifier 'sqlite3_str'

    sqlite3_str *pStr = sqlite3_str_new(0);

    ^

csv.c:568:18: error: use of undeclared identifier 'pStr'

    sqlite3_str *pStr = sqlite3_str_new(0);

                 ^

csv.c:568:25: warning: implicit declaration of function 'sqlite3_str_new'
is invalid in C99 [-Wimplicit-function-declaration]

    sqlite3_str *pStr = sqlite3_str_new(0);

                        ^

csv.c:571:5: warning: implicit declaration of function
'sqlite3_str_appendf' is invalid in C99 [-Wimplicit-function-declaration]

    sqlite3_str_appendf(pStr, "CREATE TABLE x(");

    ^

csv.c:571:25: error: use of undeclared identifier 'pStr'

    sqlite3_str_appendf(pStr, "CREATE TABLE x(");

                        ^

csv.c:581:29: error: use of undeclared identifier 'pStr'

        sqlite3_str_appendf(pStr, "%sc%d TEXT", zSep, iCol);

                            ^

csv.c:588:31: error: use of undeclared identifier 'pStr'

          sqlite3_str_appendf(pStr,"%s\"%w\" TEXT", zSep, z);

                              ^

csv.c:597:31: error: use of undeclared identifier 'pStr'

          sqlite3_str_appendf(pStr,"%sc%d TEXT", zSep, ++iCol);

                              ^

csv.c:603:25: error: use of undeclared identifier 'pStr'

    sqlite3_str_appendf(pStr, ")");

                        ^

csv.c:604:18: warning: implicit declaration of function
'sqlite3_str_finish' is invalid in C99 [-Wimplicit-function-declaration]

    CSV_SCHEMA = sqlite3_str_finish(pStr);

                 ^

csv.c:604:37: error: use of undeclared identifier 'pStr'

    CSV_SCHEMA = sqlite3_str_finish(pStr);

                                    ^

csv.c:643:27: error: use of undeclared identifier 'SQLITE_VTAB_DIRECTONLY'

  sqlite3_vtab_config(db, SQLITE_VTAB_DIRECTONLY);

                          ^

4 warnings and 10 errors generated.

Can someone kindly explain why?
Is there any other step /modification required or even change needed to be
made, prior to compiling or loading an extension in general?

In case there is something I missed while compiling sqlite, here is how I
initially compiled it:

cc -DSQLITE_SOUNDEX -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS5
-DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_RTREE -o sqlite3
shell.c sqlite3.c

Thank you in advance.

Osman
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: loading extension csv.c

Richard Hipp-3
On 2/6/20, chiahui chen <[hidden email]> wrote:

> Hi,
>
> After few attempts to load csv extension, (already tried
>
>     gcc -arch x86_64 -g -fPIC -dynamiclib csv.c -o csv.dylib
>
> and
>
>     gcc  -g -fPIC -dynamiclib csv.c -o csv.dylib
> )
> Mac terminal returns errors as followings:

I don't know what is causing your errors.  But I can show you what
works for me, on a Mac:

(1) Unpack the SQLite source-code tarball for version 3.31.1

(2) Run:  ./configure && make

(3) Run:  gcc -g -I. -fPIC -dynamiclib ext/misc/csv.c -o csv.dylib

(4) Run: ./sqlite3

(5) Within the SQLite command-line shell, do:  .load ./csv

I suspect that the -I. is the option that you need, so that the build
will pick up a proper sqlite3ext.h file, and not whatever sqlite3ext.h
file that Apple has installed.  But that is just my guess.

--
D. Richard Hipp
[hidden email]
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: loading extension csv.c

chiahui chen
Hi Dr. Hipp,

Thank you very much. I tried the suggested solution. sqlite3 was
downloaded  and compiled.
Then ran : gcc -g -l. -fPIC -dynamiclib ./ext/csv.c -o csv.dylib
the same errors occurred again.

./ext/csv.c:115:3: error: no member named '__builtin___vsnprintf_chk' in
'struct sqlite3_api_routines'

  sqlite3_vsnprintf(CSV_MXERR, p->zErr, zFormat, ap);

  ^~~~~~~~~~~~~~~~~

/usr/include/sqlite3ext.h:437:53: note: expanded from macro
'sqlite3_vsnprintf'

#define sqlite3_vsnprintf              sqlite3_api->vsnprintf

                                       ~~~~~~~~~~~  ^

/usr/include/secure/_stdio.h:75:3: note: expanded from macro 'vsnprintf'

  __builtin___vsnprintf_chk (str, len, 0, __darwin_obsz(str), format, ap)

  ^

./ext/csv.c:115:21: warning: incompatible integer to pointer conversion
passing 'int' to parameter of type

      'const void *' [-Wint-conversion]

  sqlite3_vsnprintf(CSV_MXERR, p->zErr, zFormat, ap);

                    ^~~~~~~~~

./ext/csv.c:67:19: note: expanded from macro 'CSV_MXERR'

#define CSV_MXERR 200

                  ^~~

/usr/include/secure/_stdio.h:75:57: note: expanded from macro 'vsnprintf'

  __builtin___vsnprintf_chk (str, len, 0, __darwin_obsz(str), format, ap)

                                                        ^~~

/usr/include/secure/_common.h:39:54: note: expanded from macro
'__darwin_obsz'

#define __darwin_obsz(object) __builtin_object_size (object,
_USE_FORTIFY_LEVEL > 1 ? 1 : 0)

                                                     ^~~~~~

./ext/csv.c:568:5: error: use of undeclared identifier 'sqlite3_str'

    sqlite3_str *pStr = sqlite3_str_new(0);

    ^

./ext/csv.c:568:18: error: use of undeclared identifier 'pStr'

    sqlite3_str *pStr = sqlite3_str_new(0);

                 ^

./ext/csv.c:568:25: warning: implicit declaration of function
'sqlite3_str_new' is invalid in C99

      [-Wimplicit-function-declaration]

    sqlite3_str *pStr = sqlite3_str_new(0);

                        ^

./ext/csv.c:571:5: warning: implicit declaration of function
'sqlite3_str_appendf' is invalid in C99

      [-Wimplicit-function-declaration]

    sqlite3_str_appendf(pStr, "CREATE TABLE x(");

    ^

./ext/csv.c:571:25: error: use of undeclared identifier 'pStr'

    sqlite3_str_appendf(pStr, "CREATE TABLE x(");

                        ^

./ext/csv.c:581:29: error: use of undeclared identifier 'pStr'

        sqlite3_str_appendf(pStr, "%sc%d TEXT", zSep, iCol);

                            ^

./ext/csv.c:588:31: error: use of undeclared identifier 'pStr'

          sqlite3_str_appendf(pStr,"%s\"%w\" TEXT", zSep, z);

                              ^

./ext/csv.c:597:31: error: use of undeclared identifier 'pStr'

          sqlite3_str_appendf(pStr,"%sc%d TEXT", zSep, ++iCol);

                              ^

./ext/csv.c:603:25: error: use of undeclared identifier 'pStr'

    sqlite3_str_appendf(pStr, ")");

                        ^

./ext/csv.c:604:18: warning: implicit declaration of function
'sqlite3_str_finish' is invalid in C99

      [-Wimplicit-function-declaration]

    CSV_SCHEMA = sqlite3_str_finish(pStr);

                 ^

./ext/csv.c:604:37: error: use of undeclared identifier 'pStr'

    CSV_SCHEMA = sqlite3_str_finish(pStr);

                                    ^

./ext/csv.c:643:27: error: use of undeclared identifier
'SQLITE_VTAB_DIRECTONLY'

  sqlite3_vtab_config(db, SQLITE_VTAB_DIRECTONLY);

                          ^

4 warnings and 10 errors generated.

Here is Mac terminal sqlite3 compiling process if it can shed light on the
extension compiling errors.

./configure && make

checking for a BSD-compatible install... /usr/bin/install -c

checking whether build environment is sane... yes

checking for a thread-safe mkdir -p... ./install-sh -c -d

checking for gawk... no

checking for mawk... no

checking for nawk... no

checking for awk... awk

checking whether make sets $(MAKE)... yes

checking whether make supports nested variables... yes

checking for style of include used by make... GNU

checking for gcc... gcc

checking whether the C compiler works... yes

checking for C compiler default output file name... a.out

checking for suffix of executables...

checking whether we are cross compiling... no

checking for suffix of object files... o

checking whether we are using the GNU C compiler... yes

checking whether gcc accepts -g... yes

checking for gcc option to accept ISO C89... none needed

checking whether gcc understands -c and -o together... yes

checking dependency style of gcc... gcc3

checking for special C compiler options needed for large files... no

checking for _FILE_OFFSET_BITS value needed for large files... no

checking for gcc... (cached) gcc

checking whether we are using the GNU C compiler... (cached) yes

checking whether gcc accepts -g... (cached) yes

checking for gcc option to accept ISO C89... (cached) none needed

checking whether gcc understands -c and -o together... (cached) yes

checking dependency style of gcc... (cached) gcc3

checking build system type... x86_64-apple-darwin17.7.0

checking host system type... x86_64-apple-darwin17.7.0

checking how to print strings... printf

checking for a sed that does not truncate output... /usr/bin/sed

checking for grep that handles long lines and -e... /usr/bin/grep

checking for egrep... /usr/bin/grep -E

checking for fgrep... /usr/bin/grep -F

checking for ld used by gcc...
/Library/Developer/CommandLineTools/usr/bin/ld

checking if the linker (/Library/Developer/CommandLineTools/usr/bin/ld) is
GNU ld... no

checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B

checking the name lister (/usr/bin/nm -B) interface... BSD nm

checking whether ln -s works... yes

checking the maximum length of command line arguments... 196608

checking how to convert x86_64-apple-darwin17.7.0 file names to
x86_64-apple-darwin17.7.0 format... func_convert_file_noop

checking how to convert x86_64-apple-darwin17.7.0 file names to toolchain
format... func_convert_file_noop

checking for /Library/Developer/CommandLineTools/usr/bin/ld option to
reload object files... -r

checking for objdump... objdump

checking how to recognize dependent libraries... pass_all

checking for dlltool... no

checking how to associate runtime and link libraries... printf %s\n

checking for ar... ar

checking for archiver @FILE support... no

checking for strip... strip

checking for ranlib... ranlib

checking command to parse /usr/bin/nm -B output from gcc object... ok

checking for sysroot... no

checking for a working dd... /bin/dd

checking how to truncate binary pipes... /bin/dd bs=4096 count=1

checking for mt... no

checking if : is a manifest tool... no

checking for dsymutil... dsymutil

checking for nmedit... nmedit

checking for lipo... lipo

checking for otool... otool

checking for otool64... no

checking for -single_module linker flag... yes

checking for -exported_symbols_list linker flag... yes

checking for -force_load linker flag... yes

checking how to run the C preprocessor... gcc -E

checking for ANSI C header files... yes

checking for sys/types.h... yes

checking for sys/stat.h... yes

checking for stdlib.h... yes

checking for string.h... yes

checking for memory.h... yes

checking for strings.h... yes

checking for inttypes.h... yes

checking for stdint.h... yes

checking for unistd.h... yes

checking for dlfcn.h... yes

checking for objdir... .libs

checking if gcc supports -fno-rtti -fno-exceptions... yes

checking for gcc option to produce PIC... -fno-common -DPIC

checking if gcc PIC flag -fno-common -DPIC works... yes

checking if gcc static flag -static works... no

checking if gcc supports -c -o file.o... yes

checking if gcc supports -c -o file.o... (cached) yes

checking whether the gcc linker
(/Library/Developer/CommandLineTools/usr/bin/ld) supports shared
libraries... yes

checking dynamic linker characteristics... darwin17.7.0 dyld

checking how to hardcode library paths into programs... immediate

checking whether stripping libraries is possible... yes

checking if libtool supports shared libraries... yes

checking whether to build shared libraries... yes

checking whether to build static libraries... yes

checking for fdatasync... yes

checking for usleep... yes

checking for fullfsync... no

checking for localtime_r... yes

checking for gmtime_r... yes

checking whether strerror_r is declared... yes

checking for strerror_r... yes

checking whether strerror_r returns char *... no

checking editline/readline.h usability... yes

checking editline/readline.h presence... yes

checking for editline/readline.h... yes

checking for library containing readline... no

checking readline/readline.h usability... yes

checking readline/readline.h presence... yes

checking for readline/readline.h... yes

checking for library containing tgetent... -ltermcap

checking for library containing readline... -lreadline

checking for library containing pthread_create... none required

checking for library containing pthread_mutexattr_init... none required

checking for library containing dlopen... none required

checking for whether to support dynamic extensions... yes

checking for library containing log... none required

checking for posix_fallocate... no

checking zlib.h usability... yes

checking zlib.h presence... yes

checking for zlib.h... yes

checking for library containing deflate... -lz

checking for library containing system... none required

checking that generated files are newer than configure... done

configure: creating ./config.status

config.status: creating Makefile

config.status: creating sqlite3.pc

config.status: executing depfiles commands

config.status: executing libtool commands

/bin/sh ./libtool  --tag=CC   --mode=compile gcc -DPACKAGE_NAME=\"sqlite\"
-DPACKAGE_TARNAME=\"sqlite\" -DPACKAGE_VERSION=\"3.31.1\"
-DPACKAGE_STRING=\"sqlite\ 3.31.1\" -DPACKAGE_BUGREPORT=\"
http://www.sqlite.org\" -DPACKAGE_URL=\"\" -DPACKAGE=\"sqlite\"
-DVERSION=\"3.31.1\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1
-DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1
-DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1
-DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE_FDATASYNC=1 -DHAVE_USLEEP=1
-DHAVE_LOCALTIME_R=1 -DHAVE_GMTIME_R=1 -DHAVE_DECL_STRERROR_R=1
-DHAVE_STRERROR_R=1 -DHAVE_EDITLINE_READLINE_H=1
-DHAVE_READLINE_READLINE_H=1 -DHAVE_READLINE=1 -DHAVE_ZLIB_H=1 -I.
-D_REENTRANT=1
-DSQLITE_THREADSAFE=1 -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5
-DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_GEOPOLY
-DSQLITE_HAVE_ZLIB  -g -O2 -MT sqlite3.lo -MD -MP -MF .deps/sqlite3.Tpo -c
-o sqlite3.lo sqlite3.c

libtool: compile:  gcc -DPACKAGE_NAME=\"sqlite\"
-DPACKAGE_TARNAME=\"sqlite\" -DPACKAGE_VERSION=\"3.31.1\"
"-DPACKAGE_STRING=\"sqlite 3.31.1\"" -DPACKAGE_BUGREPORT=\"
http://www.sqlite.org\" -DPACKAGE_URL=\"\" -DPACKAGE=\"sqlite\"
-DVERSION=\"3.31.1\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1
-DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1
-DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1
-DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE_FDATASYNC=1 -DHAVE_USLEEP=1
-DHAVE_LOCALTIME_R=1 -DHAVE_GMTIME_R=1 -DHAVE_DECL_STRERROR_R=1
-DHAVE_STRERROR_R=1 -DHAVE_EDITLINE_READLINE_H=1
-DHAVE_READLINE_READLINE_H=1 -DHAVE_READLINE=1 -DHAVE_ZLIB_H=1 -I.
-D_REENTRANT=1 -DSQLITE_THREADSAFE=1 -DSQLITE_ENABLE_FTS4
-DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_RTREE
-DSQLITE_ENABLE_GEOPOLY -DSQLITE_HAVE_ZLIB -g -O2 -MT sqlite3.lo -MD -MP
-MF .deps/sqlite3.Tpo -c sqlite3.c  -fno-common -DPIC -o .libs/sqlite3.o

libtool: compile:  gcc -DPACKAGE_NAME=\"sqlite\"
-DPACKAGE_TARNAME=\"sqlite\" -DPACKAGE_VERSION=\"3.31.1\"
"-DPACKAGE_STRING=\"sqlite 3.31.1\"" -DPACKAGE_BUGREPORT=\"
http://www.sqlite.org\" -DPACKAGE_URL=\"\" -DPACKAGE=\"sqlite\"
-DVERSION=\"3.31.1\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1
-DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1
-DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1
-DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE_FDATASYNC=1 -DHAVE_USLEEP=1
-DHAVE_LOCALTIME_R=1 -DHAVE_GMTIME_R=1 -DHAVE_DECL_STRERROR_R=1
-DHAVE_STRERROR_R=1 -DHAVE_EDITLINE_READLINE_H=1
-DHAVE_READLINE_READLINE_H=1 -DHAVE_READLINE=1 -DHAVE_ZLIB_H=1 -I.
-D_REENTRANT=1 -DSQLITE_THREADSAFE=1 -DSQLITE_ENABLE_FTS4
-DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_RTREE
-DSQLITE_ENABLE_GEOPOLY -DSQLITE_HAVE_ZLIB -g -O2 -MT sqlite3.lo -MD -MP
-MF .deps/sqlite3.Tpo -c sqlite3.c -o sqlite3.o >/dev/null 2>&1

mv -f .deps/sqlite3.Tpo .deps/sqlite3.Plo

/bin/sh ./libtool  --tag=CC   --mode=link gcc -D_REENTRANT=1
-DSQLITE_THREADSAFE=1 -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5
-DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_GEOPOLY
-DSQLITE_HAVE_ZLIB  -g -O2 -no-undefined -version-info 8:6:8  -o
libsqlite3.la -rpath /usr/local/lib sqlite3.lo  -lz

libtool: link: gcc -dynamiclib  -o .libs/libsqlite3.0.dylib  .libs/sqlite3.o
  -lz  -g -O2   -install_name  /usr/local/lib/libsqlite3.0.dylib
-compatibility_version 9 -current_version 9.6 -Wl,-single_module

libtool: link: (cd ".libs" && rm -f "libsqlite3.dylib" && ln -s
"libsqlite3.0.dylib" "libsqlite3.dylib")

libtool: link: ar cru .libs/libsqlite3.a  sqlite3.o

libtool: link: ranlib .libs/libsqlite3.a

libtool: link: ( cd ".libs" && rm -f "libsqlite3.la" && ln -s "../
libsqlite3.la" "libsqlite3.la" )

gcc -DPACKAGE_NAME=\"sqlite\" -DPACKAGE_TARNAME=\"sqlite\"
-DPACKAGE_VERSION=\"3.31.1\" -DPACKAGE_STRING=\"sqlite\ 3.31.1\"
-DPACKAGE_BUGREPORT=\"http://www.sqlite.org\" -DPACKAGE_URL=\"\"
-DPACKAGE=\"sqlite\" -DVERSION=\"3.31.1\" -DSTDC_HEADERS=1
-DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1
-DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1
-DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\"
-DHAVE_FDATASYNC=1 -DHAVE_USLEEP=1 -DHAVE_LOCALTIME_R=1 -DHAVE_GMTIME_R=1
-DHAVE_DECL_STRERROR_R=1 -DHAVE_STRERROR_R=1 -DHAVE_EDITLINE_READLINE_H=1
-DHAVE_READLINE_READLINE_H=1 -DHAVE_READLINE=1 -DHAVE_ZLIB_H=1 -I.
-D_REENTRANT=1
-DSQLITE_THREADSAFE=1 -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5
-DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_GEOPOLY
-DSQLITE_HAVE_ZLIB  -DSQLITE_ENABLE_EXPLAIN_COMMENTS
-DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_ENABLE_STMTVTAB
-DSQLITE_ENABLE_DBSTAT_VTAB  -g -O2 -MT sqlite3-shell.o -MD -MP -MF
.deps/sqlite3-shell.Tpo -c -o sqlite3-shell.o `test -f 'shell.c' || echo
'./'`shell.c

mv -f .deps/sqlite3-shell.Tpo .deps/sqlite3-shell.Po

gcc -DPACKAGE_NAME=\"sqlite\" -DPACKAGE_TARNAME=\"sqlite\"
-DPACKAGE_VERSION=\"3.31.1\" -DPACKAGE_STRING=\"sqlite\ 3.31.1\"
-DPACKAGE_BUGREPORT=\"http://www.sqlite.org\" -DPACKAGE_URL=\"\"
-DPACKAGE=\"sqlite\" -DVERSION=\"3.31.1\" -DSTDC_HEADERS=1
-DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1
-DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1
-DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\"
-DHAVE_FDATASYNC=1 -DHAVE_USLEEP=1 -DHAVE_LOCALTIME_R=1 -DHAVE_GMTIME_R=1
-DHAVE_DECL_STRERROR_R=1 -DHAVE_STRERROR_R=1 -DHAVE_EDITLINE_READLINE_H=1
-DHAVE_READLINE_READLINE_H=1 -DHAVE_READLINE=1 -DHAVE_ZLIB_H=1 -I.
-D_REENTRANT=1
-DSQLITE_THREADSAFE=1 -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5
-DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_GEOPOLY
-DSQLITE_HAVE_ZLIB  -DSQLITE_ENABLE_EXPLAIN_COMMENTS
-DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_ENABLE_STMTVTAB
-DSQLITE_ENABLE_DBSTAT_VTAB  -g -O2 -MT sqlite3-sqlite3.o -MD -MP -MF
.deps/sqlite3-sqlite3.Tpo -c -o sqlite3-sqlite3.o `test -f 'sqlite3.c' ||
echo './'`sqlite3.c

mv -f .deps/sqlite3-sqlite3.Tpo .deps/sqlite3-sqlite3.Po

/bin/sh ./libtool  --tag=CC   --mode=link gcc -D_REENTRANT=1
-DSQLITE_THREADSAFE=1 -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5
-DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_GEOPOLY
-DSQLITE_HAVE_ZLIB  -DSQLITE_ENABLE_EXPLAIN_COMMENTS
-DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_ENABLE_STMTVTAB
-DSQLITE_ENABLE_DBSTAT_VTAB  -g -O2   -o sqlite3 sqlite3-shell.o
sqlite3-sqlite3.o -lreadline -ltermcap  -lz

libtool: link: gcc -D_REENTRANT=1 -DSQLITE_THREADSAFE=1
-DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_JSON1
-DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_GEOPOLY -DSQLITE_HAVE_ZLIB
-DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_DBPAGE_VTAB
-DSQLITE_ENABLE_STMTVTAB -DSQLITE_ENABLE_DBSTAT_VTAB -g -O2 -o sqlite3
sqlite3-shell.o sqlite3-sqlite3.o  -lreadline -ltermcap -lz


Is there any suggestion? Just in case if my Mac operating system provides
some info (macOS High Sierra version 10.13.6)


Thank you in advance.


Appreciated,

Osman

On Thu, Feb 6, 2020 at 12:38 PM Richard Hipp <[hidden email]> wrote:

> On 2/6/20, chiahui chen <[hidden email]> wrote:
> > Hi,
> >
> > After few attempts to load csv extension, (already tried
> >
> >     gcc -arch x86_64 -g -fPIC -dynamiclib csv.c -o csv.dylib
> >
> > and
> >
> >     gcc  -g -fPIC -dynamiclib csv.c -o csv.dylib
> > )
> > Mac terminal returns errors as followings:
>
> I don't know what is causing your errors.  But I can show you what
> works for me, on a Mac:
>
> (1) Unpack the SQLite source-code tarball for version 3.31.1
>
> (2) Run:  ./configure && make
>
> (3) Run:  gcc -g -I. -fPIC -dynamiclib ext/misc/csv.c -o csv.dylib
>
> (4) Run: ./sqlite3
>
> (5) Within the SQLite command-line shell, do:  .load ./csv
>
> I suspect that the -I. is the option that you need, so that the build
> will pick up a proper sqlite3ext.h file, and not whatever sqlite3ext.h
> file that Apple has installed.  But that is just my guess.
>
> --
> D. Richard Hipp
> [hidden email]
>
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: loading extension csv.c

Richard Hipp-3
On 2/7/20, chiahui chen <[hidden email]> wrote:
>
> I tried the suggested solution. sqlite3 was
> downloaded  and compiled.
> Then ran : gcc -g -l. -fPIC -dynamiclib ./ext/csv.c -o csv.dylib
> the same errors occurred again.
>
> Is there any suggestion? Just in case if my Mac operating system provides
> some info (macOS High Sierra version 10.13.6)
>

That command works fine for me on my iMac.  I have no idea why it is
failing for you.

--
D. Richard Hipp
[hidden email]
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: loading extension csv.c

Rolf Ade-2

> On 2/7/20, chiahui chen <[hidden email]> wrote:
>>
>> I tried the suggested solution. sqlite3 was
>> downloaded  and compiled.
>> Then ran : gcc -g -l. -fPIC -dynamiclib ./ext/csv.c -o csv.dylib
                     ^^^        

Is this a typo? This should read

gcc -I. ....

>> the same errors occurred again.
>>
>> Is there any suggestion? Just in case if my Mac operating system provides
>> some info (macOS High Sierra version 10.13.6)
>>
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: loading extension csv.c

Jens Alfke-2
In reply to this post by chiahui chen


> On Feb 7, 2020, at 9:11 AM, chiahui chen <[hidden email]> wrote:
>
> /usr/include/sqlite3ext.h:437:53: note: expanded from macro
> 'sqlite3_vsnprintf'
>
> #define sqlite3_vsnprintf              sqlite3_api->vsnprintf
>
>                                       ~~~~~~~~~~~  ^
>
> /usr/include/secure/_stdio.h:75:3: note: expanded from macro 'vsnprintf'
>
>  __builtin___vsnprintf_chk (str, len, 0, __darwin_obsz(str), format, ap)
>
>  ^

This appears to be your problem. The system header <secure/_stdio.h> is defining `vsnprintf` as a macro that expands to a compiler builtin. This is conflicting with a struct field named `vsnprintf` in the SQLite extension API.

I've never heard of <sys/_stdio.h> before, although it does exist in the macOS SDK. Looking through the normal <stdio.h>, it does include that header at the end:

        #if defined (__GNUC__) && _FORTIFY_SOURCE > 0 && !defined (__cplusplus)
        /* Security checking functions.  */
        #include <secure/_stdio.h>
        #endif

So it looks like the trigger is that you're somehow building with _FORTIFY_SOURCE defined, and the others are not.

Anyway, I think you could work around the problem by editing csv.c and inserting something like this at the top:
        #include <stdio.h>
        #undef vsnprintf
Or else figuring out how to turn off _FORTIFY_SOURCE.

—Jens

PS: Your use of `gcc` in the command line confused me briefly — turns out `gcc` on macOS is simply an alias for `cc`, so it invokes Clang. If you really want GCC for some reason you'd have to install it yourself and put it in your $PATH before /usr/bin.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: loading extension csv.c

Richard Damon
On 2/7/20 3:14 PM, Jens Alfke wrote:

>
>> On Feb 7, 2020, at 9:11 AM, chiahui chen <[hidden email]> wrote:
>>
>> /usr/include/sqlite3ext.h:437:53: note: expanded from macro
>> 'sqlite3_vsnprintf'
>>
>> #define sqlite3_vsnprintf              sqlite3_api->vsnprintf
>>
>>                                        ~~~~~~~~~~~  ^
>>
>> /usr/include/secure/_stdio.h:75:3: note: expanded from macro 'vsnprintf'
>>
>>   __builtin___vsnprintf_chk (str, len, 0, __darwin_obsz(str), format, ap)
>>
>>   ^
> This appears to be your problem. The system header <secure/_stdio.h> is defining `vsnprintf` as a macro that expands to a compiler builtin. This is conflicting with a struct field named `vsnprintf` in the SQLite extension API.
>
> I've never heard of <sys/_stdio.h> before, although it does exist in the macOS SDK. Looking through the normal <stdio.h>, it does include that header at the end:
>
> #if defined (__GNUC__) && _FORTIFY_SOURCE > 0 && !defined (__cplusplus)
> /* Security checking functions.  */
> #include <secure/_stdio.h>
> #endif
>
> So it looks like the trigger is that you're somehow building with _FORTIFY_SOURCE defined, and the others are not.
>
> Anyway, I think you could work around the problem by editing csv.c and inserting something like this at the top:
> #include <stdio.h>
> #undef vsnprintf
> Or else figuring out how to turn off _FORTIFY_SOURCE.
>
> —Jens
>
> PS: Your use of `gcc` in the command line confused me briefly — turns out `gcc` on macOS is simply an alias for `cc`, so it invokes Clang. If you really want GCC for some reason you'd have to install it yourself and put it in your $PATH before /usr/bin.
>
It looks like that header (sys/_stdio.h) is non-conforming. The C
Standard does allow the stdio.h header to define a macro for the name
vsnprintf, but that macro must be a *function-like* macro (7.1.4p1 in
the C17 Standard) which it appears not to be (as that shouldn't cause a
problem with the shown code).

--
Richard Damon

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users