Compilation of libgphoto2 under Cygwin

Gphoto2, and its library libgphoto2 is a Linux application enables controlling cameras and downloading images through USB PTP or serial cable. It is of importance if you would like to build a remote controlled camera or automate the time lapse photography with advanced setting, such as altering the shutter speed during sunset with a predefined value, or make exposure at precise moment for solar eclipse. Another feature will be turning on service mode to enable uncooked RAW image download for Nikon DSLRs. Cameras from almost all vendor are supported.

But this package is for Linux, we will need a emulator to work in Windows. Cygwin is one great linux emulator with a core cygwin1.dll to link basic windows API with the Linux API. Application compiled in Cygwin will be saved as a Windows executable (.exe), and can be run from Cygwin command line or directly in windows with DLLs in the same folder. To help newbie who don’t know much about Linux and want quick compilation, here’s a list of package you need to install in order to get a working libgphoto2.

I’m working with the following combination. Unlike Windows and Mac, Linux is a collection of open source package, compatibility is really a big issue. It’s like in the old days when they quote TIFF as Thousands of Incompatible File Format!

Cygwin Setup v2.774 & libgphoto2 v2.5.1.1





GNU make






Except for “GNU make”, make sure you installed the source code for the other packages. Then it should be fine to follow the install procedure.


10 Responses to Compilation of libgphoto2 under Cygwin

  1. j-r says:

    I have a question. I have compiled libgphoto2 in Cygwin with your information. I have now written a program using libgphoto2 to trigger shots. It works when I start it in the cygwin terminal, but when i start it from outside the cygwin terminal, it does not connect to the camera (retval -105). I have to start this program as a child process of another program written in MSVC. So, so do you have any idea how i can start my program from outside the cygwin terminal so that it also connects to the camera? Thanks a lot.

  2. Samir says:

    I tried using this and was able to compile the package however it is not able to detect the camera, it cannot bring in the settings and thus it cannot set it. Not sure what did I miss. I compiled it on windows 10 with cygwin.

    • jackshencn says:

      You’ll need to install libusb driver associated with your camera. The driver for linux is different from windows. Thus for Cygwin to recognize your camera, you’ll need to go to the device manager, find your camera and update driver with libusb

      • Samir says:

        Thanks Jack,

        Is there a documentation on how to install the libusb you mentioned on windows, would it mess up my existing usb connected devices? I downloaded the libusb-win but do not know not know what to do beyond that. Any input would help me move ahead.

      • jackshencn says:

        Try this:

        You could always restore the default win32 driver by uninstalling the libusb driver in your device manager. Then replug your camera to USB should work.

      • SAMIR says:

        Thanks, that seems to work, however it seems flaky, when I issue the command gphoto2 –set-config bulb=1 –wait-event=300s –set-config bulb=0 –wait-event-and-download=5s it hangs. I does take the image but then when I take another image it just hangs and the camera is in a hung state, no matter what I do it would not work, I would have to take the battery then turn on the camera then put the battery in. I need to test more to see if this is consistent behavior.

      • jackshencn says:

        What camera are you trying to interface? AFAIK, if you’re interfacing some older generation nikon DSLR, they do not support long exposure over USB.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: