das-labor / panopticon

A libre cross-platform disassembler.
https://panopticon.re
GNU General Public License v3.0
1.43k stars 78 forks source link

Add installation instructions for OS X #145

Closed SebastianAigner closed 8 years ago

SebastianAigner commented 8 years ago

Hi,

I am having a bit of trouble building Panopticon on OS X. Maybe a small tutorial (including dependencies) in the README could help me and others out?

Greetings

jdalegonzalez commented 8 years ago

I got it building and running but after selecting an executable, nothing happens. Here are a couple of notes, I hope they'll help you.

  1. As mentioned in a previous bug, you have to be running the latest rust or else cargo won't parse the .toml file. So... install the latest rust.
  2. You actually need more than just Qt and GLPK. You also need to install cmake and pkg-config
  3. You have to have CMAKE_PREFIX_PATH set to "//clang_64" - on my machine, that's "$HOME/Qt/5.6/clang_64"
  4. You have to have PKG_CONFIG_PATH set to "//clang_64/lib/pkgconfig/" - on my machine, that's "$HOME/Qt/5.6/clang_64/lib/pkgconfig"
  5. For some reason, the Qt 5.6 install for OSX is missing a bunch of ".pc" files. I found them here I unzipped the file and copied the contents into the .../lib/pkgconfig directory. Prevous Qt versions apparently didn't have this problem.
  6. One of the build steps is expecting libraries in the /usr/local/Cellar/qt5/5.6.0 directory. I created /usr/local/Cellar/qt5 (/usr/local/Cellar was already there. I added qt5) and then symlinked ./5.6.0 as $HOME/Qt/5.6/clang_64

That should get it building (I think) but it still won't run. Two more steps to get it running....

  1. You have to fix up the path to the Qt dynamic libraries. the LC_RPATH value isn't getting set correctly. You can do that with the command: install_name_tool -add_rpath ~/Qt/5.6/clang_64/lib ~/panopticon-master/target/release/qtpanopticon or more generally: install_name_tool -add_rpath <full_path_to_qtlibraries> <full_path_to_pantopticon>
  2. To run it, you have to be in the directory that contains the Cargo.toml file (the project root). cd to that directory. If you built without the --release flag, type ./target/debug/qtpanopticon. If you build with the --release flag, type ./target/release/qtpanopticon.

That should get you a running instance. Won't quite work but it's a start.

86me commented 8 years ago

What are the exact issues you are having? I was able to get a working build that passed all tests without doing anything that @jdalegonzalez had to do in order to get a successful build. It was pretty much:

$ brew install rust cmake homebrew/science/glpk
$ cargo build --verbose
$ cargo test --verbose
$ cargo run

Post the verbose output of any failures and I will try to help.

flanfly commented 8 years ago

I recently merged some upstream fixes for qmlrs that fixed some problems with building it on OS X. Maybe try a cargo update followed by cargo run.

SebastianAigner commented 8 years ago

Hi and thank you for your suggestions, I pulled the newest changes, ran cargo update and cargo run, however the compilation still fails for me with

