Here is a tip for programer for debug any application with using libusb(x) or libuvc.
There’s many way to debug what it going on with gbd when you are using gcc or MinGW (incl. MinGW-W64) , you may feels somehow difficult to control gdb to debug in deep call stacks without IDE like Code::Blocks.
You can use putenv() to set debug mode to print all messages to ‘stdout’ (aka. console, or terminal) .
Preparation
#include "libuvc/libuvc.h" #ifdef DEBUG #include "libusb.h" #include <pthread.h> #endif /// of DEBUG
Enable debugging message
int main (int argc, char ** argv) { #ifdef DEBUG //LIBUSB_DEBUG putenv( "LIBUSB_DEBUG=4" ); #endif ....
Meaning of number appends LIBUSB_DEBUG is this level :
/** \ingroup lib * Log message levels. * - LIBUSB_LOG_LEVEL_NONE (0) : no messages ever printed by the library (default) * - LIBUSB_LOG_LEVEL_ERROR (1) : error messages are printed to stderr * - LIBUSB_LOG_LEVEL_WARNING (2) : warning and error messages are printed to stderr * - LIBUSB_LOG_LEVEL_INFO (3) : informational messages are printed to stdout, warning * and error messages are printed to stderr * - LIBUSB_LOG_LEVEL_DEBUG (4) : debug and informational messages are printed to stdout, * warnings and errors to stderr */ enum libusb_log_level { LIBUSB_LOG_LEVEL_NONE = 0, LIBUSB_LOG_LEVEL_ERROR, LIBUSB_LOG_LEVEL_WARNING, LIBUSB_LOG_LEVEL_INFO, LIBUSB_LOG_LEVEL_DEBUG, };
When you enable this, you can see all debugging messages on your terminal or console.