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

When LibSVM is executed from the command line, I can specify -q as an option and everything should be fine. But, when I use it as a library, the -q option is not set programmatically. How can I suppress the output? There are solutions in Java and python, but not in C ++.

+3


source to share


3 answers


You can use the same trick as in svm_train.c .



  • First, define a function that does nothing:

    void print_null(const char *s) {}
    
          

  • Then call the function that sets the print:

    svm_set_print_string_function(&print_null);
    
          

+2


source


LibSVM is also distributed as source code. You can remove all unnecessary fprintf or set the output function pointer information to 0

static int (*info)(const char *fmt,...) = 0;//&printf;

      



and create it again:

nmake -f Makefile.win lib

      

0


source


svm_set_print_string_function([](auto c) {});

      

0


source







All Articles