gpt4 book ai didi

c++ - xcode c++ sqlite3 symbol(s) not found for architecture x86_64

转载 作者:太空宇宙 更新时间:2023-11-04 14:55:15 26 4
gpt4 key购买 nike

你好,我想在 xcode 4 的 c++ 项目中使用 sqlite

现在我收到这个错误

Ld /Users/jayb/Library/Developer/Xcode/DerivedData/EMS-bpigynlzjbrescadebhoiupqmtkg/Build/Products/Debug/EMS normal x86_64 cd /Users/jayb/Documents/Developement/EMS/EMS setenv MACOSX_DEPLOYMENT_TARGET 10.8 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -L/Users/jayb/Library/Developer/Xcode/DerivedData/EMS-bpigynlzjbrescadebhoiupqmtkg/Build/Products/Debug -F/Users/jayb/Library/Developer/Xcode/DerivedData/EMS-bpigynlzjbrescadebhoiupqmtkg/Build/Products/Debug -filelist /Users/jayb/Library/Developer/Xcode/DerivedData/EMS-bpigynlzjbrescadebhoiupqmtkg/Build/Intermediates/EMS.build/Debug/EMS.build/Objects-normal/x86_64/EMS.LinkFileList -mmacosx-version-min=10.8 -o /Users/jayb/Library/Developer/Xcode/DerivedData/EMS-bpigynlzjbrescadebhoiupqmtkg/Build/Products/Debug/EMS

Undefined symbols for architecture x86_64: "_sqlite3_close", referenced from: _main in main.o "_sqlite3_errmsg", referenced from: _main in main.o "_sqlite3_open", referenced from: _main in main.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

我发现这是链接器问题它可以通过编译器选项 -lsqlite3 修复

但是,我如何在 Xcode 中添加该选项?????

我在 xcode 4.4 上使用“运行”按钮来编译我的项目。我没有在终端窗口中编译。

这是我的代码

#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <sqlite3.h>

using namespace std;

int main()
{
sqlite3 *db;
int rc = sqlite3_open("EMSDB", &db);
if (rc) {
fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
exit(0);
}
else {
fprintf(stderr, "Opened Database successfully\n");
}

sqlite3_close(db);

return 0;
}

最佳答案

我找到了路,希望它能帮助寻找相同解决方案的人。现在它构建正确,我可以看到输出

糟糕,我还不能发布图片:(

从 xcode build设置,您可以找到一个名为(链接)的选项卡并在“链接”选项卡上有字段调用“其他链接器标志”我只是为调试和发布添加了 -lsqlite3

干杯

关于c++ - xcode c++ sqlite3 symbol(s) not found for architecture x86_64,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18489796/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com