Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

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 ( [id://817876]=note: print w/replies, xml ) Need Help??


in reply to Re^3: 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

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..

checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for gawk... no checking for mawk... no checking for nawk... no checking for awk... awk checking whether make sets $(MAKE)... yes checking build system type... i686-apple-darwin10.2.0 checking host system type... i686-apple-darwin10.2.0 checking for style of include used by make... GNU checking for gcc... gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ANSI C... none needed checking dependency style of gcc... gcc3 checking for a sed that does not truncate output... /usr/bin/sed checking for egrep... grep -E checking for ld used by gcc... /usr/libexec/gcc/i686-apple-darwin10/4. +2.1/ld checking if the linker (/usr/libexec/gcc/i686-apple-darwin10/4.2.1/ld) + is GNU ld... no checking for /usr/libexec/gcc/i686-apple-darwin10/4.2.1/ld option to r +eload object files... -r checking for BSD-compatible nm... /usr/bin/nm checking whether ln -s works... yes checking how to recognise dependent libraries... pass_all checking how to run the C preprocessor... gcc -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking dlfcn.h usability... yes checking dlfcn.h presence... yes checking for dlfcn.h... yes checking for g++... g++ checking whether we are using the GNU C++ compiler... yes checking whether g++ accepts -g... yes rm: conftest.dSYM: is a directory checking dependency style of g++... gcc3 checking how to run the C++ preprocessor... g++ -E checking for g77... no checking for f77... no checking for xlf... no checking for frt... no checking for pgf77... no checking for fort77... no checking for fl32... no checking for af77... no checking for f90... no checking for xlf90... no checking for pgf90... no checking for epcf90... no checking for f95... no checking for fort... no checking for xlf95... no checking for ifc... no checking for efc... no checking for pgf95... no checking for lf95... no checking for gfortran... no checking whether we are using the GNU Fortran 77 compiler... no checking whether accepts -g... no checking the maximum length of command line arguments... 65536 checking command to parse /usr/bin/nm output from gcc object... rm: co +nftest.dSYM: is a directory rm: conftest.dSYM: is a directory rm: conftest.dSYM: is a directory rm: conftest.dSYM: is a directory ok checking for objdir... .libs checking for ar... ar checking for ranlib... ranlib checking for strip... strip checking if gcc static flag works... rm: conftest.dSYM: is a director +y yes checking if gcc supports -fno-rtti -fno-exceptions... rm: conftest.dSY +M: is a directory no checking for gcc option to produce PIC... -fno-common checking if gcc PIC flag -fno-common works... rm: conftest.dSYM: is a +directory yes checking if gcc supports -c -o file.o... rm: conftest.dSYM: is a direc +tory yes checking whether the gcc linker (/usr/libexec/gcc/i686-apple-darwin10/ +4.2.1/ld) supports shared libraries... yes checking dynamic linker characteristics... darwin10.2.0 dyld checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... yes configure: creating libtool appending configuration tag "CXX" to libtool checking for ld used by g++... /usr/libexec/gcc/i686-apple-darwin10/4. +2.1/ld checking if the linker (/usr/libexec/gcc/i686-apple-darwin10/4.2.1/ld) + is GNU ld... no checking whether the g++ linker (/usr/libexec/gcc/i686-apple-darwin10/ +4.2.1/ld) supports shared libraries... yes checking for g++ option to produce PIC... -fno-common checking if g++ PIC flag -fno-common works... rm: conftest.dSYM: is a +directory yes checking if g++ supports -c -o file.o... rm: conftest.dSYM: is a direc +tory yes checking whether the g++ linker (/usr/libexec/gcc/i686-apple-darwin10/ +4.2.1/ld) supports shared libraries... yes checking dynamic linker characteristics... darwin10.2.0 dyld checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes appending configuration tag "F77" to libtool checking for what USB OS support... Darwin and/or MacOS 10 checking for gcc... (cached) gcc checking whether we are using the GNU C compiler... (cached) yes checking whether gcc accepts -g... (cached) yes checking for gcc option to accept ANSI C... (cached) none needed checking dependency style of gcc... (cached) gcc3 checking whether gcc and cc understand -c and -o together... rm: conft +est.dSYM: is a directory yes checking for a BSD-compatible install... /usr/bin/install -c checking for ANSI C header files... (cached) yes checking for vprintf... yes checking for _doprnt... no checking for an ANSI C-conforming const... yes checking whether byte ordering is bigendian... no checking limits.h usability... yes checking limits.h presence... yes checking for limits.h... yes checking for unistd.h... (cached) yes checking values.h usability... no checking values.h presence... no checking for values.h... no checking for memmove... yes checking for pkg-config... /opt/local/bin/pkg-config checking if we should build the documentation... auto checking for jade... no checking for openjade... no checking for Doxygen tools... checking for dot... not found checking for doxygen... not found configure: WARNING: Documentation build components not installed. sgml + docs will not be built configure: creating ./config.status config.status: creating Makefile config.status: creating doc/Makefile config.status: creating libusb.spec config.status: creating libusb-config config.status: creating libusb.pc config.status: creating tests/Makefile config.status: creating README config.status: creating INSTALL.libusb config.status: creating usb.h config.status: creating Doxyfile config.status: creating config.h config.status: executing depfiles commands config.status: executing default commands make all-recursive Making all in . if /bin/sh ./libtool --mode=compile gcc -DHAVE_CONFIG_H -I. -Werror + -no-cpp-precomp -g -O2 -g -Wall -MT usb.lo -MD -MP -MF ".deps/usb.Tp +o" -c -o usb.lo usb.c; \ then mv -f ".deps/usb.Tpo" ".deps/usb.Plo"; else rm -f ".deps/usb. +Tpo"; exit 1; fi gcc -DHAVE_CONFIG_H -I. -Werror -no-cpp-precomp -g -O2 -g -Wall -MT u +sb.lo -MD -MP -MF .deps/usb.Tpo -c usb.c -fno-common -DPIC -o .libs/ +usb.o gcc -DHAVE_CONFIG_H -I. -Werror -no-cpp-precomp -g -O2 -g -Wall -MT u +sb.lo -MD -MP -MF .deps/usb.Tpo -c usb.c -o usb.o >/dev/null 2>&1 if /bin/sh ./libtool --mode=compile gcc -DHAVE_CONFIG_H -I. -Werror + -no-cpp-precomp -g -O2 -g -Wall -MT error.lo -MD -MP -MF ".deps/erro +r.Tpo" -c -o error.lo error.c; \ then mv -f ".deps/error.Tpo" ".deps/error.Plo"; else rm -f ".deps/ +error.Tpo"; exit 1; fi gcc -DHAVE_CONFIG_H -I. -Werror -no-cpp-precomp -g -O2 -g -Wall -MT e +rror.lo -MD -MP -MF .deps/error.Tpo -c error.c -fno-common -DPIC -o +.libs/error.o gcc -DHAVE_CONFIG_H -I. -Werror -no-cpp-precomp -g -O2 -g -Wall -MT e +rror.lo -MD -MP -MF .deps/error.Tpo -c error.c -o error.o >/dev/null +2>&1 if /bin/sh ./libtool --mode=compile gcc -DHAVE_CONFIG_H -I. -Werror + -no-cpp-precomp -g -O2 -g -Wall -MT descriptors.lo -MD -MP -MF ".dep +s/descriptors.Tpo" -c -o descriptors.lo descriptors.c; \ then mv -f ".deps/descriptors.Tpo" ".deps/descriptors.Plo"; else r +m -f ".deps/descriptors.Tpo"; exit 1; fi gcc -DHAVE_CONFIG_H -I. -Werror -no-cpp-precomp -g -O2 -g -Wall -MT d +escriptors.lo -MD -MP -MF .deps/descriptors.Tpo -c descriptors.c -fn +o-common -DPIC -o .libs/descriptors.o gcc -DHAVE_CONFIG_H -I. -Werror -no-cpp-precomp -g -O2 -g -Wall -MT d +escriptors.lo -MD -MP -MF .deps/descriptors.Tpo -c descriptors.c -o d +escriptors.o >/dev/null 2>&1 if /bin/sh ./libtool --mode=compile gcc -DHAVE_CONFIG_H -I. -Werror + -no-cpp-precomp -g -O2 -g -Wall -MT darwin.lo -MD -MP -MF ".deps/dar +win.Tpo" -c -o darwin.lo darwin.c; \ then mv -f ".deps/darwin.Tpo" ".deps/darwin.Plo"; else rm -f ".dep +s/darwin.Tpo"; exit 1; fi gcc -DHAVE_CONFIG_H -I. -Werror -no-cpp-precomp -g -O2 -g -Wall -MT d +arwin.lo -MD -MP -MF .deps/darwin.Tpo -c darwin.c -fno-common -DPIC +-o .libs/darwin.o cc1: warnings being treated as errors darwin.c: In function 'usb_get_next_device': darwin.c:257: warning: passing argument 5 of 'IOCreatePlugInInterfaceF +orService' from incompatible pointer type darwin.c: In function 'claim_interface': darwin.c:560: warning: passing argument 5 of 'IOCreatePlugInInterfaceF +orService' from incompatible pointer type darwin.c: In function 'rw_completed': darwin.c:772: warning: cast from pointer to integer of different size darwin.c:772: warning: format '%lu' expects type 'long unsigned int', +but argument 4 has type 'unsigned int' darwin.c:774: warning: cast from pointer to integer of different size darwin.c: In function 'usb_os_find_devices': darwin.c:1067: warning: format '%08lx' expects type 'long unsigned int +', but argument 3 has type 'UInt32' darwin.c:1095: warning: format '%08lx' expects type 'long unsigned int +', but argument 5 has type 'UInt32' make[2]: *** [darwin.lo] Error 1 make[1]: *** [all-recursive] Error 1 make: *** [all] Error 2 </readmore>

I realise this is not directly a perl issue so let me know if im stepping over the boundary here

Replies are listed 'Best First'.
Re^5: Problem make'ing Device::USB on osx Snow Leopard 10.6.2
by broomduster (Priest) on Jan 17, 2010 at 19:21 UTC
    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

        I have a fairly recent version of the Developer tools as my laptop is only a few months old and i installed xcode more recently.

        Secondly, I have now managed to install libusb-legacy using MacPorts and Make now works for Device::USB and it compiles! WOO! .. or so it seems..

        However, on execution of the dump_usb.pl script included with Device::USB it becomes apparent that it has not compiled correctly! gah, i cant win.

        The following is ./configure > make > sudo make install > ./dump_usb.pl

      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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://817876]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-04-18 05:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found