Understanding Library Links in Xcode

Asked 2 years ago, Updated 2 years ago, 140 views

When I moved the Xcode project from another PC to another PC and tried to run it on a new PC, it was probably a library link problem, but I'm having trouble running it. The project uses multiple libraries, including OpenCV.

Installation methods and versions may vary (if you try to install an earlier version, it may not work), but for all libraries you are using,

  • Configuring Library search path.
  • Header search path settings.
  • Link .dylib files required by Link Binary with Libraries in Build Phase

We have done .
The build itself is successful (shown as build succeeded), but

 dyld: Library not loaded: /Users/XXX/XXX/ArUco/aruco-1.3.0/build/src/libaruco.1.3.dylib
  Referenced from: /Users/○○○/○○○/Xcode/build/Debug/feedback
  Reason—image not found
Program ended with exit code: 9

The program will end with a message like the one above.

XXX and ○○○ are not really such names, but they are usernames, so I changed them.
I can understand that the library is not loaded, but the path (/Users/XXX/XXX...) beyond "Library not loaded:" is the path of the PC from which it was moved, and there are no such directories or files on the PC you are running.

Beyond "Reference from:" is the UNIX executable created during build. Once you delete and run this file, you will see a similar message, so you may still have the path configuration on your old PC somewhere.

There are no previous PC settings left in the Library search path and Header search path in Xcode's Build setting, but I'm at a loss because I can't find anywhere else to set the path. If anyone knows anything, please let me know.

  • PC:Macbook PRO 2017
  • OS: macOS 10.14
  • Xcode 10.1

The library is installed via homebrew. (GLFW, GLEW, tbb, etc.)
If you install the latest version of opencv only on homebrew, you will get a different error from the one above, so I downloaded the source of opencv 3.2 and installed it on cmake.

I look forward to your kind cooperation.

xcode macos opencv homebrew

2022-09-30 17:32

1 Answers

Didn't the unix executable feedback contain .dylib and the .dylib just copy what was compiled on the previous Mac?

I can't say 100% because I don't know the components, but if you want to create a library file in an archive,

    Static library with the extension
  • .a—Contents are copied when linked, so you can copy them to other machines.
  • Dynamic library with extension
  • .dylib: When linked, only the file path is stored in the executable file and loaded into the executable file at startup or load instruction, so the size of the executable file is reduced.

    From what is happening, a program called feedback links some .dylib, and there are no other .dylib on the new machine that requires that .dylib.dylib.It is estimated that

    If so, to avoid this, you should not get this error if you change the library of elements that make up feedback to ..a instead of .dylib or replace it with a new machine that has been compiled again.

Dynamic library with extension .dylib: When linked, only the file path is stored in the executable file and loaded into the executable file at startup or load instruction, so the size of the executable file is reduced.

From what is happening, a program called feedback links some .dylib, and there are no other .dylib on the new machine that requires that .dylib.dylib.It is estimated that

If so, to avoid this, if you change the library of elements that make up feedback to ..a instead of .dylib, or replace it with a new machine that has been compiled again.

In other words,
feedback<- Yes, compileable
 --??.dylib<- Yes, copy from previous machine
    --XXXX.dylib<- Error if not found because it is only on previous machine. I feel like this is happening.Please check.


2022-09-30 17:32

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.