简体   繁体   English

找不到针对架构x86_64的xcode c ++ sqlite3符号

[英]xcode c++ sqlite3 symbol(s) not found for architecture x86_64

Hi I want to use sqlite in c++ project in xcode 4 嗨,我想在xcode 4的C ++项目中使用sqlite

now i am getting this error 现在我收到此错误

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 Ld / Users / jayb / Library / Developer / Xcode / DerivedData / EMS-bpigynlzjbrescadebhoiupqmtkg / Build / Products / Debug / EMS normal x86_64 cd / Users / jayb / Documents / Development / EMS / EMS setenv MACOSX_DEPLOYMENT_TARGET 10.8 / Applications。内容/开发人员/工具链/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 / Users-file /库/开发人员/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 /库/开发人员/ Xcode / DerivedData / EMS-bpigynlzjbrescadebhoiupqmtkg /构建/产品/调试/ 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) 体系结构x86_64的未定义符号:“ _sqlite3_close”,引用自:main.o中的_main“ _sqlite3_errmsg”,引用自:main.o _main中的“ _sqlite3_open”,引用自:main.o中的_main。ld:未找到符号对于体系结构x86_64 clang:错误:链接器命令失败,退出代码为1(使用-v查看调用)

and i found that is linker problem it may fix with compiler option -lsqlite3 我发现这是链接器问题,可以用编译器选项-lsqlite3修复

but, how can i add that option in Xcode?????? 但是,如何在Xcode中添加该选项呢????

I use "Run" button on xcode 4.4 to compile my project. 我在xcode 4.4上使用“运行”按钮来编译我的项目。 i am not compiling in terminal window. 我不在终端窗口中进行编译。

this is my code 这是我的代码

#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;
}

I found the way, wish it helps someone looking for the same solution. 我找到了方法,希望它能帮助寻找相同解决方案的人。 now it builds correct and i can see the output 现在它建立正确,我可以看到输出

woops, I cannot post image yet :( 哇,我还不能发布图片:(

from the xcode build settings, you can find a tab called (Linking) and on the Linking tab there are field call 'Other Linker Flags' i simply added the -lsqlite3 for both Debug, and Release 从xcode的构建设置中,您可以找到一个名为(Linking)的选项卡,并且在Linking选项卡上有字段调用“ Other Linker Flags”,我只是为调试和发布添加了-lsqlite3

cheers 干杯

I was getting the similar error : I did following in my case: 我遇到了类似的错误:我的情况如下:

#import <sqlite3.h>

在此处输入图片说明

I am not familiar with xcode. 我对xcode不熟悉。 Look for linker settings or compiler settings and add the -lsqlite3 there. 查找linker设置或compiler设置,然后在其中添加-lsqlite3

Perhaps this page helps: Xcode what's the difference between "Other Linker Flags" vs "Other_LDFLAGS" 也许该页面会有所帮助: Xcode“ Other Linker Flags”与“ Other_LDFLAGS”之间有什么区别

LDFLAGS are passed to the linker. LDFLAGS传递到链接器。 CFLAGS are passed to the compiler. CFLAGS传递给编译器。

It is require to link libsqlite3.dylib in your project. 需要在您的项目中链接libsqlite3.dylib。 That can be done in Linked Frameworks and Libraries and add libsqlite3.dylib. 这可以在链接框架和库中完成,并添加libsqlite3.dylib。

for reference follow: xcode sqlite3 libsqlite.dylib 供参考,请执行以下操作: xcode sqlite3 libsqlite.dylib

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Xcode项目中使用C / C ++库时,找不到体系结构x86_64的符号 - Symbol(s) not found for architecture x86_64 when using C/C++ library in Xcode project 未找到架构x86_64的符号(带有xcode的OpenGL) - Symbol(s) not found for architecture x86_64 (OpenGL with xcode) 在Xcode中找不到架构x86_64的符号 - symbol(s) not found for architecture x86_64 in Xcode ld:在编译c ++时找不到架构x86_64的符号 - ld: symbol(s) not found for architecture x86_64 when compiling c++ C ++编译错误,需要帮助-ld:找不到体系结构x86_64的符号 - C++ Compile Error, Help Needed - ld: symbol(s) not found for architecture x86_64 C ++ ld:找不到x86_64体系结构macbook特立独行的符号 - C++ ld: symbol(s) not found for architecture x86_64 macbook maverick C ++:gcc“找不到架构x86_64的符号”(Mac) - C++: gcc “symbol(s) not found for architecture x86_64” (Mac) C ++错误:-1:错误:在Qt-Creator中找不到架构x86_64的符号 - c++ error: :-1: error: symbol(s) not found for architecture x86_64 - in Qt-Creator C ++库编程错误:找不到架构x86_64的ld:符号 - C++ Library programming error: ld: symbol(s) not found for architecture x86_64 如何使用 C++、CMake 和 Tensorflow 修复“ld: symbol(s) not found for architecture x86_64”? - How to fix “ld: symbol(s) not found for architecture x86_64” using C++, CMake and Tensorflow?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM