Skip to content

Commit 14cba69

Browse files
committed
Now working with example
1 parent f225341 commit 14cba69

File tree

7 files changed

+45
-44
lines changed

7 files changed

+45
-44
lines changed

CMakeLists.txt

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,6 @@ endif ()
1717
message(STATUS "Using c++ standard c++${CMAKE_CXX_STANDARD}")
1818
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1919

20-
if(BUILD_SHARED_LIBS)
21-
if(WIN32)
22-
message("defining SQLITECPP_COMPILE_DLL")
23-
add_definitions("-DSQLITECPP_COMPILE_DLL")
24-
if(SQLITECPP_DLL_EXPORT)
25-
add_definitions("-DSQLITECPP_DLL_EXPORT")
26-
endif()
27-
endif()
28-
endif()
29-
3020
message (STATUS "CMake version: ${CMAKE_VERSION}")
3121
message (STATUS "Project version: ${PROJECT_VERSION}")
3222

@@ -223,6 +213,13 @@ if (SQLITE_USE_LEGACY_STRUCT)
223213
target_compile_definitions(SQLiteCpp PUBLIC SQLITE_USE_LEGACY_STRUCT)
224214
endif (SQLITE_USE_LEGACY_STRUCT)
225215

216+
if(BUILD_SHARED_LIBS)
217+
if(WIN32)
218+
add_definitions("-DSQLITECPP_COMPILE_DLL")
219+
target_compile_definitions(SQLiteCpp PRIVATE "SQLITECPP_DLL_EXPORT=1")
220+
endif()
221+
endif()
222+
226223
option(SQLITE_OMIT_LOAD_EXTENSION "Enable omit load extension" OFF)
227224
if (SQLITE_OMIT_LOAD_EXTENSION)
228225
# Enable the user definition of load_extension().
@@ -412,8 +409,14 @@ endif (SQLITECPP_RUN_DOXYGEN)
412409

413410
option(SQLITECPP_BUILD_EXAMPLES "Build examples." OFF)
414411
if (SQLITECPP_BUILD_EXAMPLES)
412+
415413
# add the basic example executable
416414
add_executable(SQLiteCpp_example1 ${SQLITECPP_EXAMPLES})
415+
if(BUILD_SHARED_LIBS)
416+
if(WIN32)
417+
target_compile_definitions(SQLiteCpp_example1 PRIVATE "SQLITECPP_DLL_EXPORT=0")
418+
endif()
419+
endif()
417420
target_link_libraries(SQLiteCpp_example1 SQLiteCpp)
418421
if (MSYS OR MINGW)
419422
target_link_libraries(SQLiteCpp_example1 ssp)

include/SQLiteCpp/Database.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,15 @@ DLL_API extern const int OPEN_PRIVATECACHE; // SQLITE_OPEN_PRIVATECACHE
107107
DLL_API extern const int OPEN_NOFOLLOW; // SQLITE_OPEN_NOFOLLOW
108108

109109

110-
extern const int OK; ///< SQLITE_OK (used by check() bellow)
110+
DLL_API extern const int OK; ///< SQLITE_OK (used by check() bellow)
111111

112-
extern const char* const VERSION; ///< SQLITE_VERSION string from the sqlite3.h used at compile time
113-
extern const int VERSION_NUMBER; ///< SQLITE_VERSION_NUMBER from the sqlite3.h used at compile time
112+
DLL_API extern const char* const VERSION; ///< SQLITE_VERSION string from the sqlite3.h used at compile time
113+
DLL_API extern const int VERSION_NUMBER; ///< SQLITE_VERSION_NUMBER from the sqlite3.h used at compile time
114114

115115
/// Return SQLite version string using runtime call to the compiled library
116-
const char* getLibVersion() noexcept;
116+
DLL_API const char* getLibVersion() noexcept;
117117
/// Return SQLite version number using runtime call to the compiled library
118-
int getLibVersionNumber() noexcept;
118+
DLL_API int getLibVersionNumber() noexcept;
119119

120120
// Public structure for representing all fields contained within the SQLite header.
121121
// Official documentation for fields: https://www.sqlite.org/fileformat.html#the_database_header
@@ -266,7 +266,7 @@ class DLL_API Database
266266
// Deleter functor to use with smart pointers to close the SQLite database connection in an RAII fashion.
267267
struct Deleter
268268
{
269-
void operator()(sqlite3* apSQLite);
269+
DLL_API void operator()(sqlite3* apSQLite);
270270
};
271271

272272
/**

include/SQLiteCpp/SQLiteCppExport.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
/* Windows DLL export/import */
2121
#if defined(WIN32) && defined(SQLITECPP_COMPILE_DLL)
22-
#if defined(SQLITECPP_DLL_EXPORT)
22+
#if SQLITECPP_DLL_EXPORT
2323
#define DLL_API __declspec(dllexport)
2424
#pragma message("Exporting symbols")
2525
#else
@@ -29,3 +29,8 @@
2929
#else
3030
#define DLL_API
3131
#endif
32+
33+
#if defined(WIN32) && defined(SQLITECPP_COMPILE_DLL)
34+
#pragma warning( disable : 4251 )
35+
#pragma warning( disable : 4275 )
36+
#endif

