如何在x86_64架构中修复libluajit?

时间:2015-01-12 06:36:29

标签: xcode cocos2d-x arm64 luajit

我正在尝试编译我的项目,但看到了这个问题

问题:[架构x86_64的未定义符号]

图片:http://i.imgur.com/iDOlwMX.png

我用过: + Cocos2d-2.1rc0-x-2.1.2 + xCode 6.1 + libluajit最新

构建设置:

  • 有效架构:arm64,armv7,armv7s

- >我不知道如何解决这个问题,你能帮我解决一下吗?

非常感谢你!

1 个答案:

答案 0 :(得分:1)

我遇到了和你一样的问题,解决方案如下:

<强> 1。下载luajit v2.1

<强> 2。像这样编辑build_ios.sh:

#!/bin/sh
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
LIPO="xcrun -sdk iphoneos lipo"
STRIP="xcrun -sdk iphoneos strip"

SRCDIR=$DIR/src
DESTDIR=$DIR/prebuilt/ios
IXCODE=`xcode-select -print-path`
ISDK=$IXCODE/Platforms/iPhoneOS.platform/Developer
INFOPLIST_PATH=$IXCODE/Platforms/iPhoneOS.platform/version.plist
BUNDLE_ID=$(/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "${INFOPLIST_PATH}")
ISDKVER=iPhoneOS${BUNDLE_ID}.sdk

if [ "${ISDKVER}" = "iPhoneOS8.0.sdk" ] || [ "${ISDKVER}" = "iPhoneOS8.1.sdk" ]; then
ISDKP=$IXCODE/usr/bin/
else
ISDKP=$ISDK/usr/bin/
fi

if [ ! -e $ISDKP/ar ]; then 
  sudo cp $ISDK/usr/bin/ar $ISDKP
fi

if [ ! -e $ISDKP/ranlib ]; then
  sudo cp $ISDK/usr/bin/ranlib $ISDKP
fi

if [ ! -e $ISDKP/strip ]; then
  sudo cp $ISDK/usr/bin/strip $ISDKP
fi

rm "$DESTDIR"/*.a
cd $SRCDIR


make clean
ISDKF="-arch armv7 -isysroot $ISDK/SDKs/$ISDKVER"
if [ ${ISDKVER} = "iPhoneOS8.0.sdk" ] || [ ${ISDKVER} = "iPhoneOS8.1.sdk" ]; then
make HOST_CC="gcc -m32 -arch i386" TARGET_FLAGS="$ISDKF" TARGET=arm TARGET_SYS=iOS
else
make HOST_CC="gcc -m32 -arch i386" CROSS=$ISDKP TARGET_FLAGS="$ISDKF" TARGET_SYS=iOS
fi
mv "$SRCDIR"/src/libluajit.a "$DESTDIR"/libluajit-armv7.a

make clean
ISDKF="-arch armv7s -isysroot $ISDK/SDKs/$ISDKVER"
if [ ${ISDKVER} = "iPhoneOS8.0.sdk" ] || [ ${ISDKVER} = "iPhoneOS8.1.sdk" ]; then
make HOST_CC="gcc -m32 -arch i386" TARGET_FLAGS="$ISDKF" TARGET=arm TARGET_SYS=iOS
else
make HOST_CC="gcc -m32 -arch i386" CROSS=$ISDKP TARGET_FLAGS="$ISDKF" TARGET_SYS=iOS
fi
mv "$SRCDIR"/src/libluajit.a "$DESTDIR"/libluajit-armv7s.a

make clean
make CC="gcc -m32 -arch i386" clean all
mv "$SRCDIR"/src/libluajit.a "$DESTDIR"/libluajit-i386.a

make clean
ISDKF="-arch arm64 -isysroot $ISDK/SDKs/$ISDKVER"
make HOST_CC="gcc " CROSS="$ISDKP" TARGET_FLAGS="$ISDKF" TARGET=arm64 TARGET_SYS=iOS
mv "$SRCDIR"/src/libluajit.a "$DESTDIR"/libluajit-arm64.a

make clean
make CC="gcc -m64 -arch x86_64" clean all
mv "$SRCDIR"/src/libluajit.a "$DESTDIR"/libluajit-x86_64.a

$LIPO -create "$DESTDIR"/libluajit-*.a -output "$DESTDIR"/libluajit.a
$STRIP -S "$DESTDIR"/libluajit.a
$LIPO -info "$DESTDIR"/libluajit.a

rm "$DESTDIR"/libluajit-*.a

make clean

第3。运行此脚本以创建新的“luajit.a”

<强> 4。 Xcode项目在'其他链接器标志'中添加新参数'-pagezero_size 10000 -image_base 100000000'