Question

I'm trying to build libx264.a to run on my iphone 4s ( running iOS 6.1.3 )

I'm building it using the MACOSX 10.9 Terminal application:

CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang ./configure 
--host=arm-apple-darwin 
--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk 
--prefix=armv7 
--extra-cflags='-no-integrated-as -arch armv7' 
--extra-ldflags="-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/lib/system -arch armv7" 
--enable-pic --enable-static

Which guives me the output:

platform:      ARM
system:        MACOSX
cli:           yes
libx264:       internal
shared:        no
static:        yes
asm:           yes
interlaced:    yes
avs:           avxsynth
lavf:          no
ffms:          no
mp4:           no
gpl:           yes
thread:        posix
opencl:        yes
filters:       crop select_every 
debug:         no
gprof:         no
strip:         no
PIC:           yes
bit depth:     8
chroma format: all

Then I run 'make' and it generates a libx264.a archive.

So far, so good.

On my Xcode (Version 5.0.2 (5A3005)) application I set:

1) Build Settings -> Header Search Path -> x264 parent directory (../x264 )
2) Build Phases -> Link Library with Binaries -> Add Other... ( ../x264/libx264.a )
3) Build Settings -> Other Linker Flags: -ObjC

In my AppDelegate.mm:

#import "AppDelegate.h"
#import "x264.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application 
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{    
    x264_param_t x264param;
    x264_param_default(&x264param);

    // Override point for customization after application launch.
    return YES;
}

...

When i try to run it on the device I get the error:

Undefined symbols for architecture armv7:
  "x264_param_default(x264_param_t*)", referenced from:
  -[AppDelegate application:didFinishLaunchingWithOptions:] in AppDelegate.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 
(use -v to see invocation)

Here is the command invoked by xcode:

Ld /Users/danieldantas/Library/Developer/Xcode/DerivedData/testingCpp-bvawshyhjcybwvadwwwjqxuomjts/Build/Products/Debug-iphoneos/testingCpp.app/testingCpp normal armv7
cd /Users/danieldantas/Desktop/projects/testingCpp
setenv IPHONEOS_DEPLOYMENT_TARGET 6.0
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch armv7 -isysroot 
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk 
-L/Users/danieldantas/Library/Developer/Xcode/DerivedData/testingCpp-bvawshyhjcybwvadwwwjqxuomjts/Build/Products/Debug-iphoneos 
-L/Users/danieldantas/Desktop/projects/testingCpp -L/Users/danieldantas/Desktop/projects/x264 
-F/Users/danieldantas/Library/Developer/Xcode/DerivedData/testingCpp-bvawshyhjcybwvadwwwjqxuomjts/Build/Products/Debug-iphoneos 
-filelist /Users/danieldantas/Library/Developer/Xcode/DerivedData/testingCpp-bvawshyhjcybwvadwwwjqxuomjts/Build/Intermediates/testingCpp.build/Debug-iphoneos/testingCpp.build/Objects-normal/armv7/testingCpp.LinkFileList 
-dead_strip -ObjC -stdlib=libc++ -fobjc-arc -fobjc-link-runtime -miphoneos-version-min=6.0 -lx264 -framework CoreGraphics -framework UIKit -framework Foundation -Xlinker -dependency_info -Xlinker 
/Users/danieldantas/Library/Developer/Xcode/DerivedData/testingCpp-bvawshyhjcybwvadwwwjqxuomjts/Build/Intermediates/testingCpp.build/Debug-iphoneos/testingCpp.build/Objects-normal/armv7/testingCpp_dependency_info.dat -o 
/Users/danieldantas/Library/Developer/Xcode/DerivedData/testingCpp-bvawshyhjcybwvadwwwjqxuomjts/Build/Products/Debug-iphoneos/testingCpp.app/testingCpp

Any idea how to fix this ?

Thanks

Was it helpful?

Solution

Just found the solution:

The problem was a missing extern "C" surrounding the import statement:

The fixed version:

#import "AppDelegate.h"
extern "C" {
    #import "x264.h"
}

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application 
didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
{        
    x264_param_t x264param;
    x264_param_default(&x264param);

    // Override point for customization after application launch.
    return YES;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top