c++ - 我该如何解决:找不到-lsqlite3?
问题描述
我正在使用 GCC/G++ 和 VS2019 IDE 在 Windows 10 下编译基于 Linux 的 CMake C++ 项目。
我已经通过 PATH 环境变量安装了sqlite3.dll
、sqlite3.lib
和。lsqlite3.so
然而,我收到以下错误:
[297/795] cmd.exe /C "cd . && C:\PROGRA~1\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin\g++.exe -g -DDEBUG -pthread -O1 -std=c++11 -Wall -g -DDEBUG -pthread -O1 -std=c++11 -Wall -lsqlite3 src/CMakeFiles/hist.dir/apps/MyLinuxBasedCppProject/hist.cc.obj -o ..\..\..\bin\hist.exe -Wl,--out-implib,..\bin\libhist.dll.a -Wl,--major-image-version,0,--minor-image-version,0 ../bin/libMyLinuxBasedCppProject.a -Wl,-Bstatic -lz -Wl,-Bdynamic -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
FAILED: ../../../bin/hist.exe
cmd.exe /C "cd . && C:\PROGRA~1\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin\g++.exe -g -DDEBUG -pthread -O1 -std=c++11 -Wall -g -DDEBUG -pthread -O1 -std=c++11 -Wall -lsqlite3 src/CMakeFiles/hist.dir/apps/MyLinuxBasedCppProject/hist.cc.obj -o ..\..\..\bin\hist.exe -Wl,--out-implib,..\bin\libhist.dll.a -Wl,--major-image-version,0,--minor-image-version,0 ../bin/libMyLinuxBasedCppProject.a -Wl,-Bstatic -lz -Wl,-Bdynamic -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
C:/PROGRA~1/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lsqlite3
C:\Users\pc\source\repos\MyLinuxBasedCppProject\out\build\Mingw64-Debug\collect2.exe : error : ld returned 1 exit status
[298/795] cmd.exe /C "cd . && C:\PROGRA~1\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin\g++.exe -g -DDEBUG -pthread -O1 -std=c++11 -Wall -g -DDEBUG -pthread -O1 -std=c++11 -Wall -lsqlite3 src/CMakeFiles/seqc.dir/apps/MyLinuxBasedCppProject/seqc.cc.obj -o ..\..\..\bin\seqc.exe -Wl,--out-implib,..\bin\libseqc.dll.a -Wl,--major-image-version,0,--minor-image-version,0 ../bin/libMyLinuxBasedCppProject.a -Wl,-Bstatic -lz -Wl,-Bdynamic -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
FAILED: ../../../bin/seqc.exe
cmd.exe /C "cd . && C:\PROGRA~1\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin\g++.exe -g -DDEBUG -pthread -O1 -std=c++11 -Wall -g -DDEBUG -pthread -O1 -std=c++11 -Wall -lsqlite3 src/CMakeFiles/seqc.dir/apps/MyLinuxBasedCppProject/seqc.cc.obj -o ..\..\..\bin\seqc.exe -Wl,--out-implib,..\bin\libseqc.dll.a -Wl,--major-image-version,0,--minor-image-version,0 ../bin/libMyLinuxBasedCppProject.a -Wl,-Bstatic -lz -Wl,-Bdynamic -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
C:/PROGRA~1/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lsqlite3
C:\Users\pc\source\repos\MyLinuxBasedCppProject\out\build\Mingw64-Debug\collect2.exe : error : ld returned 1 exit status
我该如何解决这个问题?
编辑
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 -LC:\\Users\\pc\\Downloads\\SQLite 64bit")
SET(CMAKE_SHARED_LINKER_FLAGS "-lsqlite3 -LC:\\Users\\pc\\Downloads\\SQLite 64bit" )
else()
message("Sqlite3 not found")
endif (SQLITE3_FOUND)
解决方案
推荐阅读
- export - 如何控制Stata中使用asdoc将判别分析结果导出为word的格式?
- python - 返回 NUMA 节点 0 TensorFlow
- reactjs - 尽管使用了 connect 和 mapDispatchToProps,调度操作并未触发减速器
- oauth-2.0 - Dropbox api Oauth 响应“不能为此应用授予任何范围请求”
- wordpress - 在事件日历插件中使用 Timber 和更新的日历设计
- typescript - 如何要求一个类型是一个排序的数组,而不仅仅是一个数组
- bootstrap-4 - 我如何在 nuxtjs 上安装引导程序
- flutter - 是否有任何解决方案可以使此代码正常工作
- flutter - 我如何在颤动中进行 2 对齐
- node.js - 无法接收客户标头节点快递