Failed to load embed dylib in M1?

I met a strange issue. I got error:

dyld: Library not loaded: /usr/local/lib/mylib.dylib
  Reference from: .....
Reason: image not found

I didn't suppose that I need to load library from /usr/local/lib, because it already included in my project.

The lib is an embed lib of my project and this issue only happened on my M1 mini? I have try three devices even on MacOS 12.0.1

Then I found the "Runpath Search Paths" seems didn't work on M1 machine. All setting among three machine are the same. (The same source code). Even I use the absolute path on this setting on M1 machine didn't work while others two machine without any problem.

Does anybody know what happened? Should I add additional setting on my M1 machine?

ps: My project has two level, the problem happen on my second level project which is included in the first level project. I am not sure related to this or not?

For additional reference, I was building the ffmpeg library for Arm. The Intel part I got from my previous owner directly. I just using the same build config got from the original owner to build the Arm build and using lipo to combine these two library into one to be used in my app. I am wondering are there something I am missing when I build the Arm version. Are there any possible hint to find the solution?

I used otool -l to get some information on my lib. Does anybody know why the load path will be different within the same project?

For Intel:

Load command 11           cmd LC_LOAD_DYLIB       cmdsize 56          name @rpath/libavcodec.58.dylib (offset 24)    time stamp 2 Thu Jan  1 08:00:02 1970       current version 58.54.100 compatibility version 58.0.0

For Arm Load command 12           cmd LC_LOAD_DYLIB       cmdsize 64          name /usr/local/lib/libavcodec.58.dylib (offset 24)    time stamp 2 Thu Jan  1 08:00:02 1970       current version 58.54.100 compatibility version 58.0.0

Failed to load embed dylib in M1?
 
 
Q