当LibSVM从命令行执行时,我可以给出-q作为参数,一切都会没问题。但是,当我将其用作库时,没有-q参数可编程设置。那么我该如何抑制输出呢?在Java和Python中存在解决方案,但在C ++中不存在。
First define a function that does nothing:
void print_null(const char *s) {}
Then call the function that sets the printing:
svm_set_print_string_function(&print_null);
svm_set_print_string_function([](auto c) {});
LibSVM也可以作为源代码分发。您可以删除所有不需要的fprintf或将输出函数指针信息设置为0。
static int (*info)(const char *fmt,...) = 0;//&printf;
然后重新构建:
nmake -f Makefile.win lib