Aperture Laboratories Aperture Laboratories - 2 months ago 14
C++ Question

How to suppress output of LibSVM in C++ [library mode]

When LibSVM is executed from command line, i can give -q as a parameter and all will be ok. But, when i use it as a library, there is no -q parameter to set programmatically. How can i suppress the output then? There exist solutions in Java and python, but not in C++.

Answer

You can use the same trick that they do in svm_train.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);