SQLite Forum

Compiling without the amalgamation process
Login
Thanks a lot for that detailed answer. I understand better now why it wouldn't work.

I have replaced all definitions (`TCC` and `BCC`) in the Makefile from `g++` (which used to be `gcc` before I changed it) to `g++ -x none`. Unfortunately that has not changed anything, and I'm still getting the same errors.

After running `make clean`, and re-running `make -f Makefile.linux-gcc`, the errors I get are the following (I guess they're the errors from the first targets):

```
../sqlite/tool/lemon.c:2286:40: error: assigning to 'Boolean' from incompatible type 'int'
          psp->prevrule->neverReduce = 1;
                                       ^
../sqlite/tool/lemon.c:2290:35: error: assigning to 'Boolean' from incompatible type 'int'
          psp->prevrule->noCode = 0;
                                  ^
480 warnings generated.
../sqlite/tool/lemon.c:2398:24: error: assigning to 'Boolean' from incompatible type 'int'
          rp->noCode = 1;
                       ^
../sqlite/tool/lemon.c:3732:18: error: assigning to 'Boolean' from incompatible type 'int'
    rp->noCode = 1;
                 ^
../sqlite/tool/lemon.c:3734:18: error: assigning to 'Boolean' from incompatible type 'int'
    rp->noCode = 0;
                 ^
../sqlite/tool/lemon.c:3750:20: error: assigning to 'Boolean' from incompatible type 'int'
      rp->noCode = 0;
                   ^
../sqlite/tool/lemon.c:3900:18: error: assigning to 'Boolean' from incompatible type 'int'
    rp->noCode = 0;
                 ^
../sqlite/tool/lemon.c:4428:32: error: assigning to 'Boolean' from incompatible type 'int'
        ap->x.rp->doesReduce = 1;
                               ^
../sqlite/tool/lemon.c:4743:28: error: assigning to 'Boolean' from incompatible type 'int'
        rp2->codeEmitted = 1;
                           ^
../sqlite/tool/lemon.c:4748:23: error: assigning to 'Boolean' from incompatible type 'int'
    rp->codeEmitted = 1;
                      ^
```

My diagnostic would be that `lemon` is simply not meant to be compiled with a C++ compiler, hence I should first compile it with `gcc` and only use a C++ compiler in a second time for the actual SQLite source.

So that's what I did: I changed `g++` back to `gcc` and re-ran `make`. I get these errors again (but I expect it, as I'm not linking the C++ standard library / using GCC):
 
```
212 warnings generated.
Undefined symbols for architecture x86_64:
  "std::__1::locale::use_facet(std::__1::locale::id&) const", referenced from:
      std::__1::ctype<char> const& std::__1::use_facet<std::__1::ctype<char> >(std::__1::locale const&) in libsqlite3.a(thomas.o)
  "std::__1::ios_base::getloc() const", referenced from:
      std::__1::basic_ios<char, std::__1::char_traits<char> >::widen(char) const in libsqlite3.a(thomas.o)
  "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__init(unsigned long, char)", referenced from:
      std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::basic_string(unsigned long, char) in libsqlite3.a(thomas.o)
  "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_string()", referenced from:
      std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> > std::__1::__pad_and_output<char, std::__1::char_traits<char> >(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >, char const*, char const*, char const*, std::__1::ios_base&, char) in libsqlite3.a(thomas.o)
  "std::__1::basic_ostream<char, std::__1::char_traits<char> >::put(char)", referenced from:
      std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::endl<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) in libsqlite3.a(thomas.o)
```

After changing back to `g++`:

```
BCC = g++ -x none -g -O0
TCC = g++ -x none -O0
```

I get several errors coming from compiling `shell.c`:

```
shell.c:817:12: error: assigning to 'char *' from incompatible type 'void *'
    p->z = realloc(p->z, p->nAlloc);
           ^~~~~~~~~~~~~~~~~~~~~~~~
shell.c:868:16: warning: conversion from string literal to 'char *' is deprecated [-Wc++11-compat-deprecated-writable-strings]
  char *zDiv = "(";
               ^
shell.c:888:12: warning: conversion from string literal to 'char *' is deprecated [-Wc++11-compat-deprecated-writable-strings]
    zDiv = ",";
           ^
shell.c:1883:5: error: no matching function for call to 'SHA3Update'
    SHA3Update(&cx, sqlite3_value_blob(argv[0]), nByte);
    ^~~~~~~~~~
shell.c:1793:13: note: candidate function not viable: cannot convert argument of incomplete type 'const void *' to 'const unsigned char *' for 2nd argument
static void SHA3Update(
            ^
shell.c:2037:34: error: cannot initialize a variable of type 'const unsigned char *' with an rvalue of type 'const void *'
            const unsigned char *z2 = sqlite3_column_blob(pStmt, i);
                                 ^    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

All the errors come from compiling the shell, though I don't know whether it is because it can't compile the shell or if it is because the shell is the first of several files that can't be compiled. 

Once again any suggestions are welcome.