SRombauts / SQLiteCpp

SQLiteC++ (SQLiteCpp) is a smart and easy to use C++ SQLite3 wrapper.
http://srombauts.github.io/SQLiteCpp
MIT License
2.19k stars 509 forks source link

Problem with link SqliteCpp with my lib #449

Closed 0b-s3rv3r closed 1 year ago

0b-s3rv3r commented 1 year ago

My errors: [build] LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library [C:\repos\2DO\build\test\twodo_ut.vcxproj] [build] LINK : warning LNK4217: symbol '_free' defined in 'libucrtd.lib(free.obj)' is imported by 'sqlite3.lib(sqlite3.obj)' in function '_vfsUnlink' [C:\repos\2DO\build\test\twodo_ut.vcxproj] [build] LINK : warning LNK4217: symbol '_malloc' defined in 'libucrtd.lib(malloc.obj)' is imported by 'sqlite3.lib(sqlite3.obj)' in function '_vfsUnlink' [C:\repos\2DO\build\test\twodo_ut.vcxproj] [build] LINK : warning LNK4217: symbol '_realloc' defined in 'libucrtd.lib(realloc.obj)' is imported by 'sqlite3.lib(sqlite3.obj)' in function '_vfsUnlink' [C:\repos\2DO\build\test\twodo_ut.vcxproj] [build] LINK : warning LNK4217: symbol '_strcspn' defined in 'libucrtd.lib(strcspn.obj)' is imported by 'sqlite3.lib(sqlite3.obj)' in function '_patternCompare' [C:\repos\2DO\build\test\twodo_ut.vcxproj] [build] LINK : warning LNK4217: symbol '_strncmp' defined in 'libucrtd.lib(strncmp.obj)' is imported by 'sqlite3.lib(sqlite3.obj)' in function '_sqlite3VListNameToNum' [C:\repos\2DO\build\test\twodo_ut.vcxproj] [build] LINK : warning LNK4217: symbol 'localtime64_s' defined in 'libucrtd.lib(localtime.obj)' is imported by 'sqlite3.lib(sqlite3.obj)' in function '_localtime_s' [C:\repos\2DO\build\test\twodo_ut.vcxproj] [build] sqlite3.lib(sqlite3.obj) : error LNK2019: unresolved external symbol imp_msize referenced in function _vfsUnlink [C:\repos\2DO\build\test\twodo_ut.vcxproj] [build] sqlite3.lib(sqlite3.obj) : error LNK2019: unresolved external symbol _impbeginthreadex referenced in function _sqlite3ThreadCreate [C:\repos\2DO\build\test\twodo_ut.vcxproj] [build] sqlite3.lib(sqlite3.obj) : error LNK2019: unresolved external symbol __imp_endthreadex referenced in function _sqlite3ThreadProc@4 [C:\repos\2DO\build\test\twodo_ut.vcxproj] [build] MSVCRTD.lib(chandler4gs.obj) : error LNK2019: unresolved external symbol except_handler4_common referenced in function __except_handler4 [C:\repos\2DO\build\test\twodo_ut.vcxproj] [build] C:\repos\2DO\build\test\Debug\twodo_ut.exe : fatal error LNK1120: 4 unresolved externals [C:\repos\2DO\build\test\twodo_ut.vcxproj]


I use CMake and compiler returs me these errors. Why ?

I also have to mention that i add SQLiteCpp through gh sumodules.


That's my cmakelists with adding subdirectory and linking libraries:

set(SQLITECPP_RUN_CPPCHECK OFF CACHE BOOL "" FORCE) set(SQLITECPP_RUN_CPPLINT OFF CACHE BOOL "" FORCE)

set(SQLITECPP_DIR "${CMAKE_SOURCE_DIR}/thirdparty/SQLiteCpp") add_subdirectory(${SQLITECPP_DIR} ${CMAKE_BINARY_DIR}/SQLiteCpp)

file(GLOB SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/.cpp ${CMAKE_CURRENT_SOURCE_DIR}/.hpp)

add_library(${PROJECT_NAME}_lib STATIC ${SOURCES})

target_include_directories(${PROJECT_NAME}_lib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} )

target_link_libraries( ${PROJECT_NAME}_lib SQLiteCpp sqlite3 )

0b-s3rv3r commented 1 year ago

It was just a conflict with gtest. Gtest compiles with MTd and SQLite with MDd. I forced gtest for compile with MDd and now it works.

SRombauts commented 1 year ago

Thanks for taking the time to let us know And yes that's a recent changes to the wrapper CMakeFiles.txt