KISS-UI / kiss-ui

A simple UI framework for Rust built on top of IUP (http://webserver2.tecgraf.puc-rio.br/iup/)
MIT License
341 stars 28 forks source link

Build problems with IUP #38

Open ErinCall opened 9 years ago

ErinCall commented 9 years ago

I haven't messed with C libraries much so I'm not sure if this is a problem with kiss-ui, IUP, my system, or me, but I'm getting a build error that I'm not sure how to resolve.

$ cargo build
   Compiling grim-edit v0.0.1 (file:///Users/erincalling/code/grim-edit)
error: linking with `cc` failed: exit code: 1
note: "cc" "-m64" "-L" "/usr/local/Cellar/rust/1.0.0/lib/rustlib/x86_64-apple-darwin/lib" "-o" "/Users/erincalling/code/grim-edit/target/debug/grim_edit" "/Users/erincalling/code/grim-edit/target/debug/grim_edit.o" "-Wl,-force_load,/usr/local/Cellar/rust/1.0.0/lib/rustlib/x86_64-apple-darwin/lib/libmorestack.a" "-Wl,-dead_strip" "-nodefaultlibs" "/Users/erincalling/code/grim-edit/target/debug/deps/libkiss_ui-3b13f82488719214.rlib" "/Users/erincalling/code/grim-edit/target/debug/deps/libiup_sys-4a23062e27aae405.rlib" "/Users/erincalling/code/grim-edit/target/debug/deps/liblibc-ef5cbad4ef5c7a1e.rlib" "/usr/local/Cellar/rust/1.0.0/lib/rustlib/x86_64-apple-darwin/lib/libstd-4e7c5e5c.rlib" "/usr/local/Cellar/rust/1.0.0/lib/rustlib/x86_64-apple-darwin/lib/libcollections-4e7c5e5c.rlib" "/usr/local/Cellar/rust/1.0.0/lib/rustlib/x86_64-apple-darwin/lib/libunicode-4e7c5e5c.rlib" "/usr/local/Cellar/rust/1.0.0/lib/rustlib/x86_64-apple-darwin/lib/librand-4e7c5e5c.rlib" "/usr/local/Cellar/rust/1.0.0/lib/rustlib/x86_64-apple-darwin/lib/liballoc-4e7c5e5c.rlib" "/usr/local/Cellar/rust/1.0.0/lib/rustlib/x86_64-apple-darwin/lib/liblibc-4e7c5e5c.rlib" "/usr/local/Cellar/rust/1.0.0/lib/rustlib/x86_64-apple-darwin/lib/libcore-4e7c5e5c.rlib" "-L" "/Users/erincalling/code/grim-edit/target/debug" "-L" "/Users/erincalling/code/grim-edit/target/debug/deps" "-L" "/usr/local/Cellar/rust/1.0.0/lib/rustlib/x86_64-apple-darwin/lib" "-L" "/Users/erincalling/code/grim-edit/.rust/lib/x86_64-apple-darwin" "-L" "/Users/erincalling/code/grim-edit/lib/x86_64-apple-darwin" "-liup" "-lc" "-lm" "-lSystem" "-lpthread" "-lc" "-lm" "-lcompiler-rt"
note: Undefined symbols for architecture x86_64:
  "_gtk_range_set_value", referenced from:
      _gtkValSetValueAttrib in libiup.a(iupgtk_val.o)
      _gtkValKeyPressEvent in libiup.a(iupgtk_val.o)
      _gtkValChangeValue in libiup.a(iupgtk_val.o)
  "_gtk_adjustment_new", referenced from:
      _gtkValMapMethod in libiup.a(iupgtk_val.o)
  "_gtk_hscale_new", referenced from:
      _gtkValMapMethod in libiup.a(iupgtk_val.o)

{ 600 other symbols snipped }

ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

error: aborting due to previous error
Could not compile `grim-edit`.

To learn more, run the command again with --verbose.

full, un-snipped error

This is on OSX 10.10.3 after installing IUP using the "precompiled binary" instructions in the README. I'm using cargo 0.4.0-nightly (b48cd46 2015-07-01) (built 2015-07-01) and rustc 1.0.0 (built 2015-05-16)

I'd appreciate any help you can offer!

abonander commented 9 years ago

_gtk_range_set_value, _gtk_adjustment_new, _gtk_hscale_new, sounds like you need to install GTK+. Sorry, I forgot to add that to the install instructions for OS X. It can be version 2.x or 3.x, IUP can work with both.

I'd really like to see IUP run directly on top of Cocoa but no one has been working on the driver for it.

ErinCall commented 9 years ago

I'm wrestling with that now. I've installed it with Homebrew but can't figure out how to point gcc at it--I'm guessing it's something like INCLUDE_PATH=/usr/local/Cellar/.... cargo build, but I'm not sure what the exact env var is, or what directory level to point it at. Do you know those?

abonander commented 9 years ago

Does this StackOverflow answer help?

ErinCall commented 9 years ago

It doesn't seem to. PKG_CONFIG_PATH=/usr/local/Cellar/gtk+/2.24.28/lib/pkgconfig/ LDFLAGS=-L/usr/local/Cellar/gtk+/2.24.28/lib/ CPPFLAGS=-I /usr/local/Cellar/gtk+/2.24.28/lib/ cargo build gives the same error.

It seems like it's weird that it's saying "undefined symbols" rather than something about failing to find a .h or .o/.so/.dylib file. Is that weird or is that a normal dynamic-linking problem?

abonander commented 9 years ago

Hmm... maybe try installing GTK+3? It might be looking for symbols that are not in 2.x, although I could have sworn it could link with either.

ErinCall commented 9 years ago

No love, but I'm noticing the cc command in the error output doesn't list the gtk paths I'm putting in PKG_CONFIG_PATH/LDFLAGS/CPPFLAGS. Should I be looking at how to specify them in Cargo.toml?

abonander commented 9 years ago

It's trying to static-link to GTK+ because it's static-linking to IUP. Did you install IUP with ./install (dynamic) or ./install_dev (static)? It might work better with dynamic linking because IUP will find it at runtime.

ErinCall commented 9 years ago

Both. I think I did install_dev first, then tried install when I had trouble

abonander commented 9 years ago

All right, maybe try uninstalling and then just doing install.

ErinCall commented 9 years ago

Ok, that gives me ld: library not found for -liup which is at least a different error. Thanks for your fast responses on this :) I'm gonna take a break from bashing my face against it, and try to resolve the ld error later.

abonander commented 9 years ago

Progress! Don't get discouraged, link errors are always a pain to deal with. You should have seen me try to set up this crap on Windows so I could write the install instructions for it.

ErinCall commented 9 years ago

I got it! The steps that got things working for me were:

PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig/ pkg-config --libs x11 gtk+-2.0

So my working build.rs looks like so:

fn main() {
    // here is gtk
    println!("cargo:rustc-link-search=native=/usr/local/Cellar/gtk+/2.24.28/lib");
    println!("cargo:rustc-link-search=native=/usr/local/Cellar/pango/1.36.8/lib");
    println!("cargo:rustc-link-search=native=/usr/local/Cellar/atk/2.16.0/lib");
    println!("cargo:rustc-link-search=native=/usr/local/Cellar/cairo/1.14.2/lib");
    println!("cargo:rustc-link-search=native=/usr/local/Cellar/gdk-pixbuf/2.30.8/lib");
    println!("cargo:rustc-link-search=native=/usr/local/Cellar/glib/2.44.1/lib");
    println!("cargo:rustc-link-search=native=/usr/local/Cellar/pango/1.36.8/lib");
    println!("cargo:rustc-link-search=native=/usr/local/Cellar/glib/2.44.1/lib");
    println!("cargo:rustc-link-search=native=/usr/local/opt/gettext/lib");
    println!("cargo:rustc-link-search=native=/usr/local/Cellar/fontconfig/2.11.1/lib");
    println!("cargo:rustc-link-search=native=/usr/local/Cellar/freetype/2.5.5/lib");
    println!("cargo:rustc-link-lib=dylib=gtk-x11-2.0");
    println!("cargo:rustc-link-lib=dylib=gdk-x11-2.0");
    println!("cargo:rustc-link-lib=dylib=pangocairo-1.0");
    println!("cargo:rustc-link-lib=dylib=atk-1.0");
    println!("cargo:rustc-link-lib=dylib=cairo");
    println!("cargo:rustc-link-lib=dylib=gdk_pixbuf-2.0");
    println!("cargo:rustc-link-lib=dylib=gio-2.0");
    println!("cargo:rustc-link-lib=dylib=pangoft2-1.0");
    println!("cargo:rustc-link-lib=dylib=pango-1.0");
    println!("cargo:rustc-link-lib=dylib=gobject-2.0");
    println!("cargo:rustc-link-lib=dylib=glib-2.0");
    println!("cargo:rustc-link-lib=dylib=intl");
    println!("cargo:rustc-link-lib=dylib=fontconfig");
    println!("cargo:rustc-link-lib=dylib=freetype");

    // here is X11/xquartz
    println!("cargo:rustc-link-search=native=/opt/X11/lib");
    println!("cargo:rustc-link-lib=dylib=X11");
}
abonander commented 9 years ago

Oh, wow. Perhaps the pkg-config crate can streamline this process on platforms where it is available.