sqlite3 - Linker error with CMake -
i'm using jetbrains clion pure c (c ansi) development, know it's target c++, company works c , clion uses cmake build system.
my system debian jessie system , sqlite3 , libsqlite3-dev installed.
i'm trying build simple sqlite3 project this:
#include <sqlite3.h> #include <stdio.h> int main() { sqlite3 *sqlconnection; int ret; ret = sqlite3_open("database/path.db, &sqlconnection); if (ret) { printf("ups ... can't open %d", ret); } do_some_queries(sqlconnection); return 0; }
the automatic generated cmakelists.txt follwing.
cmake_minimum_required(version 3.3) project(project) set(cmake_cxx_flags "${cmake_cxx_flags} -std=c++11") set(source_files main.cpp ) add_executable(project ${source_files})
when build, either through clion, either through command line, linker errors:
... undefined reference `sqlite3_prepare_v2' undefined reference `sqlite3_column_int' undefined reference `sqlite3_open' ...
i know must point out cmake sqlite3 is, can't find way of doing this.
"find_package" , "find_library" may it, can't find how.
i've found this cmake file, not used successfully.
so, how integrate sqlite3 cmake ?
you need add path sqlite header file include path. link sqlite library using target_link_libraries
:
https://cmake.org/cmake/help/v3.3/command/target_link_libraries.html
Comments
Post a Comment