简体   繁体   中英

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.

So, I've make the next steps:

  1. download libpng sources from http://libpng.sourceforge.net (version 1.6.29) and unarchive
  2. download xcode project folder from here https://github.com/IGRSoft/libpng-xcode-project and put it into ./projects folder
  3. open libpng.xcodeproj and make build. As a result I have /Users/admin/Library/Developer/Xcode/DerivedData/libpng-efgdtopqjltxorcwlnlvdirxqclm/Build/Products/Debug/ libpng.framework
  4. I copied this file to my xcode project folder
  5. Add this file to 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.

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

Now I found solution.

I moved framework file from project folder to folder with .xcodeproj and it linked successfull: screenshot

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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