C/C++ undefined reference for sqlite3's functions using CLion with CMAKE

CMAKE's file has this code:

cmake_minimum_required(VERSION 3.6) 


set(SOURCE_FILES main.c)
add_executable(HelloSqliteC ${SOURCE_FILES})

The file main.c has this code:

#include <stdio.h>
#include <stdlib.h>
#include <sqlite3.h>

int main() {
   sqlite3 *db;
   int rc;

   rc = sqlite3_open("database.db", &db);

   if (rc) {
       fprintf(stderr, "Can't open database: %s!\n",      sqlite3_errmsg(db));
   } else {
       fprintf(stderr, "Opened database successfully!\n");

   return 0;

When I've trying compiling:

/home/marcus/ide/clion/clion-2016.3.1/bin/cmake/bin/cmake --build      /home/marcus/projects/native/HelloSqliteC/cmake-build-debug --target   HelloSqliteC -- -j 4
[ 50%] Building C object CMakeFiles/HelloSqliteC.dir/main.c.o
[100%] Linking C executable HelloSqliteC
CMakeFiles/HelloSqliteC.dir/main.c.o: In function `main':
/home/marcus/projects/native/HelloSqliteC/main.c:13: undefined reference to `sqlite3_open'
/home/marcus/projects/native/HelloSqliteC/main.c:16: undefined reference to `sqlite3_errmsg'
/home/marcus/projects/native/HelloSqliteC/main.c:21: undefined reference to `sqlite3_close'
collect2: error: ld returned 1 exit status
CMakeFiles/HelloSqliteC.dir/build.make:94: recipe for target     'HelloSqliteC' failed
make[3]: *** [HelloSqliteC] Error 1
CMakeFiles/Makefile2:67: recipe for target     'CMakeFiles/HelloSqliteC.dir/all' failed
make[2]: *** [CMakeFiles/HelloSqliteC.dir/all] Error 2
CMakeFiles/Makefile2:79: recipe for target     'CMakeFiles/HelloSqliteC.dir/rule' failed
make[1]: *** [CMakeFiles/HelloSqliteC.dir/rule] Error 2
Makefile:118: recipe for target 'HelloSqliteC' failed
make: *** [HelloSqliteC] Error 2

I tried solve this issue using different ways, but no success. I'm using CLion C/C++, my OS is Ubuntu 16.04 and I install sqlite3 using autoconf.

For test, I used the main.c above and compiled in command line with "-l sqlite3" using GCC and I had success, but I want use CLion.

Help me, thanks.

CLion uses CMake for all the building and project configuration. You have to manually modify CMakeLists.txt. In fact this is a CMake question.

This line in your CMakeLists.txt will solve your problem:

add_compile_options(-l sqlite3)

But actually CMake has a more sophisticated dependency discovery system. Read How To Find Libraries to learn this.

What is the meaning of CC in civil engineering?, ) is a unique proprietary material. It has a very wide range of applications throughout the building & civil engineering industry. C&C is listed in the World's largest and most authoritative dictionary database of abbreviations and acronyms. C&C - What does C&C stand for? The Free Dictionary.

I solved this issue with this target_link_libraries(HelloSqlite3 LINK_PUBLIC sqlite3) or target_link_libraries(projectName LINK_PUBLIC libraryName).

Genius, is what I try to keep myself, calm and collect, cool and calm. Remastered Features. Developed Alongside the C&C Community, the Command & Conquer Remastered Collection Delivers 4K Graphics, Rebuilt Multiplayer, Enhanced UI, the Completely Remastered Legendary Soundtrack by Frank Klepacki and More

I also use CLion C/C++. The OS is Ubuntu 18.04. But I want to compile the main.cpp. The CMakelist.txt is:

cmake_minimum_required(VERSION 3.13)

add_executable(student main.cpp)
target_link_libraries(ProjectName LINK_PUBLIC sqlite3)

It works successfully.

C+C Music Factory, was an American musical group formed in 1989 by David Cole and Robert Clivillés. The group is best known for their five hit singles: "Gonna Make You Sweat (Everybody Dance Now)", "Here We Go (Let's Rock & Roll)", "Things That Make You Go Hmmm", "Just a Touch of Love", and "Keep It Comin'". Classic Command & Conquer CnCNet is one of the largest Command & Conquer multiplayer platforms. It's time to welcome you back Commander, to Command & Conquer Online.

C/C, Looking for online definition of C/C or what C/C stands for? C/C is listed in the World's largest and most authoritative dictionary database of abbreviations and  You’ve had a moment of panic when trying to decide whether or not an item goes in the recycling bin.

C+C Music Factory, C & C Music Factory's official music video for 'Gonna Make You Sweat (​Everybody Dance Duration: 4:08 Posted: Oct 25, 2009 c+c is all about the good. Good, in terms of what comes from people’s hearts when not hindered by self-interest or demonic possession. Good, as it relates to campaigns that are 1) considerate towards the earth and the people living on it, and 2) inconsiderate towards things like coal trains making a polluted bummer out of said earth.

C+C Music Factory, C+C Music Factory - Everybody Dance Now (KaktuZ Remix) DJ KaktuZ: http://​promodj.com Duration: 4:50 Posted: Aug 19, 2018 At C&C we believe in giving you "Service With a Personal Touch." Our goal is to provide education, service, solutions and products that assist dealers and installers in the proper installation of floor covering while striving to have a positive impact on our environment.