简体   繁体   English

将框架包含到xcode C ++项目中-链接器错误

[英]Include framework into xcode C++ project - linker error

I'm trying to use libpng for reading data from image file in my c++ project, making on xcode and have some problems to include it. 我正在尝试使用libpng从我的c ++项目中的图像文件中读取数据,并在xcode上进行制作,但包含它时遇到一些问题。

So, I've make the next steps: 因此,我要执行以下步骤:

  1. download libpng sources from http://libpng.sourceforge.net (version 1.6.29) and unarchive http://libpng.sourceforge.net (版本1.6.29)下载libpng源,并取消存档
  2. download xcode project folder from here https://github.com/IGRSoft/libpng-xcode-project and put it into ./projects folder 从此处下载xcode项目文件夹https://github.com/IGRSoft/libpng-xcode-project并将其放入./projects文件夹
  3. open libpng.xcodeproj and make build. 打开libpng.xcodeproj并进行构建。 As a result I have /Users/admin/Library/Developer/Xcode/DerivedData/libpng-efgdtopqjltxorcwlnlvdirxqclm/Build/Products/Debug/ libpng.framework 结果是我有/ Users / admin / Library / Developer / Xcode / DerivedData / libpng-efgdtopqjltxorcwlnlvdirxqclm / Build / Products / Debug / libpng.framework
  4. I copied this file to my xcode project folder 我将此文件复制到我的xcode项目文件夹中
  5. Add this file to Project->General->Linked Frameworks and Libraries 将此文件添加到Project-> General-> Linked Frameworks and Libraries

Then, when I'm trying to compile project, I have an error: 然后,当我尝试编译项目时,出现错误:

ld: framework not found libpng clang: error: linker command failed with exit code 1 (use -v to see invocation)

What I'm doing wrong or what step was missed? 我做错了什么或错过了哪一步?

I'm new in xcode so be patient and give a detailed answer, please. 我是xcode的新手,请耐心等待,并提供详细的答案。

找不到库的错误通常是引荐人将标题搜索路径设置为错误,因此请建立设置/标题搜索路径,然后添加$(inherit)

Now I found solution. 现在我找到了解决方案。

I moved framework file from project folder to folder with .xcodeproj and it linked successfull: screenshot 我将框架文件从项目文件夹移到了.xcodeproj文件夹,并成功链接了: 屏幕截图

But there is another one error on starting program: 但是启动程序还有另一个错误

dyld: Library not loaded: @loader_path/../Frameworks/libpng.framework/Versions/A/libpng
Referenced from: /Users/admin/Library/Developer/CoreSimulator/Devices/B875D4BF-EE6B-4601-9DFC-9C534AD6C085/data/Containers/Bundle/Application/981ECC6B-5EDB-4646-A990-510FEB619650/Happy Ball.app/Happy Ball
Reason: image not found

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM