I'm trying to run a short test with SQLite3. I can not run this program so simple! I have already researched solutions on the internet and none of them solved my problem. Follow the program, cmakelists and logs :
main.c
#include <stdio.h>
#include <pthread.h>
#include "sqlite3.h"
int main(void)
{
sqlite3 *db;
int rc;
rc = sqlite3_open("test.db", &db);
if( rc ){
fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
return 0;
}else{
fprintf(stderr, "Opened database successfully\n");
}
sqlite3_close(db);
return 1;
}
And the following CMakeLists.txt
find_package(Threads)
cmake_minimum_required(VERSION 3.0)
project(Testes)
add_definitions(-Wall -g -o -std-c11 -lpthread -lcppdb_sqlite3 -ldl)
add_executable(Testes main.c)
add_library(sqlite3 sqlite3.c)
target_link_libraries(Testes sqlite3)
target_link_libraries(Testes ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(Testes ${CMAKE_DL_LIBS})
CMakeError.log
Determining if files pthread.h exist failed with the following output:
Source:
/* */
#include <pthread.h>
int main(){return 0;}