Recently I decided to install a gphoto2, open source software for controlling digital camera on my Mac computer. It wasn’t very straightforward, but with some help from friends I managed to make it working.
gphoto2 is just an interface - it depends on the library called (surprise, surprise) libgphoto2 and without this library you cannot use it at all. There are two ways of obtaining this library: the first one is to use DarwinPorts and the second - compile everything by yourself.
I really do not recommend compiling libgphoto2 (and libusb, and few other things needed) for many reasons. Probably the most important is, that the newest libgphoto2 (2.2.1) will not compile under Mac OSX. Few people tried, including myself and nobody succeeded at that. Interestingly, the previous version (2.1.6) will compile and install without any problems BUT it will not work anyway.
Now, when I convinced you to use DarwinPorts, here’s the procedure I used to make gphoto2 working under OSX:
1. Install DarwinPorts and then, install libgphoto2 (available from libgphoto2.darwinports.com) with command: sudo port install libgphoto2. It will download all needed libraries for you and install all of them under /opt/.
2. Download gphoto2, unpack, go to it’s directory and configure with: configure –prefix=/opt/local. The script is not smart enough to search for libraries at /opt/local directory unless you’ve added this to global libraries path. Type then, make, and sudo make install. You will most probably need to provide your password. Remember, that it will be installed under /opt/local/bin - you may want to adjust your $PATH variable.
3. Now is the trick I couldn’t find elsewhere. When your camera (set to PTP mode, remember?) is connected to the computer, kill the process named (all in one line):
/System/Library/Image Capture/Devices/PTPCamera.app/Contents/MacOS/PTPCamera
with a kill command. It’s necessary, otherwise gphoto2 will not be able to capture proper usb device.
That’s all.
After connecting my Nikon D70 I was able to trigger capturing - using gphoto2 –capture-image command.
All command line options of gphoto2 you may find on its man page. For features list go to the Gphoto Project home page.
Tags: No Tags








