[英]How to compile and link sqlite3 in a C++ program
I get the following response when I try to compile and link sqlite3 in a C++ program. 当我尝试在C ++程序中编译和链接sqlite3时,得到以下响应。 I use Eclipse Mars for C++
我将Eclipse Mars用于C ++
g++ "-LC:\\Sqlite\\sqlite3.h" -o Stryktips.exe "src\\Stryktips.o" "-lC:\\Sqlite\\sqlite3.h"
g ++“ -LC:\\ Sqlite \\ sqlite3.h” -o Stryktips.exe“ src \\ Stryktips.o”“ -lC:\\ Sqlite \\ sqlite3.h”
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../.C:/ MinGW的/ bin中/../ LIB / GCC / x86_64的-W64-的mingw32 / 4.9.2 /../../。 ./../x86_64-w64-mingw32/bin/ld.exe:
./../x86_64-w64-mingw32/bin/ld.exe:
cannot find -lC:\\Sqlite\\sqlite3.h找不到-lC:\\ Sqlite \\ sqlite3.h
collect2.exe: error: ld returned 1 exit statuscollect2.exe:错误:ld返回1退出状态
C:\\Sqlite\\sqlite3.h
is a header file . C:\\Sqlite\\sqlite3.h
是头文件 。 And as such you should #include
it, not link with it. 因此,您应该
#include
它,而不是链接它。 You should link with a file ending with .lib
or .a
您应该链接以
.lib
或.a
结尾的文件
And the -L
option is to add a directory path, not a file. -L
选项是添加目录路径,而不是文件。
So your linker command like should look something like this: 因此,您的链接器命令如下所示:
g++ -o Stryktips.exe "src\Stryktips.o" -LC:\Sqlite -lsqlite
That will tell the linker that libraries can be found in the C:\\Sqlite
directory , and that it should link with the sqlite
library. 这将告诉链接器可以在
C:\\Sqlite
目录中找到库,并且应与sqlite
库链接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.