0

I've compiled SQLiteCPP with no errors. Steps: clone SQLiteCPP, build.sh, cd build, make, make all, sudo make install

I've verified that the files have copied to /usr/local/include

I'm including it all in my task.json:

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: g++ build active file",
            "command": "/usr/bin/g++",
            "args": [
                "-fdiagnostics-color=always",
                "-fsanitize=address",
                "-I/usr/local/include/",
                "-I/usr/local/lib/wx/include/gtk3-unicode-3.2",
                 "-I/usr/local/include/wx-3.2", 
                 "-D_FILE_OFFSET_BITS=64",
                  "-DWXUSINGDLL", 
                  "-D__WXGTK__", 
                  "-pthread",
                "-g3",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}",
                "-L/usr/local/lib", 
                "-pthread",   
                "-lwx_gtk3u_xrc-3.2", 
                "-lwx_gtk3u_html-3.2", 
                "-lwx_gtk3u_qa-3.2", 
                "-lwx_gtk3u_core-3.2", 
                "-lwx_baseu_xml-3.2", 
                "-lwx_baseu_net-3.2", 
                "-lwx_baseu-3.2",
                "-lsqlite3",
                "-lSQLiteCpp"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}

The output of compile:

Starting build...
/usr/bin/g++ -fdiagnostics-color=always -fsanitize=address -I/usr/local/include/ -I/usr/local/lib/wx/include/gtk3-unicode-3.2 -I/usr/local/include/wx-3.2 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread -g3 /home/me/src/no_cmake/src/main.cpp -o /home/me/src/no_cmake/src/main -L/usr/local/lib -pthread -lwx_gtk3u_xrc-3.2 -lwx_gtk3u_html-3.2 -lwx_gtk3u_qa-3.2 -lwx_gtk3u_core-3.2 -lwx_baseu_xml-3.2 -lwx_baseu_net-3.2 -lwx_baseu-3.2 -lsqlite3 -lSQLiteCpp
/usr/bin/ld: /usr/local/lib/libSQLiteCpp.a(Database.cpp.o): in function `SQLite::getLibVersion()':
/home/me/src/SQLiteCpp/src/Database.cpp:52: undefined reference to `sqlite3_libversion'
/usr/bin/ld: /usr/local/lib/libSQLiteCpp.a(Database.cpp.o): in function `SQLite::getLibVersionNumber()':
/home/me/src/SQLiteCpp/src/Database.cpp:58: undefined reference to `sqlite3_libversion_number'

It looks like I'm linking everything correctly? But I'm new to C++ so...

edit: On SQLiteCPP's git, I see this in the cmake file: set(SQLITECPP_RUN_CPPCHECK OFF CACHE BOOL "" FORCE) set(SQLITECPP_RUN_CPPLINT OFF CACHE BOOL "" FORCE) set(SQLITECPP_USE_STATIC_RUNTIME OFF CACHE BOOL "" FORCE)

Do I somehow need to set that during compile? I wasn't sure how and trying not to use cmake for this.

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
Chemdream
  • 618
  • 2
  • 9
  • 25
  • 2
    I would try switching the order of the last two libraries. `-lSQLiteCpp` looks like a C++ wrapper for a C interface from `-lsqlite3`, so it should be linked to first. – Sam Varshavchik Dec 13 '22 at 21:12
  • [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Jesper Juhl Dec 13 '22 at 22:21
  • @SamVarshavchik that worked! Because SQLiteCpp is a wrapper, I assumed it needed sqlite3 first. – Chemdream Dec 14 '22 at 14:27
  • The whole point of having a library is to pull in only what's needed. Your poor linker has no idea what `SQLiteCpp` needs from `sqlite3`, because the libraries get linked in the given order. Each library provides whatever it has, that something needs and hasn't beenr resolved yet. – Sam Varshavchik Dec 14 '22 at 14:32

0 Answers0