16 comments
Comments feed for this article
February 23rd, 2007 at 6:19 pm
Pingback from New Media Initiatives Blog » Party People Tech Details
September 25th, 2006 at 10:21 pm
Justin
Thanks for the help and the tips!
December 27th, 2006 at 6:35 am
tie
I tried this with the last thee versions of gphoto, but got the same error for each one running the configure script. It terminates with:
checking whether popt is required… yes
checking popt.h usability… no
checking popt.h presence… no
checking for popt.h… no
checking popt.h usability… no
checking popt.h presence… no
checking for popt.h… no
configure: error:
* Cannot autodetect popt.h
*
* Set POPT_CFLAGS and POPT_LIBS correctly.
I’ll post again if I figure out what popt is.
December 27th, 2006 at 6:42 am
tie
I installed popt with darwinports (sudo port install popt), but installation still fails on popt:
checking whether popt is required… yes
checking popt.h usability… yes
checking popt.h presence… yes
checking for popt.h… yes
checking for poptStuffArgs in -lpopt… no
checking for poptStuffArgs in -lpopt… no
checking for poptStuffArgs in -lpopt… no
checking for poptStuffArgs in -lpopt… no
checking for poptStuffArgs in -lpopt… no
configure: error:
* Cannot autodetect library directory containing popt
*
* Set POPT_CFLAGS and POPT_LIBS correctly.
December 27th, 2006 at 10:56 am
Ynse
As far as I remember I forced the configure script to disable POPT. With POPT enabled I couldn’t install it at all. Here’s summary of my configuration:
This version of gphoto2 is using the following software versions and options:
gphoto2 2.1.6 gcc, no popt, no exif, no cdk, no aa, no jpeg, no readline
libgphoto2 2.1.6 gcc, no EXIF, ltdl, no /proc/meminfo
libgphoto2_port 0.5.1 gcc, USB, serial without locking, ltdl
December 28th, 2006 at 6:53 am
tie
It appears popt is required for the latest gphoto versions. This includes gphoto 2.2.0, even though the configure script still has –disable-popt as a nonfunctional option!
Going back to gphoto 2.1.6 and running “./configure –prefix=/opt/local –disable-popt” worked. I’ll see if I can get it working with my D80.
Thanks very much.
December 28th, 2006 at 7:09 am
tie
Yes, it works!
January 10th, 2007 at 6:15 pm
Paul
I’ve just managed to compile libgphoto2 and gphoto2 from the 2.3.1 gphoto-suite package.
To do this I had to install libusb from macports (was darwinports) and I already had libexif and popt installed. I’ve yet to test it fully but it’s looking good so far.
Looks like the problems of 2.2 could be behind us.
January 20th, 2007 at 1:52 pm
Menno
Hi all,
Well I try to do the same thing with my Mac. But I can’t get it to work.. I am what new to this kind of installing. But it seems like it installs just fine.
But when I run the program with the summery option I get the following error:
root# ./gphoto2 –summary
*** Error ***
An error occurred in the io-library (’Could not claim the USB device’): Could not claim interface 0 (m). Make sure no other program or kernel module (such as sdc2xx, stv680, spca50x) is using the device and you have read/write access to the device.
*** Error (-53: ‘Could not claim the USB device’) ***
For debugging messages, please use the –debug option.
Debugging messages may help finding a solution to your problem.
If you intend to send any error or debug messages to the gphoto
developer mailing list , please run
gphoto2 as follows:
env LANG=C gphoto2 –debug –debug-logfile=my-logfile.txt –summary
Please make sure there is sufficient quoting around the arguments.
Do you perhaps know what to make of this ??
(the camera is a Nikon D70, connected on usb with PTP)
January 21st, 2007 at 10:23 pm
Ynse
Paul, I’m glad it’s working now, I will try to update gphoto on my Mac.
Menno, did you try to kill the PTPCamera process? What libraries versions o you use?
I will try to make a major update on the topic following Paul’s information that newest gphoto works pretty well and post it on this site. I don’t work on Mac so much as before, which translates into long delays in trying new things…
February 1st, 2007 at 1:16 am
nigel
I managed to get libgphoto2 and gphoto2 from the 2.3.1 gphoto-suite package to compile also. However, I had to install popt from Macports AND put simlinks from /opt/local/lib and /opt/local/include before configure could find popt
ln -s /opt/local/include/popt.* /usr/include/
ln -s /opt/local/lib/libpopt.* /usr/lib/
February 19th, 2007 at 10:13 am
Menno
Hi all,
sorry I didn’t do this sooner: But it is working now. I didn’t see the process. But with some help i found that that was the problem. Thanks !!
just posting this so everybody knows: ps -ax | grep PTP
February 23rd, 2007 at 5:55 pm
justin
Thanks for the hints everyone. Nice to have one that compiles without too much hacking.
March 22nd, 2007 at 9:06 am
ene
Hi,
I was looking for a tool to remote control my D50 and I found gphoto2 and this post.
I installed DarwinPorts.
I installed libgphoto2 with:
sudo port install libgphoto2
Then I tried doing this:
sudo port install gphoto2
and it worked
Now I’m trying to use gphoto2.3.1
April 28th, 2007 at 4:39 pm
Robert
I just set up libgphoto2 and gphoto2 (2.3.1) on OS X 10.4.9 without DarwinPorts and thought I’d add a couple of nuggets of (hopefully) helpful info to this very helpful page.
I use fink and so have lots of stuff in /sw. Fink can build libgphoto2. It’s not the latest version, but it has a helpful patch script. So, for libgphoto2:
perl -pi -e “s/-g -O/-O/g;s/-O2/-Os/g” configure libgphoto2_port/configure libltdl/configure
./configure –with-extra-libs=/sw/lib –with-extra-includes=/sw/include
And then for gphoto2:
./configure POPT_CFLAGS=”-I/sw/include” POPT_LIBS=”-L/sw/lib -lpopt” CPPFLAGS=”-I/sw/include” LDFLAGS=”-L/sw/lib”
November 9th, 2007 at 2:23 pm
David
I’m trying to compile gphoto2 2.4.0.1 on OS X from svn. I’ve gotten it to work under Linux. This is the first version that will actually capture multiple images with my D70.
libgphoto2 will compile if you change every instance of u_char to unsigned char, u_short to unsigned short, u_long to unsigned long, and u_int to unsigned int.
After creating symlinks as described above:
ln -s /opt/local/include/popt.* /usr/include/
ln -s /opt/local/lib/libpopt.* /usr/lib/
It was possible to configure gphoto2:
./configure –with-libgphoto2=/usr/local/
No success yet compiling though.