2

我正在尝试从 openhome.org 构建 ohNet UPnP 堆栈,以便在 iPhone 和 iPhoneSimulator 上执行。我在网络上的各个地方都看到有一个 iOS 端口,并且确实在 Makefile 中有一些关于 iOS 构建的参考。在对 $DEVROOT 和 $SDKROOT 路径进行了一些编辑之后,我可以编译许多源代码,但是构建在以下位置停止并出现错误:

g++ -pthread  -L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/usr/lib/ -arch armv6  -L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/usr/lib/system -shared -shared-libgcc  -o Build/Obj/Mac/arm/Release/libohNet.dylib Build/Obj/Mac/arm/Release/Ascii.o Build/Obj/Mac/arm/Release/AsyncC.o Build/Obj/Mac/arm/Release/AsyncPrivate.o Build/Obj/Mac/arm/Release/Bonjour.o Build/Obj/Mac/arm/Release/Buffer.o Build/Obj/Mac/arm/Release/Discovery.o Build/Obj/Mac/arm/Release/Debug.o Build/Obj/Mac/arm/Release/Converter.o Build/Obj/Mac/arm/Release/CpDeviceCore.o Build/Obj/Mac/arm/Release/CpDeviceC.o Build/Obj/Mac/arm/Release/CpDeviceStd.o Build/Obj/Mac/arm/Release/CpDeviceDvCore.o Build/Obj/Mac/arm/Release/CpDeviceDvStd.o Build/Obj/Mac/arm/Release/CpDeviceDvC.o Build/Obj/Mac/arm/Release/CpDeviceUpnpCore.o Build/Obj/Mac/arm/Release/CpDeviceUpnpC.o Build/Obj/Mac/arm/Release/CpDeviceUpnpStd.o Build/Obj/Mac/arm/Release/CpiDevice.o Build/Obj/Mac/arm/Release/CpiDeviceDv.o Build/Obj/Mac/arm/Release/CpiDeviceUpnp.o Build/Obj/Mac/arm/Release/CpiService.o Build/Obj/Mac/arm/Release/CpiStack.o Build/Obj/Mac/arm/Release/CpiSubscription.o Build/Obj/Mac/arm/Release/CpProxy.o Build/Obj/Mac/arm/Release/CpProxyC.o Build/Obj/Mac/arm/Release/CpServiceC.o Build/Obj/Mac/arm/Release/DvDevice.o Build/Obj/Mac/arm/Release/DvDeviceStd.o Build/Obj/Mac/arm/Release/DvDeviceC.o Build/Obj/Mac/arm/Release/DviDevice.o Build/Obj/Mac/arm/Release/DvInvocationC.o Build/Obj/Mac/arm/Release/DvInvocationStd.o Build/Obj/Mac/arm/Release/DviProtocolUpnp.o Build/Obj/Mac/arm/Release/DviProviderSubscriptionLongPoll.o Build/Obj/Mac/arm/Release/DvOpenhomeOrgSubscriptionLongPoll1.o Build/Obj/Mac/arm/Release/DviServer.o Build/Obj/Mac/arm/Release/DviServerUpnp.o Build/Obj/Mac/arm/Release/DviServerWebSocket.o Build/Obj/Mac/arm/Release/DviService.o Build/Obj/Mac/arm/Release/DviStack.o Build/Obj/Mac/arm/Release/DviSubscription.o Build/Obj/Mac/arm/Release/DviPropertyUpdateCollection.o Build/Obj/Mac/arm/Release/DvProvider.o Build/Obj/Mac/arm/Release/DvProviderC.o Build/Obj/Mac/arm/Release/DvServerUpnp.o Build/Obj/Mac/arm/Release/DvServerUpnpC.o Build/Obj/Mac/arm/Release/DeviceXml.o Build/Obj/Mac/arm/Release/Error.o Build/Obj/Mac/arm/Release/EventUpnp.o Build/Obj/Mac/arm/Release/Exception.o Build/Obj/Mac/arm/Release/Fifo.o Build/Obj/Mac/arm/Release/Http.o Build/Obj/Mac/arm/Release/DNSCommon.o Build/Obj/Mac/arm/Release/DNSDigest.o Build/Obj/Mac/arm/Release/mDNS.o Build/Obj/Mac/arm/Release/uDNS.o Build/Obj/Mac/arm/Release/MdnsPlatform.o Build/Obj/Mac/arm/Release/MdnsProvider.o Build/Obj/Mac/arm/Release/Maths.o Build/Obj/Mac/arm/Release/Md5.o Build/Obj/Mac/arm/Release/NetworkAdapterList.o Build/Obj/Mac/arm/Release/Network.o Build/Obj/Mac/arm/Release/Parser.o Build/Obj/Mac/arm/Release/Printer.o Build/Obj/Mac/arm/Release/ProtocolUpnp.o Build/Obj/Mac/arm/Release/Queue.o Build/Obj/Mac/arm/Release/RefCounter.o Build/Obj/Mac/arm/Release/Service.o Build/Obj/Mac/arm/Release/ServiceC.o Build/Obj/Mac/arm/Release/sha1.o Build/Obj/Mac/arm/Release/Ssdp.o Build/Obj/Mac/arm/Release/SsdpDv.o Build/Obj/Mac/arm/Release/Stack.o Build/Obj/Mac/arm/Release/Stream.o Build/Obj/Mac/arm/Release/Subscription.o Build/Obj/Mac/arm/Release/Thread.o Build/Obj/Mac/arm/Release/Timer.o Build/Obj/Mac/arm/Release/Uri.o Build/Obj/Mac/arm/Release/XmlParser.o Build/Obj/Mac/arm/Release/XmlFetcher.o Build/Obj/Mac/arm/Release/OhNet.o Build/Obj/Mac/arm/Release/OhNetCp.o Build/Obj/Mac/arm/Release/OhNetDv.o Build/Obj/Mac/arm/Release/OhNetCombined.o Build/Obj/Mac/arm/Release/OhNetC.o Build/Obj/Mac/arm/Release/OhNetCCp.o Build/Obj/Mac/arm/Release/OhNetCDv.o Build/Obj/Mac/arm/Release/OhNetCCombined.o Build/Obj/Mac/arm/Release/OsWrapper.o Build/Obj/Mac/arm/Release/Os.o 
llvm-g++-4.2: error trying to exec '/usr/bin/../llvm-gcc-4.2/bin/arm-apple-darwin11-llvm-g++-4.2': execvp: No such file or directory
make: *** [ohNetDll] Error 255

