所以我是过去几个月一直在学习python的诺布。我最近发现了一个名为PyWiiUse的python库,想用它来做一些有趣的WiiMote。由于库只是C库WiiUse的包装器,我发现在开始任何操作之前我必须安装这两个库。
我有一台运行山狮的mac,我在编译和安装WiiUse库时遇到了一些麻烦。 README说使用cmake为源代码生成MakeFile。我在安装cmake,xcode和xcode命令行工具后运行了以下命令。
cd /build_directory
cmake /source_directory
make
make install
cmake成功制作了一个MakeFile,并构建了gnu make软件并安装了一个静态库“libwiiuse.a”和头文件“wiiuse.h”。静态库安装到/ usr / local / lib,头文件安装到/ usr / local / include。
我不知道如何处理stative库。 README文件让我相信我会以libwiiuse.so的形式获得一个链接库。我读了静态库并了解到它们只是编译代码的档案。我将.o文件从存档中解压缩到名为libwiiuse的文件夹中,并运行以下代码:
gcc -shared -o libwiiuse.so io.o os_mac_find.o classic.o ir.o os_mac_interface.o dynamics.o motion_plus.o util.o events.o nunchuk.o wiiboard.o guitar_hero_3.o os_mac.o wiiuse.o
我试图将所有“.o”(对象?)文件编译成一个“.so”(共享对象?)文件。我得到的结果出人意料。
Undefined symbols for architecture x86_64:
"_IOBluetoothNSStringFromDeviceAddress", referenced from:
-[WiiuseDeviceInquiry collectResultsOf:] in os_mac_find.o
"_NSDefaultRunLoopMode", referenced from:
-[WiiuseDeviceInquiry wait] in os_mac_find.o
-[WiiuseWiimote waitForIncomingData:] in os_mac.o
"_OBJC_CLASS_$_IOBluetoothDeviceInquiry", referenced from:
objc-class-ref in os_mac_find.o
_OBJC_CLASS_$_IOBluetoothHostController", referenced from:
objc-class-ref in os_mac_find.o
"_OBJC_CLASS_$_NSAutoreleasePool", referenced from:
objc-class-ref in os_mac_find.o
objc-class-ref in os_mac_interface.o
objc-class-ref in os_mac.o
"_OBJC_CLASS_$_NSData", referenced from:
objc-class-ref in os_mac.o
"_OBJC_CLASS_$_NSDate", referenced from:
objc-class-ref in os_mac_find.o
objc-class-ref in os_mac.o
"_OBJC_CLASS_$_NSLock", referenced from:
objc-class-ref in os_mac.o
"_OBJC_CLASS_$_NSMutableArray", referenced from:
objc-class-ref in os_mac.o
"_OBJC_CLASS_$_NSObject", referenced from:
_OBJC_CLASS_$_WiiuseDeviceInquiry in os_mac_find.o
_OBJC_CLASS_$_WiiuseWiimote in os_mac.o
_OBJC_CLASS_$_WiiuseDisconnectionMessage in os_mac.o
_OBJC_CLASS_$_WiiuseReceivedData in os_mac.o
"_OBJC_CLASS_$_NSRunLoop", referenced from:
objc-class-ref in os_mac_find.o
objc-class-ref in os_mac.o
"_OBJC_METACLASS_$_NSObject", referenced from:
_OBJC_METACLASS_$_WiiuseDeviceInquiry in os_mac_find.o
_OBJC_METACLASS_$_WiiuseWiimote in os_mac.o
_OBJC_METACLASS_$_WiiuseReceivedData in os_mac.o
_OBJC_METACLASS_$_WiiuseDisconnectionMessage in os_mac.o
"__objc_empty_cache", referenced from:
_OBJC_CLASS_$_WiiuseDeviceInquiry in os_mac_find.o
_OBJC_METACLASS_$_WiiuseDeviceInquiry in os_mac_find.o
_OBJC_CLASS_$_WiiuseWiimote in os_mac.o
_OBJC_CLASS_$_WiiuseDisconnectionMessage in os_mac.o
_OBJC_CLASS_$_WiiuseReceivedData in os_mac.o
_OBJC_METACLASS_$_WiiuseWiimote in os_mac.o
_OBJC_METACLASS_$_WiiuseReceivedData in os_mac.o
...
"__objc_empty_vtable", referenced from:
_OBJC_CLASS_$_WiiuseDeviceInquiry in os_mac_find.o
_OBJC_METACLASS_$_WiiuseDeviceInquiry in os_mac_find.o
_OBJC_CLASS_$_WiiuseWiimote in os_mac.o
_OBJC_CLASS_$_WiiuseDisconnectionMessage in os_mac.o
_OBJC_CLASS_$_WiiuseReceivedData in os_mac.o
_OBJC_METACLASS_$_WiiuseWiimote in os_mac.o
_OBJC_METACLASS_$_WiiuseReceivedData in os_mac.o
...
"_objc_msgSend", referenced from:
-[WiiuseDeviceInquiry initWithMemory:maxDevices:timeout:] in os_mac_find.o
-[WiiuseDeviceInquiry start] in os_mac_find.o
-[WiiuseDeviceInquiry wait] in os_mac_find.o
-[WiiuseDeviceInquiry collectResultsOf:] in os_mac_find.o
-[WiiuseDeviceInquiry run] in os_mac_find.o
_wiiuse_os_find in os_mac_find.o
_wiiuse_os_connect_single in os_mac_interface.o
...
"_objc_msgSendSuper2", referenced from:
-[WiiuseDeviceInquiry initWithMemory:maxDevices:timeout:] in os_mac_find.o
-[WiiuseWiimote initWithPtr:device:] in os_mac.o
-[WiiuseWiimote dealloc] in os_mac.o
-[WiiuseReceivedData initWithData:] in os_mac.o
-[WiiuseReceivedData dealloc] in os_mac.o
"_objc_msgSend_fixup", referenced from:
l_objc_msgSend_fixup_release in os_mac_find.o
l_objc_msgSend_fixup_count in os_mac_find.o
l_objc_msgSend_fixup_objectAtIndex_ in os_mac_find.o
l_objc_msgSend_fixup_alloc in os_mac_find.o
l_objc_msgSend_fixup_alloc in os_mac_interface.o
l_objc_msgSend_fixup_release in os_mac_interface.o
l_objc_msgSend_fixup_retain in os_mac.o
...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
所以我几乎被困在这里。我不确定目标文件是否为X86 64架构构建,因此我在所有文件上运行“file”命令,并为每个文件获得相同的结果。
Mach-O 64-bit object x86_64
我知道自己想要做什么可能很容易,但我一直在努力。任何人都可以帮助我吗?
答案 0 :(得分:0)
在Mac上链接静态wiiuse.a库时,还需要链接一些Apple框架。尝试将以下内容添加到CMakeLists.txt:
set(PLATFORM_LIBS)
if(APPLE)
find_library(IOBLUETOOTH_FRAMEWORK
NAMES
IOBluetooth)
find_library(COREFOUNDATION_FRAMEWORK
NAMES
CoreFoundation)
find_library(FOUNDATION_FRAMEWORK
NAMES
Foundation)
list(APPEND PLATFORM_LIBS
${IOBLUETOOTH_FRAMEWORK}
${COREFOUNDATION_FRAMEWORK}
${FOUNDATION_FRAMEWORK})
endif(APPLE)
然后,在创建目标之后,cmake link命令看起来像......
target_link_libraries(${target}
${WIIUSE_LIB}
${PLATFORM_LIBS})
(我认为静态lib会为我们解决这个问题,但我错了。)