Repository: jeaye/ncurses-rs (language: rust)

Issue:
test fail to build on fedora 25:   undefined reference to 'wget_wch'
ncurses 6.0
````
cargo test  --verbose

warning: path `/tmp/ncurses-rs/src/ncurses.rs` was erroneously implicitly accepted for library `ncurses`,
please rename the file to `src/lib.rs` or set lib.path in Cargo.toml
       Fresh libc v0.2.32
       Fresh gcc v0.3.54
       Fresh pkg-config v0.3.9
   Compiling ncurses v5.86.0 (file:///tmp/ncurses-rs)
     Running `rustc --crate-name ex_7 examples/ex_7.rs --crate-type bin --emit=dep-info,link -C debuginfo=2 --cfg 'feature="default"' -C metadata=32c66cdfcc872a56 -C extra-filename=-32c66cdfcc872a56 --out-dir /tmp/ncurses-rs/target/debug/examples -L dependency=/tmp/ncurses-rs/target/debug/deps --extern libc=/tmp/ncurses-rs/target/debug/deps/liblibc-126a44a53dfd6129.rlib --extern ncurses=/tmp/ncurses-rs/target/debug/deps/libncurses-9c81af12678bde21.rlib -C target-cpu=native -L native=/usr/lib64`
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/tmp/ncurses-rs/target/debug/examples/ex_7-32c66cdfcc872a56.ex_70.rust-cgu.o" "/tmp/ncurses-rs/target/debug/examples/ex_7-32c66cdfcc872a56.ex_71.rust-cgu.o" "/tmp/ncurses-rs/target/debug/examples/ex_7-32c66cdfcc872a56.ex_710.rust-cgu.o" "/tmp/ncurses-rs/target/debug/examples/ex_7-32c66cdfcc872a56.ex_711.rust-cgu.o" "/tmp/ncurses-rs/target/debug/examples/ex_7-32c66cdfcc872a56.ex_712.rust-cgu.o" "/tmp/ncurses-rs/target/debug/examples/ex_7-32c66cdfcc872a56.ex_713.rust-cgu.o" "/tmp/ncurses-rs/target/debug/examples/ex_7-32c66cdfcc872a56.ex_714.rust-cgu.o" "/tmp/ncurses-rs/target/debug/examples/ex_7-32c66cdfcc872a56.ex_715.rust-cgu.o" "/tmp/ncurses-rs/target/debug/examples/ex_7-32c66cdfcc872a56.ex_72.rust-cgu.o" "/tmp/ncurses-rs/target/debug/examples/ex_7-32c66cdfcc872a56.ex_73.rust-cgu.o" "/tmp/ncurses-rs/target/debug/examples/ex_7-32c66cdfcc872a56.ex_74.rust-cgu.o" "/tmp/ncurses-rs/target/debug/examples/ex_7-32c66cdfcc872a56.ex_75.rust-cgu.o" "/tmp/ncurses-rs/target/debug/examples/ex_7-32c66cdfcc872a56.ex_76.rust-cgu.o" "/tmp/ncurses-rs/target/debug/examples/ex_7-32c66cdfcc872a56.ex_77.rust-cgu.o" "/tmp/ncurses-rs/target/debug/examples/ex_7-32c66cdfcc872a56.ex_78.rust-cgu.o" "/tmp/ncurses-rs/target/debug/examples/ex_7-32c66cdfcc872a56.ex_79.rust-cgu.o" "-o" "/tmp/ncurses-rs/target/debug/examples/ex_7-32c66cdfcc872a56" "/tmp/ncurses-rs/target/debug/examples/ex_7-32c66cdfcc872a56.crate.allocator.rust-cgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "-L" "/tmp/ncurses-rs/target/debug/deps" "-L" "/usr/lib64" "-L" "/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/tmp/ncurses-rs/target/debug/deps/libncurses-9c81af12678bde21.rlib" "/tmp/ncurses-rs/target/debug/deps/liblibc-126a44a53dfd6129.rlib" "/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ef68455a36f432e0.rlib" "/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_jemalloc-f6e1402098866357.rlib" "/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_system-4217dfafb936c36b.rlib" "/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librand-97fa3d5ef4bd4fdd.rlib" "/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-cf9300d96e8efc7d.rlib" "/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-e6f731c8a56b92a5.rlib" "/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-58100a6f9c048547.rlib" "/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-f59d3752d69fd895.rlib" "/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_unicode-fe3fcd278911a505.rlib" "/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-fcc46f3067b1a58b.rlib" "/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-295aef536590064a.rlib" "-Wl,-Bdynamic" "-l" "ncurses" "-l" "tinfo" "-l" "util" "-l" "dl" "-l" "rt" "-l" "pthread" "-l" "pthread" "-l" "gcc_s" "-l" "c" "-l" "m" "-l" "rt" "-l" "pthread" "-l" "util"
  = note: src/ncurses.rs:349: error: undefined reference to 'wget_wch'
          collect2: error: ld returned 1 exit status
          

error: aborting due to previous error

error: Could not compile `ncurses`.

Caused by:
  process didn't exit successfully: `rustc --crate-name ex_7 examples/ex_7.rs --crate-type bin --emit=dep-info,link -C debuginfo=2 --cfg feature="default" -C metadata=32c66cdfcc872a56 -C extra-filename=-32c66cdfcc872a56 --out-dir /tmp/ncurses-rs/target/debug/examples -L dependency=/tmp/ncurses-rs/target/debug/deps --extern libc=/tmp/ncurses-rs/target/debug/deps/liblibc-126a44a53dfd6129.rlib --extern ncurses=/tmp/ncurses-rs/target/debug/deps/libncurses-9c81af12678bde21.rlib -C target-cpu=native -L native=/usr/lib64` (exit code: 101)
````


Discussion / hints:
Do you have ncursesw installed? (the wide version)

EDIT: Whoops, I got confused by https://www.rpmfind.net/linux/rpm2html/search.php?query=pkgconfig(ncursesw), looks like fedora only has `ncurses-devel`
I couldn't it in the fedora package list
````
dnf search ncursesw
Last metadata expiration check: 1:37:48 ago on Wed Nov 22 00:42:26 2017.
Error: No matches found.
````


````
dnf search ncurses     
Last metadata expiration check: 1:36:25 ago on Wed Nov 22 00:42:26 2017.
=================================================================================================================================================== N/S Matched: ncurses ===================================================================================================================================================
ncurses.x86_64 : Ncurses support utilities
ncurses-libs.x86_64 : Ncurses libraries
ncurses-libs.i686 : Ncurses libraries
ncurses-c++-libs.x86_64 : Ncurses C++ bindings
ncurses-c++-libs.i686 : Ncurses C++ bindings
ncurses-compat-libs.x86_64 : Ncurses compatibility libraries
ncurses-compat-libs.i686 : Ncurses compatibility libraries
ncurses-devel.x86_64 : Development files for the ncurses library
ncurses-devel.i686 : Development files for the ncurses library
ncurses-static.x86_64 : Static libraries for the ncurses library
ncurses-static.i686 : Static libraries for the ncurses library
gambas3-gb-ncurses.x86_64 : Gambas3 component package for ncurses
libyui-ncurses-doc.noarch : Documentation files for libyui-ncurses
libyui-mga-ncurses.i686 : Libyui-Ncurses extensions for Mageia tools
libyui-mga-ncurses.x86_64 : Libyui-Ncurses extensions for Mageia tools
libyui-mga-ncurses-doc.noarch : Documentation files for libyui-mga-ncurses
libyui-ncurses-devel.i686 : Files needed for developing with libyui-ncurses
libyui-ncurses-devel.x86_64 : Files needed for developing with libyui-ncurses
ruby-ncurses.x86_64 : A module for ruby applications for using ncurses interfaces
libyui-mga-ncurses-devel.i686 : Files needed for developing with libyui-mga-ncurses
libyui-mga-ncurses-devel.x86_64 : Files needed for developing with libyui-mga-ncurses
ncurses-base.noarch : Descriptions of common terminals
ncurses-term.noarch : Terminal descriptions
libyui-ncurses.i686 : Character Based User Interface for libyui
libyui-ncurses.x86_64 : Character Based User Interface for libyui
vdr-skincurses.i686 : Shell window skin plugin for VDR
vdr-skincurses.x86_64 : Shell window skin plugin for VDR
nudoku.x86_64 : Ncurses based Sudoku game
perl-Curses.x86_64 : Perl bindings for ncurses
ocaml-curses.x86_64 : OCaml bindings for ncurses
cmus.x86_64 : Ncurses-Based Music Player
tpp.noarch : A ncurses-based presentation tool
dhex.x86_64 : Ncurses based hexadecimal editor with a diff mode
2048-cli-nocurses.x86_64 : The game 2048 for your Linux terminal (non-ncurses)
ncmpcpp.x86_64 : Featureful ncurses based MPD client inspired by ncmpc
ninvaders.x86_64 : Space Invaders clone written in ncurses for cli gaming
wyrd.x86_64 : A ncurses frontend for the calendar application remind
ettercap.i686 : Network traffic sniffer/analyser, NCURSES interface version
ettercap.x86_64 : Network traffic sniffer/analyser, NCURSES interface version
wavemon.x86_64 : Ncurses-based monitoring application for wireless network devices
lpsk31.x86_64 : A ncurses application for ham radio communications using PSK31 digital mode
gridloc.x86_64 : A ncurses console application for the calculation of Maidenhead QRA Locators
````
It also fails for me running on ubuntu with libcurses5, libcurses5-dev, libcursesw5 and libcursesw5-dev installed.
I can see in the output of my build that it is not even trying ncursesw: `-l ncurses`
And it doesn't show up here: https://github.com/jeaye/ncurses-rs/blob/master/build.rs#L48
This solves for this lib itself: https://github.com/jeaye/ncurses-rs/blob/master/Makefile#L23

So I need that on my own project?
So on linux you need this:

```toml
[dependencies.ncurses]
version = "*"
features = ["wide"]
```

On OSX it works without that because the library name happens to be the same.

Fix patch:
diff --git a/.travis.yml b/.travis.yml
index cc947538..570038e1 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,13 @@
-install:
-  - wget http://static.rust-lang.org/dist/rust-nightly-x86_64-unknown-linux-gnu.tar.gz
-  - tar xf rust-nightly-x86_64-unknown-linux-gnu.tar.gz
-  - sudo rust-nightly-x86_64-unknown-linux-gnu/install.sh
+language: rust
+rust:
+  - stable
+  - beta
+  - nightly
+matrix:
+  allow_failures:
+    - rust: nightly
+  fast_finish: true
 script:
-  - cargo build
+  - cargo build --verbose
+  - cargo test --verbose
+  - cargo test --verbose --features wide
diff --git a/examples/ex_7.rs b/examples/ex_7.rs
index 745a6a69..bd765fdf 100644
--- a/examples/ex_7.rs
+++ b/examples/ex_7.rs
@@ -13,6 +13,7 @@ extern crate ncurses;
 use std::char;
 use ncurses::*;
 
+#[cfg(feature = "wide")]
 fn main()
 {
   let locale_conf = LcCategory::all;
@@ -74,3 +75,11 @@ fn main()
   getch();
   endwin();
 }
+
+#[cfg(not(feature = "wide"))]
+fn main() {
+  initscr();
+  printw("This example requires wide character support.");
+  getch();
+  endwin();
+}
diff --git a/src/lib.rs b/src/lib.rs
index e22cb67a..57cf934c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -351,6 +351,7 @@ pub fn mvget_wch(y: i32, x: i32) -> Option<WchResult> {
     }
 }
 
+#[cfg(feature = "wide")]
 pub fn wget_wch(w: WINDOW) -> Option<WchResult> {
     unsafe {
         let mut result = 0;
@@ -368,6 +369,7 @@ pub fn wget_wch(w: WINDOW) -> Option<WchResult> {
     }
 }
 
+#[cfg(feature = "wide")]
 pub fn mvwget_wch(w: WINDOW, y: i32, x: i32) -> Option<WchResult> {
     unsafe {
         let mut result = 0;


Test patch: