search

Home  >  Q&A  >  body text

objective-c - When trying to link a static library in Xcode, a dylib error is prompted when running. How to solve it?

I am making a program on Mac OS X and plan to use libev.

What I do is: download libev, then:

# ./configure
# make

Next, I added the two files .lib/libev.a and include/ev.h to my xcode project. You can see that xcode recognized libev.a, as shown below:

But when I ran, the following error occurred:

dyld: Library not loaded: /usr/local/lib/libev.4.dylib
  Referenced from: /Users/Falcon/Library/Developer/Xcode/DerivedData/BrahBrah-hibmvwhxifxymfacottfiecsflqn/Build/Products/Debug/BrahBrah.app/Contents/MacOS/ToyControl
  Reason: image not found

What's going on with this...? I obviously added an .a file, but why does it say dylib cannot be found?
Is it wrong for me to add libev like this? Under normal circumstances, how do I need to add the libev.a static library?

Thank you in advance for everyone who answered my questions~~

ringa_leeringa_lee2788 days ago525

reply all(1)I'll reply

  • 淡淡烟草味

    淡淡烟草味2017-05-02 09:28:58

    Uh...I found the reason myself. It turned out to be very simple: I copied libev.a to the project folder and it was OK...
    I feel like I should be able to add the search path of the library in xcode, so I don't have to copy... …

    reply
    0
  • Cancelreply