问题描述
我没有成功地尝试构建包含在 VTK 5.6.1 发行版 (.../VTK/Examples/GUI/Qt/) 中的 Qt + VTK 示例.这是我正在使用的:- VTK 分布:5.6.1- Qt IDE:Qt creator 2.7.1(基于 Qt 4.7.0)- Mac OS X 版本:10.6.6
I'm UNSUCCESSFULLY trying to build the Qt + VTK examples included in VTK's 5.6.1 distribution (.../VTK/Examples/GUI/Qt/). Here's what I'm using:- VTK distribution: 5.6.1- Qt IDE: Qt creator 2.7.1 (based on Qt 4.7.0)- Mac OS X version: 10.6.6
也在 Qt 的 .pro 项目文件中,我已经包含了我的 vtk 头文件和 lib 目录:
Also in the .pro project file on Qt I've included my vtk headers and lib directories:
INCLUDEPATH +=/Users/catamigue/Documents/Migue/Developer/bin/vtk561/include/vtk-5.6
LIBS += -L/Users/catamigue/Documents/Migue/Developer/bin/vtk561Dyn/lib/vtk-5.6
无论我尝试构建的示例(事件、GraphicView、ImageViewer 还是 SimpleView),在尝试在 Qt Creator 上构建项目后,我总是遇到相同的错误(在 Qt Creator 的构建问题"选项卡中):
Regardless of the example I'm trying to build (Events, GraphicView, ImageViewer or SimpleView), after trying to build the project on Qt creator I always get the same error (in "Build issues" tab on Qt Creator):
:: 错误:未找到符号
:: 错误:collect2:ld 返回 1 个退出状态
也从编译输出"选项卡中,我在构建后得到了这个:
also from the "compile output" tab I get this after building:
ld: 警告:目录 '/tmp/qt-stuff-6474/source/qt-everywhere-opensource-src-4.7.0/lib' 以下 -L 未找到
ld:警告:未找到 -F 之后的目录/tmp/qt-stuff-6474/source/qt-everywhere-opensource-src-4.7.0/lib"
未定义符号:
vtkSmartPointerBase::~vtkSmartPointerBase()",引用自:vtkSmartPointer::~vtkSmartPointer()in simpleview.o
vtkSmartPointer::~vtkSmartPointer()in simpleview.o
vtkSmartPointer::~vtkSmartPointer()in simpleview.o
vtkSmartPointer::~vtkSmartPointer()in simpleview.o
vtkSmartPointer::~vtkSmartPointer()in simpleview.o
vtkAlgorithm::GetOutputPort(int)",引用自:vtkAlgorithm::GetOutputPort() in simpleview.o
vtkActor::New()",引用自:simpleview.o
中的 vtkSmartPointer::New()vtkSphereSource::New()",引用自:simpleview.o
中的 vtkSmartPointer::New()"QVTKWidget::QVTKWidget(QWidget*, QFlags)",引用自:Ui_SimpleView::setupUi(QMainWindow*) in simpleview.o
Ui_SimpleView::setupUi(QMainWindow*) in simpleview.o
vtkRenderer::AddActor(vtkProp*)",引用自:SimpleView::SimpleView() 在 simpleview.o
SimpleView::SimpleView() 在 simpleview.o
SimpleView::SimpleView() 在 simpleview.o
SimpleView::SimpleView() 在 simpleview.o
vtkCubeSource::New()",引用自:simpleview.o
中的 vtkSmartPointer::New()vtkPolyDataMapper::New()",引用自:simpleview.o
中的 vtkSmartPointer::New()vtkSmartPointerBase::vtkSmartPointerBase(vtkObjectBase*, vtkSmartPointerBase::NoReference const&)",引用自:vtkSmartPointer::vtkSmartPointer(vtkSphereSource*, vtkSmartPointerBase::NoReference const&)in simpleview.o
vtkSmartPointer::vtkSmartPointer(vtkCubeSource*, vtkSmartPointerBase::NoReference const&)in simpleview.o
vtkSmartPointer::vtkSmartPointer(vtkPolyDataMapper*, vtkSmartPointerBase::NoReference const&)in simpleview.o
vtkSmartPointer::vtkSmartPointer(vtkActor*, vtkSmartPointerBase::NoReference const&)in simpleview.o
vtkSmartPointer::vtkSmartPointer(vtkRenderer*, vtkSmartPointerBase::NoReference const&)in simpleview.o
vtkRenderer::New()",引用自:simpleview.o
中的 vtkSmartPointer::New()ld:未找到符号
collect2:ld 返回了 1 个退出状态
制作: [01SimpleView.app/Contents/MacOS/01SimpleView] 错误 1*
make:离开目录`/Users/catamigue/Documents/Migue/Polimi/Programming/Qt/Learning code/Qt + VTK + ITK/01SimpleView-build-desktop'
进程/usr/bin/make"退出,代码为 %2.*构建项目 01SimpleView(目标:桌面)时出错*执行构建步骤Make"时
从我在其他论坛上读到的内容来看,这可能是链接过程中出现的错误...我不知道该怎么做!...请提供一些指导,我们将不胜感激...
from what I've read in other forums this might be an error during linking... and I don't know what to do!... Please, some guidance will be really appreciated...
还有一些关于如何在我的 Mac 上构建 vtk5.6.1 的附加信息:
- CMake 版本:2.8.1.
- CMake 参数(使用 CMake 界面,而不是命令行):
Also some additional information of how vtk5.6.1 was built on my Mac:
- CMake version: 2.8.1.
- CMake parameters (using CMake interface, not command line):
BUILD_EXAMPLES = 关闭
BUILD_SHARED_LIBS = 关闭
BUILD_TESTING = 关闭
CMAKE_BUILD_TYPE = 发布
CMAKE_OSX_ARCHITECTURE = x86_64
VTK_USE_GUI_SUPPORT = ON
VTK_USE_QT = 开
我还尝试过使用通用二进制文件重新编译 VTK(通过更改 CMAKE_OSX_ARCHITECTURE)并在 Qt Creator 中以调试和发布模式构建项目......但什么都没有!
I've also tried by recompiling VTK with universal binaries (by changing CMAKE_OSX_ARCHITECTURE) and by building the projects in Qt Creator both in Debug and Release modes... And nothing!
我还成功构建了所有 Qt 示例(不包括 VTK)...
I've also successfully built all of the Qt examples (not including VTK)...
有什么意见吗?
谢谢,米格尔
推荐答案
我不是 VTK 专家,但从您发布的内容来看:
I'm not a VTK guru but from what you posted:
警告
'/tmp/qt-stuff-6474/source/qt-everywhere-opensource-src-4.7.0/lib'未找到以下 -L
是不言自明的.所有其他错误看起来都是上述错误的结果.
is self explanatory. All other errors look like consequence of the one above.
你可以尝试做什么:
检查 VTK 是否编译/安装了 QT 支持.例如你可以尝试编译
Check if VTK was compiled\installed with QT support. For example you can try compiling
/your_vtk_folder/Examples/GUI/Qt/SimpleView/
使用 cmake.如果您正确编译并安装了 QT 和 VTK,那么这样做应该不会有任何问题.
using cmake. If you have QT and VTK compiled and installed correctly you shouldn't have any problems doing this.
接下来仔细检查 vtk 包含文件和库的安装位置.在我的机器上文件夹是:
Next double check where vtk include files and libraries were installed. On my machine folders are:
头文件:/usr/local/include/vtk-5.6
headers: /usr/local/include/vtk-5.6
库:/usr/local/lib/vtk-5.6/
libs: /usr/local/lib/vtk-5.6/
在您的 *.pro 文件中,您可以添加以下内容:
In your *.pro file you can add following:
INCLUDEPATH +=/usr/local/include/vtk-5.6
INCLUDEPATH += /usr/local/include/vtk-5.6
LIBS += -L/usr/local/lib/vtk-5.6/-lvtkCommon -lvtksys -lQVTK ...您的项目所需的所有 vtk 库
LIBS += -L/usr/local/lib/vtk-5.6/ -lvtkCommon -lvtksys -lQVTK ... all vtk libs needed for your projects
希望对您有所帮助,问候
hope this helps, regards
这篇关于Mac OS X 10.6 上的 Qt 4.7 + VTK 5.6.1:链接项目时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!