-1

I have a C++ project developed in Ubuntu Linux. This C++ project is not written by me. Also, it runs under Ubuntu without any issues.

I am trying to compile the project under Windows 10 using GCC/G++ compiler and Visual Studio 2019 IDE. I am very close to success.

This project has the following lines in its CMakeList.txt file:

find_package(sqlite3)
if (SQLITE3_FOUND)
  message("Sqlite3 found")
  include_directories(${SQLite3_INCLUDE_DIRS})
  SET(CMAKE_CXX_FLAGS_RELEASE " -DSQLITE3 ${CMAKE_CXX_FLAGS_RELEASE}")
  SET(CMAKE_CXX_FLAGS_DEBUG " -DSQLITE3 ${CMAKE_CXX_FLAGS_DEBUG}")
  SET(CMAKE_EXE_LINKER_FLAGS "-lsqlite3")
  SET(CMAKE_SHARED_LINKER_FLAGS "-lsqlite3")
else()
  message("Sqlite3 not found")
endif (SQLITE3_FOUND)

I need lsqlite3. I found the source code but failed to compile it using GCC:

C:\Users\pc\Downloads\sqlite3\lsqlite3-master\lsqlite3-master>mingw32-make
FIND: Parameter format not correct
FIND: Parameter format not correct
luarocks make

Error: Please specify which rockspec file to use.
luarocks make

Error: Please specify which rockspec file to use.

C:\Users\pc\Downloads\sqlite3\lsqlite3-master\lsqlite3-master>mingw32-make lsqlite3complete-0.9.4-2.rockspec
mingw32-make: Nothing to be done for 'lsqlite3complete-0.9.4-2.rockspec'.

C:\Users\pc\Downloads\sqlite3\lsqlite3-master\lsqlite3-master>

The file lsqlite3.c contains #include "lua.h" and #include "lauxlib.h". It seems that they are from Lua for Windows project.

How can I compile lsqlite3 for Windows and link it to my existing CPP project's port?

Should it be compiled using GCC or Lua?

user366312
  • 16,949
  • 65
  • 235
  • 452
  • "This tells me that, I need lsqlite3" - Eh? For me, "**multiple definition**" error tells anything but missing library. E.g. the line `../bin/libMyLinuxBasedCppProject.a(DataTable.cc.obj):C:\Users\pc\source\repos\MyLinuxBasedCppProject\out\build\Mingw64-Debug/../../../src/utils/string_utils.hh:139: first defined here` tells me that you **define** a (non-inline) **function** in the **header**, which is frown upon: https://stackoverflow.com/questions/583255/is-it-a-good-practice-to-place-c-definitions-in-header-files – Tsyvarev Oct 29 '21 at 07:28
  • `FIND: Parameter format not correct` probably means that the makefile has been written for Linux and use the `find` command. The parameters between `find` on Windows and Linux are different. So, I think the `makefile` you are using is not targeting Win32. – Robert Nov 01 '21 at 01:09

1 Answers1

3

You are horribly mistaken. The linker flag -lsqlite3 means "link with libsqlite3.so. The correct library to compile is SQLite3. If you have trouble compiling it on Windows, there are quite a few questions about it on SO.

Botje
  • 26,269
  • 3
  • 31
  • 41
  • https://github.com/jgranick/sqlite/tree/master/ndll/Android – user366312 Oct 30 '21 at 11:40
  • In the above link, I see that `lsqlite.so` is an Android-compatible file. I am compiling C++ source code under Windows. So, how can I link it? – user366312 Oct 30 '21 at 11:41
  • Please just read [the official build Instructions](https://sqlite.org/amalgamation.html) you literally have to build and link a single C file. – Botje Nov 01 '21 at 08:20