我不明白为什么构建过程要为这个平台构建 ohNetDll,也不明白如何选择退出该部分/目标。iOS 应用程序不支持动态库,当然也不支持 Windows 原生的 dll。

如果你已经在 iOS 上构建/移植/使用了 ohNet,你能告诉我怎么做吗?我想在 ohNet 论坛上发布这个问题,但我无法注册(因为我还没有提交安全问题,即使表单上无处可做!)。

ohNet 的源代码、文档和 API 指南看起来都非常有前途,所以我希望你能提供建议......

4

1 回答 1

2

“在对 $DEVROOT 和 $SDKROOT 路径进行一些编辑后,我可以编译许多源代码......”

对于 iPhoneOS 平台,设置以下环境变量。

export ROOTDIR="/Applications/Xcode.app/Contents/Developer"
export PLATFORM="iPhoneOS"
export MAX_VERSION="5.1"
export DEVROOT=${ROOTDIR}/Platforms/${PLATFORM}.platform/Developer
export SDKROOT=${DEVROOT}/SDKs/${PLATFORM}${MAX_VERSION}.sdk

然后,在源的根目录中,在文件“Makefile”中,找到以下部分并确保它与此部分相同:

ifeq ($(MACHINE), Darwin)
ifeq ($(mac-arm),1)
    # Darwin, ARM -> iOS
    platform ?= iOS
    linkopts_ohNet =    
    devroot=$(DEVROOT)
    sdkroot=$(SDKROOT)
    platform_cflags = -I$(sdkroot)/usr/lib/gcc/arm-apple-darwin10/4.2.1/include/ -I$(sdkroot)/usr/include/ -I/usr/bin/arm-apple-darwin10-gcc -miphoneos-version-min=2.2 -pipe -no-cpp-precomp -isysroot $(sdkroot) -DPLATFORM_MACOSX_GNU -DPLATFORM_IOS -I$(sdkroot)/usr/include/c++/4.2.1/armv6-apple-darwin10/ 
    # It seems a bit weird that iOS uses a sub-dir of Build/Obj/Mac, is that deliberate? --AW
    osbuilddir = Mac/arm
    objdir = Build/Obj/Mac/arm/$(build_dir)/
    platform_linkflags = -L$(sdkroot)/usr/lib/ -arch armv7  -L$(sdkroot)/usr/lib/system
    compiler = $(devroot)/usr/bin/llvm-gcc-4.2  -arch armv7 -isysroot $(SDKROOT) -o $(objdir)
    # No support for linking Shared Objects for ARM MAC
    # link = $(devroot)/usr/bin/llvm-gcc-4.2  -pthread -Wl $(platform_linkflags)
    ar = $(devroot)/usr/bin/ar rc $(objdir)
    native_only = yes

这里的关键点是:

  1. $DEVROOT 和 $SDKROOT 对于您的 iOS SDK 版本是正确的。
  2. 变量 $native_only 设置为 yes。当 make 尝试(并且不可避免地失败)在 Mac 主机上构建 ohNetDll 时,这可以避免错误和提前退出。

然后,在终端中,在源根目录(即包含 Makefile 的目录)中键入:

make mac-arm=1

希望这可以帮助...

道格

于 2012-07-02T10:53:14.610 回答