Compilation of libgphoto2 under Cygwin
March 3, 2013 10 Comments
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
autoconf
libtool
pkg-config
GNU make
libusb
gcc-g77
libiconv
gettext
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.
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.
I guess most likely it’s a path issue when some of the camera library is not found. See this post: http://www.diybookscanner.org/forum/viewtopic.php?f=20&t=2532
set CAMLIBS=./camlibs
set IOLIBS=./iolibs
thanks a lot for your answer. It helped me a lot. yes, you have to set CAMLIBS and IOLIBS. There was still a problem, but I found out: you have to put cygusb0.dll also in path, although it does not say that it is needed. Just if anyone has similar problems…
glad to hear you fixed the problem. Actually I’m using the libgphoto2 to enable a clean RAW output from camera, which could not run aside from cygwin, even though all these library is in the same folder.
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.
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
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.
Try this:
https://sourceforge.net/p/libusb-win32/wiki/Home/
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.
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.
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.