Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing to Build on macOS Sierra (Architecture Issue?) #4

Open
Enkerli opened this issue Jun 25, 2017 · 4 comments
Open

Failing to Build on macOS Sierra (Architecture Issue?) #4

Enkerli opened this issue Jun 25, 2017 · 4 comments

Comments

@Enkerli
Copy link

Enkerli commented Jun 25, 2017

Unable to build on my mid-2011 Mac mini running macOS Sierra. Sounds like it might be an issue with the i386 called versus the x86_64 build.

This warning:
ld: warning: ignoring file /usr/local/lib/libusb-1.0.dylib, file was built for x86_64 which is not the architecture being linked (i386): /usr/local/lib/libusb-1.0.dylib
leads to:
ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)

And eventually:

Ld build/mec-api/devices/push2/push2lib/mec.build/Debug/mec-push2.build/Objects-normal/x86_64/libmec-push2.dylib normal x86_64
    cd /Users/alex/Downloads/MEC-master
    export MACOSX_DEPLOYMENT_TARGET=10.12
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -dynamiclib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -L/Users/alex/Downloads/MEC-master/build/release/lib/Debug -F/Users/alex/Downloads/MEC-master/build/release/lib/Debug -filelist /Users/alex/Downloads/MEC-master/build/mec-api/devices/push2/push2lib/mec.build/Debug/mec-push2.build/Objects-normal/x86_64/mec-push2.LinkFileList -install_name @rpath/libmec-push2.dylib -mmacosx-version-min=10.12 -Xlinker -no_deduplicate -dynamiclib -Wl,-headerpad_max_install_names /Users/alex/Downloads/MEC-master/build/libusb/Debug/liblibusb.a /usr/local/lib/libusb-1.0.dylib -framework IOKit -single_module -Xlinker -dependency_info -Xlinker /Users/alex/Downloads/MEC-master/build/mec-api/devices/push2/push2lib/mec.build/Debug/mec-push2.build/Objects-normal/x86_64/mec-push2_dependency_info.dat -o /Users/alex/Downloads/MEC-master/build/mec-api/devices/push2/push2lib/mec.build/Debug/mec-push2.build/Objects-normal/x86_64/libmec-push2.dylib

** BUILD FAILED **


The following build commands failed:
	Ld build/mec-api/devices/push2/push2lib/mec.build/Debug/mec-push2.build/Objects-normal/i386/libmec-push2.dylib normal i386
(1 failure)
@TheTechnobear
Copy link
Owner

TheTechnobear commented Jun 25, 2017

did you follow the instructions in doc/BUILD.md ?
in particular for installing libusb... it looks like you didn't install the universal build of libusb

ps : given this is very much still in development, I suggest you don't just download the code, but rather use git, and clone the repo, then when I update it, it will simply be a matter of doing a git pull

@Enkerli
Copy link
Author

Enkerli commented Jul 2, 2017

Yep, had followed the instructions and it was supposed to have installed libusb with the universal flag active.
Good point about the git pull. Did so with other projects but not this one (was just trying it on my Mac before focusing on other machines).
Tried the whole procedure again. Since brew was telling me libusb was already installed (1.0.21) uninstalled it and reinstalled it (with the --universal flag, of course). But therein lies the rub!

Warning: libusb: this formula has no --universal option so it will be ignored!
==> Downloading https://homebrew.bintray.com/bottles/libusb-1.0.21.sierra.bottle
Already downloaded: /Users/alex/Library/Caches/Homebrew/libusb-1.0.21.sierra.bottle.tar.gz
==> Pouring libusb-1.0.21.sierra.bottle.tar.gz
==> Using the sandbox

So that’s why the universal version of libusb wasn’t installed.
And that’s because “universal” was dropped three months ago:
Homebrew/homebrew-core@e64cea8#diff-ff4bdefe3c6209d82e19dfbf2593093e

@Enkerli
Copy link
Author

Enkerli commented Jul 2, 2017

Built it!
Wasn’t so obvious to revert to the previous version of the libusb.rb formula (resorted to copy-paste), but it worked.
Here’s the file:

class Libusb < Formula
   desc "Library for USB device access"
   homepage "http://libusb.info"
   url "https://github.com/libusb/libusb/releases/download/v1.0.21/libusb-1.0.21.tar.bz2"
   mirror "https://mirrors.ocf.berkeley.edu/debian/pool/main/libu/libusb-1.0/libusb-1.0_1.0.21.orig.tar.bz2"
   sha256 "7dce9cce9a81194b7065ee912bcd55eeffebab694ea403ffb91b67db66b1824b"
 
   bottle do
     cellar :any
     sha256 "e42e21cc9b7cd4223eb8050680ada895bdfcaf9c7e33534002cd21af2f84baf8" => :sierra
     sha256 "e4902b528d0ea0df0d433e349709d3708a9e08191fd2f3c6d5f5ab2989766b9f" => :el_capitan
     sha256 "8831059f7585ed973d983dd82995e1732c240a78f4f7a82e5d5c7dfe27d49941" => :yosemite
   end
 
   head do
     url "https://github.com/libusb/libusb.git"
 
     depends_on "autoconf" => :build
     depends_on "automake" => :build
      depends_on "libtool" => :build
    end
  
    option :universal
    option "without-runtime-logging", "Build without runtime logging functionality"
    option "with-default-log-level-debug", "Build with default runtime log level of debug (instead of none)"
  
    deprecated_option "no-runtime-logging" => "without-runtime-logging"
  
    def install
      ENV.universal_binary if build.universal?
 
      args = %W[--disable-dependency-tracking --prefix=#{prefix}]
      args << "--disable-log" if build.without? "runtime-logging"
      args << "--enable-debug-log" if build.with? "default-log-level-debug"
      
    system "./autogen.sh" if build.head?
    system "./configure", *args
    system "make", "install"
    pkgshare.install "examples"
  end

  test do
    cp_r (pkgshare/"examples"), testpath
    cd "examples" do
      system ENV.cc, "-lusb-1.0", "-L#{lib}", "-I#{include}/libusb-1.0",
             "listdevs.c", "-o", "test"
      system "./test"
    end
  end
end

Saved that as libusb.rb then, from that folder, did: brew install ./libusb.rb --universal (after brew uninstall libusb, of course).

@TheTechnobear
Copy link
Owner

hmm, looks like homebrew is generally removing the universal build option...
presumably there is a way to specify which arch you want to build, as just using the arch of the machine is plain dumb.
I'll take a look next time I'm doing stuff in this area.....
I'll probably just ditch the homebrew (which was kind of a hack for testing anyway) and just get eigend to build libusb natively.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants