7

I am trying to run the following PCL simple viewer example from http://pointclouds.org/documentation/tutorials/pcl_visualizer.php I have successfully built the binary tree using Cmake and the recommended Cmakelists.txt

After generation, when I try to build it I get the following error :

error LNK2019: unresolved external symbol "public: void __thiscall pcl::visualization::PCLVisualizer::initCameraParameters(void)" (?initCameraParameters@PCLVisualizer@visualization@pcl@@QAEXXZ) referenced in function "class boost::shared_ptr<class pcl::visualization::PCLVisualizer> __cdecl simpleVis(class boost::shared_ptr<class pcl::PointCloud<struct pcl::PointXYZ> const >)" (?simpleVis@@YA?AV?$shared_ptr@VPCLVisualizer@visualization@pcl@@@boost@@V?$shared_ptr@$$CBV?$PointCloud@UPointXYZ@pcl@@@pcl@@@2@@Z)`

error LNK2019: unresolved external symbol "public: void __thiscall pcl::visualization::PCLVisualizer::addCoordinateSystem(double,int)" (?addCoordinateSystem@PCLVisualizer@visualization@pcl@@QAEXNH@Z) referenced in function "class boost::shared_ptr<class pcl::visualization::PCLVisualizer> __cdecl simpleVis(class boost::shared_ptr<class pcl::PointCloud<struct pcl::PointXYZ> const >)" (?simpleVis@@YA?AV?$shared_ptr@VPCLVisualizer@visualization@pcl@@@boost@@V?$shared_ptr@$$CBV?$PointCloud@UPointXYZ@pcl@@@pcl@@@2@@Z)


error LNK2019: unresolved external symbol "public: bool __thiscall pcl::visualization::PCLVisualizer::setPointCloudRenderingProperties(int,double,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int)" (?setPointCloudRenderingProperties@PCLVisualizer@visualization@pcl@@QAE_NHNABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) referenced in function "class boost::shared_ptr<class pcl::visualization::PCLVisualizer> __cdecl simpleVis(class boost::shared_ptr<class pcl::PointCloud<struct pcl::PointXYZ> const >)" (?simpleVis@@YA?AV?$shared_ptr@VPCLVisualizer@visualization@pcl@@@boost@@V?$shared_ptr@$$CBV?$PointCloud@UPointXYZ@pcl@@@pcl@@@2@@Z)

And these are just a few... am I missing something in the cmakelists.txt ?

cmake_minimum_required(VERSION 2.6 FATAL_ERROR)

project(pcl_visualizer_viewports)

find_package(PCL 1.5.1 REQUIRED)

include_directories(${PCL_INCLUDE_DIRS})

link_directories(${PCL_LIBRARY_DIRS})

add_definitions(${PCL_DEFINITIONS})

add_executable (pcl_visualizer_demo pcl_visualizer_demo.cpp)

target_link_libraries (pcl_visualizer_demo ${PCL_LIBRARIES})

Any help is appreciated. Thanks

Flexo
  • 87,323
  • 22
  • 191
  • 272
valentin
  • 1,103
  • 2
  • 16
  • 36

5 Answers5

4

Found what the problem was : Although I am running a 64 bit machine, my compiler (VS2010) is configured for 32 bit so I needed to uninstall the 64 bit Point Cloud Library and install the 32 bit version. Now it works. Lesson learned :D

valentin
  • 1,103
  • 2
  • 16
  • 36
  • The compiler can be used for 32 or 64 bit. The real difference is that you need to set the CMake generator to "Visual Studio 10 Win64" instead of just Visual Studio 10. That will give you a sln with a 64-bit setting. Or just download the 32-bit libs, either approach will work.. :) – tfinniga Sep 17 '12 at 09:54
  • I am using VS 2017 and also 32 bit pcl executable downloaded from http://unanancyowen.com/en/pcl18/ . I get a successful .sln from cmake compilation. However on building the .sln in VS 2017 I get an unresolved linking errors. What could be the reason ? Details are also posted here - https://stackoverflow.com/questions/45300979/viewing-3d-point-cloud-by-integrating-custom-c-api-with-generic-point-cloud-view – tauseef_CuriousGuy Jul 27 '17 at 13:59
1

It looks like you're not linking the PCL libraries. That could be because ${PCL_LIBRARIES} is not set appropriately when running CMake. You could add

message("PCL_LIBRARIES - ${PCL_LIBRARIES}")

to your CMakeLists.txt file after the find_package call to check the value.

If you're using CMake v2.8.8, this bug could be the cause of your problems. Try reverting to v2.8.7.

Fraser
  • 74,704
  • 20
  • 238
  • 215
  • Thank you for your answer. It looks like it is linking all the PCL libraries (even 3rd party ones). I added your line to cmakelists.txt and checked that. I was using Cmake 2.8.7 already so I tried upgrading to 2.8.8 with no luck. I get the same errors regadless of the cmake version I use :(( – valentin Apr 26 '12 at 14:26
0

I think is so complicated can find an error in that way. I have installed PCL in my computer, Windows 7 64 bits and VStudio 2010, the samples run fine.

Be sure of have installed correctly your PCL and dependencies. Please take a look in the downloads section here In my case, I downloaded the "all in one" version.

Follow the instructions, step by step, is not very complicated.

After you can see how is structured the "cmake file" here Try to download the latest version of cmake

And finally, run the basic projects in the PCL website here

Have a nice day

Orlando Herrera
  • 3,481
  • 1
  • 34
  • 44
0

I also had the same problem and I solved by manually linking pcl_visualization.lib file. One can try following steps in visual c++ 2010:

Project Properties -> Linker -> Input -> Additional Dependencies -> Add the file.

In my case, I added G:\PCL\PCL 1.6.0\lib\pcl_visualization_release.lib for release and G:\PCL\PCL 1.6.0\lib\pcl_visualization_debug.lib for debug.

It worked for me.

0

I explained here how to install PCL 1.8.1 all in one installer in windows. And what was the problem just make sure that:

enter image description here

sqp_125
  • 538
  • 6
  • 21