tags:

views:

957

answers:

7

Hello,

I added ffmpeg iphone port into my library and I can able to use a few of its functions like avcodec_init(),.. without any errors. But when I include this function call "avcodec_register_all" Xcode is giving error after compilation

The error message is :

*--------------- ld: ldr 12-bit displacement out of range (4276 max +/-4096) in _CFRelease$stub in _CFRelease$stub from /Users/foxit/Documents/CameraTest/build/CameraTest.build/Debug-iphoneos/CameraTest.build/Objects-normal/armv6/CameraTest

Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1

*-------------

Does anyone know whats wrong with this ?

Regards,

Raghu

+1  A: 

Same as this problem?

Suggestion there is:

Please select deployment target "iPhone OS 3.0" or earlier. It is known Xcode linker issue with deployment targets "iPhone OS 3.1" and later.

David Gelhar
No that is not the problem, the same thing working in another Xocde project which I cant use it for some reasons
Sridhar
I was also seeing this problem and reordering my frameworks didn't work. After changing my build target from 3.1 to 3.0 the problem disappears.
jtrim
+3  A: 

This problem exists in iPhone OS 3.1 or later while building in Xcode. Try re-arringing the link order of the libraries in your target's link library phase. I have discussed this issue in: http://iphone.galloway.me.uk/2009/12/ldr-12-bit-displacement-out-of-range/

There is an inherent problem in iPhone SDK 3.1 and later. Will have to wait until Apple fixes it or we will have to do some trail and error changes.

In our case, just re-ordering libavfilter and libavcodec to the last would simply work.

Raj
Hi Raj, Do you know a way to convert raw surface buffer to AvFrame() ?I am trying to write a video recording application.I am able to hold the raw data of the image (screen) but not able to find the conversion from that raw data into AVframe to encode it.Thanks
Sridhar
Follow output-example.c file in the source of FFMpeg source. Implement the required methods from it. Override fill_yuv_image() method so that you convert your RGB data to YUV by using sws_scale() method and fill that raw data into AVFrame which is passed as an argument to fill_yuv_image().
Raj
A: 

Since I am using a CMake generated XCode project I don't have all the flexibility I would like in re-ordering my link lines. I stared at the ld(1) man page for a while and found this:

-no_order_inits

"When the -order_file option is not used, the linker lays out functions in object file order and it moves all initializer routines to the start of the __text section and terminator routines to the end. Use this option to disable the automatic re-arrangement of initializers and terminators."

Adding this to the link line made the error go away.

mtoy
A: 

This is just so incredibly ludicrous. Apple has put so many stupid things like this into their iphone sdk. Somebody should do something about it. Oh and the other thing is: Apple just does not care.

Adam Freeman
A: 

I added the -no_order_inits to my linker flags but I still get the error :(

And I've tried rearranging my frameworks as well.

Any other suggestions?

Ken
+1  A: 

I was able to get rid of the error by unselecting the "Compile For Thumb" compiler option.

So here are my settings:

Base SDK:  iPhone Device 4.0 
iPhone OS Deployment Target: 3.1.3

I did add -no_order_inits to the linker options but that did not work for me.

If you select a deployment target of 3.0 then you also will not get the error.

BTW, I am also using the FFMPEG and libMMS libraries.

Ken
A: 

I've had this problem in MonoTouch and posted a solution for it here: http://microsoft2apple.com/2010/09/30/solved-ldr-12-bit-displacement-out-of-range/

Ryan Smyth