2

我正在尝试学习如何使用 Qt Creator 在 C++ 中将 libfreenect 与 PCL 库一起使用。我是使用 c++ 的 n00b,所以最终我在编译示例时遇到了错误:

ld: warning: in /usr/local/lib/libfreenect.dylib, file was built for i386 which is not the architecture being linked (x86_64)
make: Leaving directory `/Users/george/Documents/Qt/OKPCL'
Undefined symbols:
  "_freenect_init", referenced from:
      Freenect::Freenect::Freenect()in OKPCL.o
  "_freenect_select_subdevices", referenced from:
      Freenect::Freenect::Freenect()in OKPCL.o
  "_freenect_process_events", referenced from:
      Freenect::Freenect::operator()()in OKPCL.o
  "_freenect_shutdown", referenced from:
      Freenect::Freenect::~Freenect()in OKPCL.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [OKPCL] Error 1
The process "/usr/bin/make" exited with code 2.
Error while building project OKPCL (target: Desktop)
When executing build step 'Make'

libfreenect 是为我的机器上的 i386 架构构建的(运行 osx 10.6.8)。我注意到 Qt Creator 运行的默认 Make 是这样做的:

make: Entering directory `/Users/george/Documents/Qt/OKPCL'
g++ -headerpad_max_install_names -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -o OKPCL main.o OKPCL.o   -F/Users/george/QtSDK/Desktop/Qt/474/gcc/lib -L/Users/george/QtSDK/Desktop/Qt/474/gcc/lib /usr/local/lib/libfreenect.dylib /usr/local/lib/libpcl_io.dylib /usr/local/lib/libpcl_common.dylib -framework QtCore 

我可以在 .pro 文件中设置一个 Qt 标志,以便将架构设置为 i386 而不是 x86_64 吗?

4

1 回答 1

2
FOO = -arch i386
LIBS = -arch i386
LIBS += $$FOO

或者

CONFIG += i386

编辑

要为特定架构设置 Qt,您必须运行命令提示符,输入 Qt 目录并运行:

configure -embedded i386 -no-webkit

确认后,您将不得不等待一段时间,然后按照说明进行操作。在这里,您还有其他用于配置的标志。它将配置您的 Qt,然后您将重新编译二进制文件。配置后将指导您如何操作。

于 2012-07-01T11:22:05.647 回答