0

当我尝试vrpn 7.33在 Mac 上编译时出现以下错误。它说这libusb是为不同的架构编译的,而不是vrpn正在编译的:

Linking CXX executable client_and_server
ld: warning: ignoring file /usr/local/lib/libusb-1.0.dylib, file was built for i386 which is not the architecture being linked (x86_64): /usr/local/lib/libusb-1.0.dylib
Undefined symbols for architecture x86_64:
  "_libusb_claim_interface", referenced from:
      vrpn_Tracker_USB::vrpn_Tracker_USB(char const*, vrpn_Connection*, unsigned short, unsigned short, long) in libvrpnserver.a(vrpn_Tracker.C.o)
      vrpn_Tracker_USB::mainloop() in libvrpnserver.a(vrpn_Tracker.C.o)
  "_libusb_close", referenced from:
      vrpn_Tracker_USB::vrpn_Tracker_USB(char const*, vrpn_Connection*, unsigned short, unsigned short, long) in libvrpnserver.a(vrpn_Tracker.C.o)
      vrpn_Tracker_USB::~vrpn_Tracker_USB() in libvrpnserver.a(vrpn_Tracker.C.o)
      vrpn_Tracker_USB::mainloop() in libvrpnserver.a(vrpn_Tracker.C.o)
  "_libusb_exit", referenced from:
      vrpn_Tracker_USB::vrpn_Tracker_USB(char const*, vrpn_Connection*, unsigned short, unsigned short, long) in libvrpnserver.a(vrpn_Tracker.C.o)
      vrpn_Tracker_USB::~vrpn_Tracker_USB() in libvrpnserver.a(vrpn_Tracker.C.o)
  "_libusb_init", referenced from:
      vrpn_Tracker_USB::vrpn_Tracker_USB(char const*, vrpn_Connection*, unsigned short, unsigned short, long) in libvrpnserver.a(vrpn_Tracker.C.o)
  "_libusb_open_device_with_vid_pid", referenced from:
      vrpn_Tracker_USB::vrpn_Tracker_USB(char const*, vrpn_Connection*, unsigned short, unsigned short, long) in libvrpnserver.a(vrpn_Tracker.C.o)
      vrpn_Tracker_USB::mainloop() in libvrpnserver.a(vrpn_Tracker.C.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [server_src/client_and_server] Error 1
make[1]: *** [server_src/CMakeFiles/client_and_server.dir/all] Error 2
make: *** [all] Error 2

但是,当我重新编译libusb将架构更改为时,x86_64我开始收到以下错误:

Linking CXX executable client_and_server
ld: warning: ignoring file /usr/local/lib/libusb-1.0.dylib, file was built for x86_64 which is not the architecture being linked (i386): /usr/local/lib/libusb-1.0.dylib
Undefined symbols for architecture i386:
  "_libusb_claim_interface", referenced from:
      vrpn_Tracker_USB::vrpn_Tracker_USB(char const*, vrpn_Connection*, unsigned short, unsigned short, long) in libvrpnserver.a(vrpn_Tracker.C.o)
      vrpn_Tracker_USB::mainloop() in libvrpnserver.a(vrpn_Tracker.C.o)
  "_libusb_close", referenced from:
      vrpn_Tracker_USB::vrpn_Tracker_USB(char const*, vrpn_Connection*, unsigned short, unsigned short, long) in libvrpnserver.a(vrpn_Tracker.C.o)
      vrpn_Tracker_USB::~vrpn_Tracker_USB() in libvrpnserver.a(vrpn_Tracker.C.o)
      vrpn_Tracker_USB::mainloop() in libvrpnserver.a(vrpn_Tracker.C.o)
  "_libusb_exit", referenced from:
      vrpn_Tracker_USB::vrpn_Tracker_USB(char const*, vrpn_Connection*, unsigned short, unsigned short, long) in libvrpnserver.a(vrpn_Tracker.C.o)
      vrpn_Tracker_USB::~vrpn_Tracker_USB() in libvrpnserver.a(vrpn_Tracker.C.o)
  "_libusb_init", referenced from:
      vrpn_Tracker_USB::vrpn_Tracker_USB(char const*, vrpn_Connection*, unsigned short, unsigned short, long) in libvrpnserver.a(vrpn_Tracker.C.o)
  "_libusb_open_device_with_vid_pid", referenced from:
      vrpn_Tracker_USB::vrpn_Tracker_USB(char const*, vrpn_Connection*, unsigned short, unsigned short, long) in libvrpnserver.a(vrpn_Tracker.C.o)
      vrpn_Tracker_USB::mainloop() in libvrpnserver.a(vrpn_Tracker.C.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [server_src/client_and_server] Error 1
make[1]: *** [server_src/CMakeFiles/client_and_server.dir/all] Error 2
make: *** [all] Error 2

注意链接器现在是如何搜索原始i386架构的。

为什么vrpn在这两种情况下都抱怨?

4

1 回答 1

0

vrpn正在同时为多个架构编译。这就是为什么libusb单一架构的编译不起作用的原因。

libusb解决方案是使用以下命令序列同时编译两个架构:

./configure
make CFLAGS="-arch x86_64 -arch i386" LDFLAGS="-arch x86_64 -arch i386"
sudo make install

如果您想了解有关在 Mac OS X 中编译通用二进制文件的更多信息,请查看此链接:

于 2015-01-30T05:21:29.810 回答