Results 1 to 2 of 2
Hi All,
im compiling using g++,the compiler is reporting error as
undefined reference to `svm_destroy_model'
here is my sample code
Code:
/********svm.h***********/
#ifndef _LIBSVM_H
#define _LIBSVM_H
#define LIBSVM_VERSION 288
#ifdef ...
- 10-21-2011 #1Just Joined!
- Join Date
- Sep 2011
- Posts
- 4
undefined reference problem for a function
Hi All,
im compiling using g++,the compiler is reporting error as
undefined reference to `svm_destroy_model'
here is my sample code
i have tried including body of function svm_destroy_model before line 1892 and including the prototype of the function but no use .....please help me in identifying this errorCode:/********svm.h***********/ #ifndef _LIBSVM_H #define _LIBSVM_H #define LIBSVM_VERSION 288 #ifdef __cplusplus extern "C" { #endif struct svm_model { . . }; void svm_destroy_model(struct svm_model *model); . . #ifdef __cplusplus } #endif #endif // _LIBSVM_H /********svm.cpp******/ void svm_binary_svc_probability(const svm_problem *prob, const svm_parameter *param, double Cp, double Cn, double& probA, double& probB)//this function is defined globally(line 1892) { . . . svm_destroy_model(submodel);//line 1966 . . . } int svm_cross_validation(const svm_problem *prob, const svm_parameter *param, int nr_fold, double *target)//this function is defined globally { . . svm_destroy_model(submodel);//line 2488 . . } void svm_destroy_model(svm_model* model)//defined globally(line 2970) { . . . . }
waiting for your reply.....................
thanx
- 10-22-2011 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
So, you want svm_destroy_model(svm_model*) to have C rather than C++ bindings? Why? What is the purpose of that? In any case, if you want to use C bindings you still need to extern "C" the function, as in:
Otherwise, you have a C-binding declaration, but a C++ definition, which in reality has a totally different function signature, hence the compiler/linker error.Code:extern "C" void svm_destroy_model(struct svm_model* model) { . . . }Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote