o2sh / provok

Text rendering
MIT License
72 stars 4 forks source link

cargo build occur error #2

Open defpis opened 3 years ago

defpis commented 3 years ago

when I run make install occur error:

error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-m64" "-arch" "x86_64" "-L" "/Users/bytedance/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" 
......
9225b8e469c32698.rlib" "/Users/bytedance/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-2fe2b8cd4fa63c34.rlib" "/Users/bytedance/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libobject-80083cf4ee7ee3ff.rlib" "/Users/bytedance/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libaddr2line-ddf3832e718029e6.rlib" "/Users/bytedance/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libgimli-ba92c986e8ef2ca8.rlib" "/Users/bytedance/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_demangle-acd0bd456d8da820.rlib" "/Users/bytedance/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libhashbrown-55608c4156e4ecbb.rlib" "/Users/bytedance/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_alloc-4be618026614fdc7.rlib" "/Users/bytedance/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libunwind-fee25922260aa100.rlib" "/Users/bytedance/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcfg_if-38ba3c5cc408e14d.rlib" "/Users/bytedance/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liblibc-899852a009fbe35f.rlib" "/Users/bytedance/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc-5687564a0ccea916.rlib" "/Users/bytedance/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_core-9ed2c58b16cff4ee.rlib" "/Users/bytedance/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcore-244bf5611f93ff45.rlib" "/Users/bytedance/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-70df686e6b4ebf5b.rlib" "-lc++" "-framework" "CoreText" "-framework" "CoreText" "-framework" "CoreText" "-framework" "CoreText" "-framework" "CoreText" "-lfreetype" "-framework" "AppKit" "-framework" "AppKit" "-framework" "QuartzCore" "-framework" "OpenGL" "-framework" "CoreGraphics" "-framework" "CoreFoundation" "-lSystem" "-framework" "CoreVideo" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreFoundation" "-framework" "AppKit" "-framework" "AppKit" "-framework" "QuartzCore" "-framework" "Foundation" "-framework" "Foundation" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreGraphics" "-framework" "CoreFoundation" "-lSystem" "-lobjc" "-liconv" "-lSystem" "-lresolv" "-lc" "-lm" "-liconv"
  = note: Undefined symbols for architecture x86_64:
            "_hb_ft_font_create_referenced", referenced from:
                provok::font::hbwrap::Font::new::hf1dda8deaf9c36e6 in provok.provok.57my01qi-cgu.13.rcgu.o
          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

error: could not compile `provok`

system_profiler:

Hardware Overview:

      Model Name: MacBook Pro
      Model Identifier: MacBookPro16,1
      Processor Name: 6-Core Intel Core i7
      Processor Speed: 2.6 GHz
      Number of Processors: 1
      Total Number of Cores: 6
      L2 Cache (per Core): 256 KB
      L3 Cache: 12 MB
      Hyper-Threading Technology: Enabled
      Memory: 32 GB
      Boot ROM Version: 1037.147.4.0.0 (iBridge: 17.16.16610.0.0,0)
      Serial Number (system): C02D569KMD6R
      Activation Lock Status: Disabled
o2sh commented 3 years ago

Thanks for reporting the issue @defpis , do you have harfbuzz installed on your machine ? if not do a brew install harfbuzz and try again.

tizee commented 3 years ago

First, use pkg-config to check whether harfbuzz is installed.

pkg-config --cflags harfbuzz

If you are using homebrew, then sometimes it's unaware of broken symlinks for dependencies that harfbuzz used.

brew unlink dep-name && brew link dep-name

As far as I know, the harfbuzz's Rust bindings is compiled without FreeType integration APIs. That's to say, you have to setup local patch for harbuzz-sys manually.

provok Cargo.toml:

diff --git a/Cargo.toml b/Cargo.toml
index a3ba62b..185b327 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -23,3 +23,6 @@ serde = {version = "1.0.126", features = ["derive"]}
 serde_json = "1.0.64"
 thiserror = "1.0"
 ttf-parser = "0.12.0"
+
+[patch.crates-io]
+harfbuzz-sys = { path = "../rust-harfbuzz/harfbuzz-sys" }

Local harfbuzz-sys:

diff --git a/harfbuzz-sys/makefile.cargo b/harfbuzz-sys/makefile.cargo
index d0ec7a8..45c5ba2 100644
--- a/harfbuzz-sys/makefile.cargo
+++ b/harfbuzz-sys/makefile.cargo
@@ -32,7 +32,7 @@ CONFIGURE_FLAGS = \
    --enable-static \
    --disable-shared \
    --without-icu \
-   --without-freetype \
+   --without-freetype=auto \
    --without-glib \
    --with-coretext=auto

diff --git a/harfbuzz-sys/wrapper.h b/harfbuzz-sys/wrapper.h
index d2cfc6e..bfbc21c 100644
--- a/harfbuzz-sys/wrapper.h
+++ b/harfbuzz-sys/wrapper.h
@@ -1,3 +1,4 @@
 #include "harfbuzz/src/hb.h"
+#include "harfbuzz/src/hb-ft.h"
 #include "harfbuzz/src/hb-ot.h"
 #include "harfbuzz/src/hb-aat.h"

Re-generate src/bindings.rs via update.sh. BTW, you could skip downloading.