1

I'm using a CamBoard Nano and Point Cloud Library in a C++ program. It uses a couple other libraries and one main C++ function as of right now. Someone else wrote the code for Windows, and I'm porting it over to Linux (Ubuntu 12.04). I've been able to get the C++ file to compile with a Makefile, but now I'm getting a ton of errors from the object file. I'm new to C++, and I don't understand what they all mean. It looks like they all stem from the same issue, hopefully one change will fix everything.

I was able to work out the errors in the C++ file by installing some Libraries (PCL, VTK, Eigen, OpenNI, etc.). I'll post what I can of the errors below, they fill up more than the entire terminal. I did look around on Google, and I found this: Qt 4.7 + VTK 5.6.1 on Mac OS X 10.6: errors linking projects

I downloaded QT 5.3, but when I use cmake on the example program I get the following error:

-- The C compiler identification is GNU 4.6.3
-- The CXX compiler identification is GNU 4.6.3
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
CMake Error at CMakeLists.txt:20 (message):
  VTK was not built with Qt


-- Configuring incomplete, errors occurred!

I'm trying to fix this now. I'll post my Makefile and errors below, so if anyone knows how to fix this or has advice, please let me know. Thanks!

Makefile:

CC = g++-4.4
CFLAGS = -I ../include -I ~/../../usr/include/pcl-1.7/ -I ~/../../usr/include/eigen3/Eigen/src -I ~/../../usr/include/vtk-5.8
# first location: pmd header files (include, back one directory)
# second location: your pcl header files
# third location: your eigen header files
# fourth location: your vtk header files
LDFLAGS = -L. -lpmdaccess2 -lc

all: main
main: main.cpp copysdk copyplugins
    $(CC) $(CFLAGS)  -c -o main.o main.cpp
    $(CC) $(LDFLAGS) -o main main.o

copysdk:
    cp ../bin/libpmdaccess* ./  # bin folder back one directory

copyplugins:
    cp ../bin/camboardnano* ./

clean: 
    rm main
    rm main.o
    rm camboardnano*
    rm libpmdaccess*

Example of Errors:

