Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^3: Problem make'ing Device::USB on osx Snow Leopard 10.6.2

by broomduster (Priest)
on Jan 17, 2010 at 14:47 UTC ( #817864=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Problem make'ing Device::USB on osx Snow Leopard 10.6.2
in thread Problem make'ing Device::USB on osx Snow Leopard 10.6.2

...requires the usb.h C header which is either not present in the latest version of libusb or has a different name.
Actually, it looks as if you have multiple versions of usb.h (hence, multiple installs of libusb) that are being detected. Look carefully through the output you posted and you see lots of things like this:
USB.xs:16: error: conflicting types for ‘libusb_init’ /opt/local/include/libusb-1.0/usb.h:768: error: previous declaration o +f ‘libusb_init’ was here
Now you just need to find the competing version, but I don't see anything in your posted output to help solve that problem.

Update: I looked right past the point Corion mentions, so obviously I don't have the full story. You may need to tweak some settings in Makefile.PL to properly detect the one version of libusb that you want to use.

Update 2: It looks like you are using MacPorts to supply libusb. Since MacPorts has multiple versions available, I'm betting that you have both the "stable" and the "legacy" versions installed, which is why usb.h is found more than once. I don't use MacPorts, so I can't offer any advice about what's the best way out of this, but I do think you need to tell Makefile.PL where to find what it's looking for.


Comment on Re^3: Problem make'ing Device::USB on osx Snow Leopard 10.6.2
Select or Download Code
Re^4: Problem make'ing Device::USB on osx Snow Leopard 10.6.2
by nick.fox (Novice) on Jan 17, 2010 at 16:40 UTC

    Ok that sounds plausible. I have previously tried to compile both libusb 0.1.12Legacy AND libusb 1.0.6(current stable). Unfortunately, libusb 0.1 does not want to compile. so i started copying some of the libusb library files from my ubuntu install. I did also use macports, so I have now cleared out all installed libusb files to remove any related issues.

    Device::USB seems to require the usb.h header from libusb legacy(0.1) as i compiled the latest libusb(1.0.6) on ubuntu but Device::USB would not compile, looking for the usb.h header. I then cleaned out the installed files and built libusb legacy v0.1.12. I then got a compiler error and had to install g++ from apt. It then compiled fine.

    I have not installed g++ or any other compilers on my macbook. Trying to compile libusb 0.1 results in the make error that i put in my original post.(see top of thread).

    Broomduster / Corion; The makefile does allow an environment var to be set with the location of the lib and include directories to use. I have tried setting this to /usr/local/ (libusb 1.0x) and /opt/local/ (macports) but still compile errors occur.

    Im now assuming there is some compiler related issue with building libusb 0.1.12 on snow leopard. unfortunately this is as far as my compiler knowledge extends. thanks for all this help by the way. ive been at this for days!

    libusb legacy v0.1.12 compile time error..

      so i started copying some of the libusb library files from my ubuntu install.
      That is usually not a good idea. Library packages (such as libusb) really need to be installed via their own make procedures to be sure that all files are installed in their proper places so that they all know where to find each other and so that other library packages (such as Device::USB) can know where to find all of them.
      I did also use macports, so I have now cleared out all installed libusb files to remove any related issues.
      What did you use from MacPorts? The libusb port or the libusb-legacy port?
      Device::USB seems to require the usb.h header from libusb legacy(0.1)
      Fair enough.... so you need the "legacy" version on Snow Leopard.
      I have not installed g++ or any other compilers on my macbook.
      Apple's Developer Tools are installed by default on Snow Leopard; so you should have all the compilers you (usually) need for this kind of task. One way to see this is at the 11th line of your output where you see:
      checking for gcc... gcc
      Otherwise, it should have died at that point.

      Update: I stand corrected about Developer Tools on Snow Leopard (thanks dHarry). Nevertheless, it looks like you have some version Developer Tools installed, as some version of gcc is being detected (perhaps from a previous version of Mac OS X?). Make sure you have the latest Developer Tools to ensure compatibility.

      Trying to compile libusb 0.1 results in the make error that i put in my original post.(see top of thread).
      The makefile does allow an environment var to be set with the location of the lib and include directories to use. I have tried setting this to /usr/local/ (libusb 1.0x) and /opt/local/ (macports) but still compile errors occur.
      May I suggest that you use MacPorts to install the libusb-legacy port? If I understand you correctly, you are trying to build it by hand. If you let MacPorts do the heavy lifting, it will (or should) ensure that you have all necessary prerequisites installed and (most important) that the compilations are done with the proper flags to avoid all those warnings about incompatible pointers and such.

      To summarize:

      • Use MacPorts to install libusb-legacy
      • Set the environment variables to build Device::USB to point at the MacPorts install (I think these will be correct for MacPorts):
        • LIBUSB_LIBDIR=/opt/local/lib
        • LIBUSB_INCDIR=/opt/local/include
      Good Luck!

      Disclaimers: I'm not using MacPorts and I'm not running Snow Leopard. YMMV, but HTH.

        Apple's Developer Tools are installed by default on Snow Leopard

        Not true, I just got my Macbook (Mac OS X 10.6.2 Snow Leopard) and it didn't even have a C-compiler! I was trying to install some Perl modules and make was not present. I was recommended to install the xcode stuff (over 1 GB if I recall correctly) and voila gcc is alive again.

        Cheers

        Harry

        Close, but no cigar. I managed to get Device::USB compiled and working out of CPAN with a few tweaks.

        MacPorts libusb-legacy is not what you need - while it does provide the right version of libusb for Device::USB, the dylibs it installs get named in such a way that gcc will only find them if invoked with -lusb-legacy (which it doesn't do). MakeMaker is one hell of a bag of black magic to me, so I've not done any work on figuring out how to change its linker arguments. Instead, the MacPorts packages you need are libusb and libusb-compat. These modules are named correctly, however they install to /opt/local/lib. If you don't want to snoop around in ~/.cpan and fix Device::USB's script yourself, I suggest symlinking /opt/local/lib/libusb.dylib and /opt/local/lib/libusb.a into /usr/local/lib.

        Once you've done your MacPorts dirtywork, you'll be able to install Device::USB out of CPAN. It requires both MakeMaker and Inline::C to be in place beforehand.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://817864]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2014-10-22 01:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (112 votes), past polls