PointCloudLibrary / PointCloudLibrary/pcl
Support Vector Machine link error
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 11.1k
- Forks
- 4.7k
- Avg merge
- 4d 10h
- Merged PRs (30d)
- 6
Description
Hi Developers,
I have worked a bit an SVM classifier test with PCL and I have few issues.
The svm_wrapper gives me an error to link dlls in visual studio.
Here link error is reported.
Your Environment
- Operating System and version: Windows 10
- Compiler: Visual Studio 2012
- PCL Version: trunk
Expected Behavior
NO link errors
Current Behavior
there is a link error when I try to build any object from the SMV class in visual studio
in file svm_wrapper.h
No link error anymore
Possible Solution
I don't know if it is correct, but I have solved in my local code using PCL_EXPORTS in the following lines:
- class SVM
+class PCL_EXPORTS SVM
- class SVMTrain : public SVM
+ class PCL_EXPORTS SVMTrain : public SVM
- class SVMClassify : public SVM
+ class PCL_EXPORTS SVMClassify : public SVM
the same happen with functions called in svm.h
so here is my code to fix
+#ifdef __cplusplus
+extern "C"
+{
+#if (defined WIN32 || defined _WIN32 || defined WINCE)
+ #define SVMLIB_EXPORTS __declspec(dllexport)
+#else
+ #define SVMLIB_EXPORTS
+#endif
+
+#endif
+ SVMLIB_EXPORTS int svm_get_nr_class (const struct svm_model *model);
+ SVMLIB_EXPORTS void svm_get_labels (const struct svm_model *model, int *label);
+ SVMLIB_EXPORTS void svm_free_model_content (struct svm_model *model_ptr);
+ SVMLIB_EXPORTS void svm_free_and_destroy_model (struct svm_model **model_ptr_ptr);
+ SVMLIB_EXPORTS void svm_destroy_param (struct svm_parameter *param);
Code to Reproduce
if you want to reproduce my error you can use the following code:
cmakelists.txt
cmake_minimum_required (VERSION 2.8 FATAL_ERROR)
project(pcl_SVM_PCD_test)
find_package (PCL 1.8 REQUIRED)
include_directories (${PCL_INCLUDE_DIRS})
include_directories (${CMAKE_BINARY_DIR})
link_directories (${PCL_LIBRARY_DIRS})
add_definitions (${PCL_DEFINITIONS})
add_executable (pcl_SVM_PCD_test pcl_SVM_PCD_test.cpp)
target_link_libraries (pcl_SVM_PCD_test ${PCL_LIBRARIES} )
pcl_SVM_PCD_test.cpp
#include <pcl/ml/svm_wrapper.h>
int main (int argc, char** argv)
{
// Only create objects to use the classifier
pcl::SVMTrain my_svm_trainer; //--> our trainer, to be used for store training data or for a new training procedure
pcl::SVMClassify my_svm_classifier; //--> our classifier
pcl::SVMModel my_svm_model; //--> classifier model, this is automatically generated after the training or loaded for the classification
pcl::SVMParam my_svm_parameters; //--> our own configuration parameters
return (0);
}
COMPILER ANSWER :
1>------ Build started: Project: ZERO_CHECK, Configuration: Release x64 ------
1> Checking Build System
1> CMake does not need to re-run because C:/code/prova2/build/CMakeFiles/generate.stamp is up-to-date.
2>------ Build started: Project: pcl_SVM_PCD_test, Configuration: Release x64 ------
2> Building Custom Rule C:/code/prova2/CMakeLists.txt
2> CMake does not need to re-run because C:\code\prova2\build\CMakeFiles\generate.stamp is up-to-date.
2> pcl_SVM_PCD_test.cpp
2>pcl_SVM_PCD_test.obj : error LNK2019: unresolved external symbol svm_free_model_content referenced in function "public: __cdecl pcl::SVMClassify::~SVMClassify(void)" (??1SVMClassify@pcl@@QEAA@XZ)
2>pcl_SVM_PCD_test.obj : error LNK2019: unresolved external symbol svm_destroy_param referenced in function "public: __cdecl pcl::SVM::~SVM(void)" (??1SVM@pcl@@QEAA@XZ)
2>pcl_SVM_PCD_test.obj : error LNK2019: unresolved external symbol svm_set_print_string_function referenced in function "public: __cdecl pcl::SVMTrain::SVMTrain(void)" (??0SVMTrain@pcl@@QEAA@XZ)
2>C:\code\prova2\build\Release\pcl_SVM_PCD_test.exe : fatal error LNK1120: 3 unresolved externals
========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Context
Build a machine learning algorithm based on the SVM classifier.
On my local code I have made few modifications, I can commit the changes in a branch and then check/pull if you are interested.
I have prepared a tutorial on how to classify point clouds, just in case.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by building the supplied CMakeLists.txt and pcl_SVM_PCD_test.cpp reproduction on Windows, then inspect pcl/ml/svm_wrapper.h and the related svm.h declarations. Compare the unresolved symbols with the linked PCL libraries and the reported export changes. Done means the sample links successfully without unresolved SVM symbols.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- build-system, computer-vision, machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100