error: linking with `cc` failed: exit code: 1
note: "cc" "-m64" "-L" "/usr/local/Cellar/rust/1.8.0/lib/rustlib/x86_64-apple-darwin/lib" "/private/tmp/panopticon/target/debug/qtpanopticon.0.o" "-o" "/private/tmp/panopticon/target/debug/qtpanopticon" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/private/tmp/panopticon/target/debug" "-L" "/private/tmp/panopticon/target/debug/deps" "-L" "/Users/sebastian/.cargo/git/checkouts/qmlrs-df0b43c41771444c/master/ext/libqmlrswrapper/build" "-F" "/usr/local/Cellar/qt5/5.6.0/lib" "-F" "/usr/local/Cellar/qt5/5.6.0/lib" "-F" "/usr/local/Cellar/qt5/5.6.0/lib" "-F" "/usr/local/Cellar/qt5/5.6.0/lib" "-F" "/usr/local/Cellar/qt5/5.6.0/lib" "-L" "/private/tmp/panopticon/target/debug/build/miniz-sys-fcf0df5bde59c9aa/out" "-L" "/usr/local/Cellar/rust/1.8.0/lib/rustlib/x86_64-apple-darwin/lib" "/private/tmp/panopticon/target/debug/deps/libglpk_sys-12feaad1d6d19270.rlib" "/private/tmp/panopticon/target/debug/deps/liblibc-5eb0f3d71076a4bc.rlib" "/private/tmp/panopticon/target/debug/libpanopticon.rlib" "/private/tmp/panopticon/target/debug/deps/libflate2-4605139603644ff5.rlib" "/private/tmp/panopticon/target/debug/deps/liblazy_static-5e6d9f365bf63baa.rlib" "/private/tmp/panopticon/target/debug/deps/libnum-98981edb917831dc.rlib" "/private/tmp/panopticon/target/debug/deps/librmp_serialize-a72d2094bfea4093.rlib" "/private/tmp/panopticon/target/debug/deps/librmp-acd753c940aae193.rlib" "/private/tmp/panopticon/target/debug/deps/libnum_rational-ee2647e9984d6d27.rlib" "/private/tmp/panopticon/target/debug/deps/libnum_bigint-d5ef62bdcef8e570.rlib" "/private/tmp/panopticon/target/debug/deps/libtempdir-2cdf7b3a831e6ac5.rlib" "/private/tmp/panopticon/target/debug/deps/libbyteorder-47184752740214a3.rlib" "/private/tmp/panopticon/target/debug/deps/libbyteorder-8ad3fd7ac7478b9a.rlib" "/private/tmp/panopticon/target/debug/deps/libminiz_sys-d3fcc71d21a3cba8.rlib" "/private/tmp/panopticon/target/debug/deps/libxdg-642706cc2420dfee.rlib" "/private/tmp/panopticon/target/debug/deps/liblog-342ffb7444a9471d.rlib" "/private/tmp/panopticon/target/debug/deps/libgraph_algos-57151065f7e76037.rlib" "/private/tmp/panopticon/target/debug/deps/libbit_set-c4f14e66c90218ab.rlib" "/private/tmp/panopticon/target/debug/deps/libbit_vec-12b013c81239352c.rlib" "/private/tmp/panopticon/target/debug/deps/libnum_iter-5766581f7597a504.rlib" "/private/tmp/panopticon/target/debug/deps/libnum_integer-8f7844108d7e0eab.rlib" "/private/tmp/panopticon/target/debug/deps/libuuid-ad64362ac96e59a8.rlib" "/private/tmp/panopticon/target/debug/deps/librand-c724acb3942597d1.rlib" "/private/tmp/panopticon/target/debug/deps/libnum_complex-c5081e842367373a.rlib" "/private/tmp/panopticon/target/debug/deps/librustc_serialize-3bc953984ed46e7f.rlib" "/private/tmp/panopticon/target/debug/deps/libnum_traits-14a2d70fdb554c2a.rlib" "/private/tmp/panopticon/target/debug/deps/libqmlrs-67e9a2a42b553f15.rlib" "/private/tmp/panopticon/target/debug/deps/liblibc-38919d24e617a235.rlib" "/usr/local/Cellar/rust/1.8.0/lib/rustlib/x86_64-apple-darwin/lib/libstd-4fda350b.rlib" "/usr/local/Cellar/rust/1.8.0/lib/rustlib/x86_64-apple-darwin/lib/libcollections-4fda350b.rlib" "/usr/local/Cellar/rust/1.8.0/lib/rustlib/x86_64-apple-darwin/lib/librustc_unicode-4fda350b.rlib" "/usr/local/Cellar/rust/1.8.0/lib/rustlib/x86_64-apple-darwin/lib/librand-4fda350b.rlib" "/usr/local/Cellar/rust/1.8.0/lib/rustlib/x86_64-apple-darwin/lib/liballoc-4fda350b.rlib" "/usr/local/Cellar/rust/1.8.0/lib/rustlib/x86_64-apple-darwin/lib/liballoc_jemalloc-4fda350b.rlib" "/usr/local/Cellar/rust/1.8.0/lib/rustlib/x86_64-apple-darwin/lib/liblibc-4fda350b.rlib" "/usr/local/Cellar/rust/1.8.0/lib/rustlib/x86_64-apple-darwin/lib/libcore-4fda350b.rlib" "-l" "glpk" "-l" "c" "-l" "m" "-l" "stdc++" "-framework" "QtQuick" "-framework" "QtGui" "-framework" "QtQml" "-framework" "QtNetwork" "-framework" "QtCore" "-l" "System" "-l" "pthread" "-l" "c" "-l" "m" "-l" "compiler-rt"
note: ld: library not found for -lglpk
clang: error: linker command failed with exit code 1 (use -v to see invocation)