include/SQLiteCpp/Statement.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace SQLite
3131
class Database;
3232
class Column;
3333

34-
extern const int OK; ///< SQLITE_OK
34+
DLL_API extern const int OK; ///< SQLITE_OK
3535

3636
/**
3737
* @brief RAII encapsulation of a prepared SQLite Statement.

sqlite3/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,7 @@ add_library(sqlite3
1313

1414
if(WIN32)
1515
if(BUILD_SHARED_LIBS)
16-
if(SQLITECPP_DLL_EXPORT)
17-
message("Adding __declspec(dllexport)")
1816
add_definitions("-DSQLITE_API=__declspec(dllexport)")
19-
else()
20-
message("Adding __declspec(dllimport)")
21-
add_definitions("-DSQLITE_API=__declspec(dllimport)")
22-
endif()
2317
endif()
2418
endif()
2519

src/Column.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
namespace SQLite
1919
{
2020

21-
const int INTEGER = SQLITE_INTEGER;
22-
const int FLOAT = SQLITE_FLOAT;
23-
const int TEXT = SQLITE_TEXT;
24-
const int BLOB = SQLITE_BLOB;
25-
const int Null = SQLITE_NULL;
21+
DLL_API const int INTEGER = SQLITE_INTEGER;
22+
DLL_API const int FLOAT = SQLITE_FLOAT;
23+
DLL_API const int TEXT = SQLITE_TEXT;
24+
DLL_API const int BLOB = SQLITE_BLOB;
25+
DLL_API const int Null = SQLITE_NULL;
2626

2727

2828
// Encapsulation of a Column in a row of the result pointed by the prepared Statement.

src/Database.cpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,28 @@
2323
#define SQLITE_DETERMINISTIC 0x800
2424
#endif // SQLITE_DETERMINISTIC
2525

26-
2726
namespace SQLite
2827
{
2928

30-
const int OK = SQLITE_OK;
31-
const int OPEN_READONLY = SQLITE_OPEN_READONLY;
32-
const int OPEN_READWRITE = SQLITE_OPEN_READWRITE;
33-
const int OPEN_CREATE = SQLITE_OPEN_CREATE;
34-
const int OPEN_URI = SQLITE_OPEN_URI;
35-
const int OPEN_MEMORY = SQLITE_OPEN_MEMORY;
36-
const int OPEN_NOMUTEX = SQLITE_OPEN_NOMUTEX;
37-
const int OPEN_FULLMUTEX = SQLITE_OPEN_FULLMUTEX;
38-
const int OPEN_SHAREDCACHE = SQLITE_OPEN_SHAREDCACHE;
39-
const int OPEN_PRIVATECACHE = SQLITE_OPEN_PRIVATECACHE;
29+
DLL_API const int OK = SQLITE_OK;
30+
DLL_API const int OPEN_READONLY = SQLITE_OPEN_READONLY;
31+
DLL_API const int OPEN_READWRITE = SQLITE_OPEN_READWRITE;
32+
DLL_API const int OPEN_CREATE = SQLITE_OPEN_CREATE;
33+
DLL_API const int OPEN_URI = SQLITE_OPEN_URI;
34+
DLL_API const int OPEN_MEMORY = SQLITE_OPEN_MEMORY;
35+
DLL_API const int OPEN_NOMUTEX = SQLITE_OPEN_NOMUTEX;
36+
DLL_API const int OPEN_FULLMUTEX = SQLITE_OPEN_FULLMUTEX;
37+
DLL_API const int OPEN_SHAREDCACHE = SQLITE_OPEN_SHAREDCACHE;
38+
DLL_API const int OPEN_PRIVATECACHE = SQLITE_OPEN_PRIVATECACHE;
4039
// check if sqlite version is >= 3.31.0 and SQLITE_OPEN_NOFOLLOW is defined
4140
#if SQLITE_VERSION_NUMBER >= 3031000 && defined(SQLITE_OPEN_NOFOLLOW)
42-
const int OPEN_NOFOLLOW = SQLITE_OPEN_NOFOLLOW;
41+
DLL_API const int OPEN_NOFOLLOW = SQLITE_OPEN_NOFOLLOW;
4342
#else
44-
const int OPEN_NOFOLLOW = 0;
43+
DLL_API const int OPEN_NOFOLLOW = 0;
4544
#endif
4645

47-
const char* const VERSION = SQLITE_VERSION;
48-
const int VERSION_NUMBER = SQLITE_VERSION_NUMBER;
46+
DLL_API const char* const VERSION = SQLITE_VERSION;
47+
DLL_API const int VERSION_NUMBER = SQLITE_VERSION_NUMBER;
4948

5049
// Return SQLite version string using runtime call to the compiled library
5150
const char* getLibVersion() noexcept

0 commit comments

Comments
 (0)