main.o: In function `bool pcl::visualization::PCLVisualizer::addArrow<pcl::PointXYZ, pcl::PointXYZ>(pcl::PointXYZ const&, pcl::PointXYZ const&, double, double, double, double, double, double, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)':
main.cpp:(.text._ZN3pcl13visualization13PCLVisualizer8addArrowINS_8PointXYZES3_EEbRKT_RKT0_ddddddRKSsi[bool pcl::visualization::PCLVisualizer::addArrow<pcl::PointXYZ, pcl::PointXYZ>(pcl::PointXYZ const&, pcl::PointXYZ const&, double, double, double, double, double, double, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)]+0xcc): undefined reference to `pcl::console::print(pcl::console::VERBOSITY_LEVEL, char const*, ...)'
main.cpp:(.text._ZN3pcl13visualization13PCLVisualizer8addArrowINS_8PointXYZES3_EEbRKT_RKT0_ddddddRKSsi[bool pcl::visualization::PCLVisualizer::addArrow<pcl::PointXYZ, pcl::PointXYZ>(pcl::PointXYZ const&, pcl::PointXYZ const&, double, double, double, double, double, double, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)]+0x22d): undefined reference to `vtkActor2D::GetProperty()'
main.cpp:(.text._ZN3pcl13visualization13PCLVisualizer8addArrowINS_8PointXYZES3_EEbRKT_RKT0_ddddddRKSsi[bool pcl::visualization::PCLVisualizer::addArrow<pcl::PointXYZ, pcl::PointXYZ>(pcl::PointXYZ const&, pcl::PointXYZ const&, double, double, double, double, double, double, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)]+0x279): undefined reference to `pcl::visualization::PCLVisualizer::addActorToRenderer(vtkSmartPointer<vtkProp> const&, int)'
main.o: In function `bool pcl::visualization::PCLVisualizer::addPointCloud<pcl::PointXYZ>(pcl::PointCloud<pcl::PointXYZ>::ConstPtr const&, pcl::visualization::PointCloudGeometryHandler<pcl::PointXYZ> const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)':
main.cpp:(.text._ZN3pcl13visualization13PCLVisualizer13addPointCloudINS_8PointXYZEEEbRKNS_10PointCloudIT_E8ConstPtrERKNS0_25PointCloudGeometryHandlerIS5_EERKSsi[bool pcl::visualization::PCLVisualizer::addPointCloud<pcl::PointXYZ>(pcl::PointCloud<pcl::PointXYZ>::ConstPtr const&, pcl::visualization::PointCloudGeometryHandler<pcl::PointXYZ> const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)]+0x84): undefined reference to `pcl::console::print(pcl::console::VERBOSITY_LEVEL, char const*, ...)'
main.o: In function `vtkSmartPointer<vtkDataSet>::~vtkSmartPointer()':

These aren't all the errors, but all the errors that would fit in the terminal can be found here:

http://pastebin.com/jgbczK74

One of the things I noticed is that vtkSmartPointer came up a lot. I think that was the first header file that I was notified about when I was trying to compile the C++ code without the VTK library. Don't know if that means anything.

Community
  • 1
  • 1
  • `VTK was not built with Qt` You need to rebuild VTK with the Qt version that you want to use. – drescherjm Jul 11 '14 at 18:30
  • `I'll post my Makefile and errors below` It is recommended that you use CMake for your own application instead of any other method. This will save you from having to enter dozens of library entries. Also the factory initialization in newer versions of vtk. – drescherjm Jul 11 '14 at 18:31
  • Okay, thanks. So to rebuild VTK I need to follow out-of-source build instructions in README.html again? $ cd VTK-build $ ccmake ../VTK $ make – user3738294 Jul 11 '14 at 18:34
  • BTW, VTK-5.X does not build with Qt-5.X. You need Qt-4.7.X or Qt-4.8.X if you use VTK-5.X – drescherjm Jul 11 '14 at 18:36
  • So I went through and installed Qt-4.8, then tried to link it with VTK-5.8 through the menu in ccmake. I had to reinstall PCL and Eigen for whatever reason, and now I'm getting the same error when I try to compile VTK/Examples/GUI/Qt/SimpleView: VTK was not built with QT. What other information do you need from me? – user3738294 Jul 11 '14 at 19:55
  • Also, could someone explain what exactly the error codes I'm getting mean? Is it a problem with linking the libraries? Is that what the .o files do? Why does the .cpp file compile okay after adding the libraries but the .o file does not? Thanks. – user3738294 Jul 11 '14 at 20:01
  • Again you need to rebuild VTK with the version of Qt that you use. – drescherjm Jul 11 '14 at 20:19
  • As for the linker errors: http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix – drescherjm Jul 11 '14 at 20:21
  • I thought I did that. With ccmake, as specified in the instructions, I turned VTK_Group_Qt on, then pressed c to configure. Then I used make. What else is required to rebuild? – user3738294 Jul 11 '14 at 20:21
  • Then you need to build VTK. configuring it is not building. It should take 30+ minutes to build. – drescherjm Jul 11 '14 at 20:22
  • `VTK_Group_Qt` What version of VTK are you using? – drescherjm Jul 11 '14 at 20:22
  • Okay. I'll look into that more next week. Maybe there was an error with make. It didn't take more than 3 minutes. When I originally built it, it did take almost 50 minutes. Thanks for the advice and the information, I'll post an update on Monday. – user3738294 Jul 11 '14 at 20:23
  • I thought I was using V5.8, since in usr/include the folder is 5.8, but VTK_Group_QT was listed under v6 options, and the v5 options weren't there on my ccmake menu. I thought that was strange. Maybe I have both now and they aren't configured correctly. – user3738294 Jul 11 '14 at 20:25
  • Your undefined references are because you need to add the vtk and pcl libraries to your `LDFLAGS = -L. -lpmdaccess2 -lc` line. However I recommend you drop the makefile completely and use CMake to generate your project. You will have to spend some time (a few days) to understand CMake enough to do this. – drescherjm Jul 11 '14 at 20:25
  • Okay. Thanks very much. I'll do that. – user3738294 Jul 11 '14 at 20:26
  • `but VTK_Group_QT was listed under v6 options, and the v5 options weren't there on my ccmake menu. I thought that was strange. – ` Yes it is strange. That is why I asked you about that. Your CMakeCache.txt in the build folder must point to VTK6. – drescherjm Jul 11 '14 at 20:27
  • Okay, I think I fixed the issue. I can run the Example in VTK/Examples/GUI/QT/SimpleView. I'm still getting the same set of error codes when I try to compile my project though. – user3738294 Jul 14 '14 at 17:11
  • Here are the updated error codes: http://pastebin.com/7tadTG3D – user3738294 Jul 14 '14 at 17:21
  • I installed VTK 5.10. In my usr/include directory, vtk-5.8 is still there, and I don't see any vtk-5.10. There are a bunch of vtkqt header files directly in usr/include though – user3738294 Jul 14 '14 at 17:23
  • If you are still using the Makefile from above your undefined references are expected. You are not linking with any of the several dozen vtk libraries or the pcl libraries. Again I would recommend using CMake to generate your Makefile and not do things the hard way unless you are an expert. – drescherjm Jul 14 '14 at 17:27
  • Okay, I'll use CMake. Do you know what I'm missing from my Makefile, just for future reference? Should I use .a and .so libraries? – user3738294 Jul 14 '14 at 18:44
  • I would let someone with more gcc experience answer that. On windows I prefer to link vtk, itk ... statically. – drescherjm Jul 14 '14 at 18:49
  • Update: I finished my CMakeLists.txt: http://pastebin.com/R5ri8uVv . Thanks for your help. – user3738294 Jul 15 '14 at 19:02
  • Yeah, works fine. No more issues. – user3738294 Jul 16 '14 at 01:02
  • Please add an answer and accept it. – David Doria Aug 25 '14 at 15:02

0 Answers0