Linker error during unit testing: ld: illegally moving text in cstring to ... from _av_image_check_size to ... /libavutil.a(imgutils.o)

In Xcode 4.3.2, when creating an iPad application that includes libavutil.affmpeg from the distribution, it builds and works correctly, but when I try to run unit tests (Cmd-U), I get the following linker error:

ld: illegally moving text in cstring to /myPath/libavutil.a(imgutils.o) from _av_image_check_size in /myPath/libavutil.a(imgutils.o) for armv7 clang architecture: error: linker command failed with exit code 1 (use -v to see the call)

This is on the device (we cannot run it in the simulator at present, because we do not have complete binaries for all the libraries that we include).

Why will it work normally and start normally, but is not connected when performing unit tests?

+5
source share
4 answers

The answer is from here .

should add:

-read_only_relocs suppress

to linker flags.

Another link explains why. The solution was originally found here .

+10
source

To be specific, a line that worked specifically to fix a similar linking error with a link ffmpegfor 32bit OSXusing xcode/c++11was to add -Wl,-read_only_relocs,suppressa link to the line. Variations of this did not work.

+3
source

I resolved this linker error by including position-independent code in the compiler and linker settings in Xcode.

+3
source

For those who read the answers above, but that didn’t help, check your “Product → Schema → Edit Schema”. It should be "debugging" for the simulator and for the device it does not matter. Otherwise, you will get strange errors, as if they do not see some parts of your project.

+1
source

All Articles