0

I met a weird problem. I can not link against sqlite3 lib (with a fresh installation of conan). I am trying to add sqlite3 to a project of mine that already contain a lot of boost code, but this the first time I met this kind of error.

int main(int argc, char *const argv[])
{
    sqlite3 *dbb = NULL;
    sqlite3_open("esrerer", &dbb);
}

This is the error message I receive :

main.cpp.obj : error LNK2019: unresolved external symbol_sqlite3_open referred in function main

I use conan for the lib :

[requires]
boost/1.71.0@conan/stable
sqlite3/3.29.0@bincrafters/stable

[generators]
cmake

And just in case, the content of my cmake:

cmake_minimum_required(VERSION 3.14)
project(project)

set(CMAKE_CXX_STANDARD 14)
include_directories(Server/include)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
find_package(sqlite3 REQUIRED)

add_executable(project Server/src/main.cpp)
target_link_libraries(project ${CONAN_LIBS})

EDIT : conan profile

[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=Visual Studio
compiler.runtime=MD
compiler.version=16
os=Windows
os_build=Windows
[options]
[build_requires]
[env]

1 Answers1

0

You want to find SQLITE3 as CMake module but you need to consider two things:

  • The Conan package which provides sqlite3 has a cmake there? You can check it by looking into the package folder:

    conan info --paths sqlite3/3.29.0@bincrafters/stable

    ls /home/user/.conan/data/sqlite3/3.29.0/bincrafters/stable/package/6745b2c67ece017487d93454786f9082519559e7/

There is a Find CMake file there, but as you can see, it's camel cased and if you are running on Unix system, you know the file name is case sensitive. So you need to change your find_package statement:

find_package(SQLite3 REQUIRED)
  • Conan packages in general don't provide any CMake file, because Conan is able to generate them:

https://docs.conan.io/en/latest/integrations/build_system/cmake.html

So, in your case, you can use cmake_find_package + cmake:

[requires]
boost/1.71.0@conan/stable
sqlite3/3.29.0@bincrafters/stable

[generators]
cmake
cmake_find_package

The find cmake file generated will use the same name from the recipe:

Findsqlite3.cmake

Regards!

uilianries
  • 3,363
  • 15
  • 28
  • Conan does not seem to be the problem. Just for curiosity, I compile myself sqlite3 library and still, the linker problem appear. It appear that whatever the way the library is linked it can not find the functions symbols, which is weird. – Michael Vouriz Sep 18 '19 at 11:45
  • Could your share what steps are your running? sqlite3 is good by Appveyor status, so it's very specific on your side. I need more details to reproduce your problem. Could you please share your entire log (including commands and all cmake output). – uilianries Sep 18 '19 at 16:33
  • I can't reproduce your error. Here is my entire log: https://gist.github.com/uilianries/4cca93b2cc0772d13913d899bc789901 – uilianries Sep 18 '19 at 18:44