error: aborting due to previous error
error: Could not compile `panopticon`.

Caused by:
  Process didn't exit successfully: `rustc qt/src/main.rs --crate-name qtpanopticon --crate-type bin -g --out-dir /private/tmp/panopticon/target/debug --emit=dep-info,link -L dependency=/private/tmp/panopticon/target/debug -L dependency=/private/tmp/panopticon/target/debug/deps --extern qmlrs=/private/tmp/panopticon/target/debug/deps/libqmlrs-67e9a2a42b553f15.rlib --extern log=/private/tmp/panopticon/target/debug/deps/liblog-342ffb7444a9471d.rlib --extern num=/private/tmp/panopticon/target/debug/deps/libnum-98981edb917831dc.rlib --extern byteorder=/private/tmp/panopticon/target/debug/deps/libbyteorder-8ad3fd7ac7478b9a.rlib --extern rmp_serialize=/private/tmp/panopticon/target/debug/deps/librmp_serialize-a72d2094bfea4093.rlib --extern rustc_serialize=/private/tmp/panopticon/target/debug/deps/librustc_serialize-3bc953984ed46e7f.rlib --extern graph_algos=/private/tmp/panopticon/target/debug/deps/libgraph_algos-57151065f7e76037.rlib --extern flate2=/private/tmp/panopticon/target/debug/deps/libflate2-4605139603644ff5.rlib --extern glpk_sys=/private/tmp/panopticon/target/debug/deps/libglpk_sys-12feaad1d6d19270.rlib --extern lazy_static=/private/tmp/panopticon/target/debug/deps/liblazy_static-5e6d9f365bf63baa.rlib --extern libc=/private/tmp/panopticon/target/debug/deps/liblibc-38919d24e617a235.rlib --extern xdg=/private/tmp/panopticon/target/debug/deps/libxdg-642706cc2420dfee.rlib --extern uuid=/private/tmp/panopticon/target/debug/deps/libuuid-ad64362ac96e59a8.rlib --extern tempdir=/private/tmp/panopticon/target/debug/deps/libtempdir-2cdf7b3a831e6ac5.rlib --extern panopticon=/private/tmp/panopticon/target/debug/libpanopticon.rlib -L native=/Users/sebastian/.cargo/git/checkouts/qmlrs-df0b43c41771444c/master/ext/libqmlrswrapper/build -L framework=/usr/local/Cellar/qt5/5.6.0/lib -L framework=/usr/local/Cellar/qt5/5.6.0/lib -L framework=/usr/local/Cellar/qt5/5.6.0/lib -L framework=/usr/local/Cellar/qt5/5.6.0/lib -L framework=/usr/local/Cellar/qt5/5.6.0/lib -L native=/private/tmp/panopticon/target/debug/build/miniz-sys-fcf0df5bde59c9aa/out` (exit code: 101)

I double-checked with brew, homebrew/science/glpk-4.60 already installed.

Are there some kind of build variables that are maybe missing that I need to add in my environment?

flanfly commented 8 years ago

It's likely a problem with glpk-sys. I don't have access to any Apple hardware to fix it myself, but extending the build.rs of glpk-sys so it emits something like cargo:rustc-link-search=native=(path to libglpk.so) should suffice.

jdalegonzalez commented 8 years ago

For what it's worth, I'm not using brew. That may be why I had to jump through the hoops I did.

flanfly commented 8 years ago

I added a section on how to install Panopticon dependencies on OSX using Homebrew. If you don't use Homebrow, the progess should be pretty easy, too. Just get CMake, Xcode and the Qt 5.5 SDK from upstream and set QTDIR64 to the install directory of the SDK. cargo run should start Panopticon. I had no problems w/ library search paths that @jdalegonzalez mentioned. If there are still problems, please reopen the issue.