eclubb / ncurses-ruby

A Ruby module for accessing the ncurses library
https://github.com/eclubb/ncurses-ruby
Other
131 stars 29 forks source link

Error while compiling on OSX 10.8.4 with Ruby 2.0-p195 #6

Closed nixpulvis closed 10 years ago

nixpulvis commented 11 years ago
$ make
compiling form_wrap.c
In file included from form_wrap.c:31:
ncurses_wrap.h:76:1: warning: "NCURSES_OPAQUE" redefined
In file included from /usr/include/form.h:38,
                 from form_wrap.h:26,
                 from form_wrap.c:30:
/usr/include/curses.h:109:1: warning: this is the location of the previous definition
form_wrap.c: In function ‘make_arg’:
form_wrap.c:1133: warning: format not a string literal and no format arguments
compiling menu_wrap.c
In file included from menu_wrap.c:27:
ncurses_wrap.h:76:1: warning: "NCURSES_OPAQUE" redefined
In file included from /usr/include/menu.h:42,
                 from menu_wrap.h:27,
                 from menu_wrap.c:26:
/usr/include/curses.h:109:1: warning: this is the location of the previous definition
compiling ncurses_wrap.c
ncurses_wrap.c: In function ‘rbncurshelper_nonblocking_wgetch’:
ncurses_wrap.c:807: error: variable ‘tz’ has initializer but incomplete type
ncurses_wrap.c:807: warning: excess elements in struct initializer
ncurses_wrap.c:807: warning: (near initialization for ‘tz’)
ncurses_wrap.c:807: warning: excess elements in struct initializer
ncurses_wrap.c:807: warning: (near initialization for ‘tz’)
ncurses_wrap.c:807: error: storage size of ‘tz’ isn’t known
ncurses_wrap.c:831: warning: ‘rb_thread_select’ is deprecated (declared at /Users/nixpulvis/.rbenv/versions/2.0.0-p195/include/ruby-2.0.0/ruby/intern.h:412)
make: *** [ncurses_wrap.o] Error 1

Code was cloned from here on Github with 074ab54 as HEAD.

fjaell commented 10 years ago

Same error with ruby 2.1.0 on a Linux system.

eclubb commented 10 years ago

@nixpulvis and @fjaell, can you confirm this fix?

fjaell commented 10 years ago

confirmed, builds again for me on linux with ruby 2.1.1

nixpulvis commented 10 years ago

Running ruby extconf.rb works and outputs the following.

$ ruby extconf.rb 
checking for unistd.h... yes
checking for ncurses.h... yes
checking for wmove() in -lncurses... yes
checking for newscr()... yes
checking for TABSIZE()... yes
checking for ESCDELAY()... yes
checking for keybound()... yes
checking for curses_version()... yes
checking for tigetstr()... yes
checking for getwin()... yes
checking for putwin()... yes
checking for ungetmouse()... yes
checking for mousemask()... yes
checking for wenclose()... yes
checking for mouseinterval()... yes
checking for wmouse_trafo()... yes
checking for mcprint()... yes
checking for has_key()... yes
checking for delscreen()... yes
checking for define_key()... yes
checking for keyok()... yes
checking for resizeterm()... yes
checking for use_default_colors()... yes
checking for use_extended_names()... yes
checking for wresize()... yes
checking for attr_on()... yes
checking for attr_off()... yes
checking for attr_set()... yes
checking for chgat()... yes
checking for color_set()... yes
checking for filter()... yes
checking for intrflush()... yes
checking for mvchgat()... yes
checking for mvhline()... yes
checking for mvvline()... yes
checking for mvwchgat()... yes
checking for mvwhline()... yes
checking for mvwvline()... yes
checking for noqiflush()... yes
checking for putp()... yes
checking for qiflush()... yes
checking for scr_dump()... yes
checking for scr_init()... yes
checking for scr_restore()... yes
checking for scr_set()... yes
checking for slk_attr_off()... yes
checking for slk_attr_on()... yes
checking for slk_attr()... yes
checking for slk_attr_set()... yes
checking for slk_color()... yes
checking for tigetflag()... yes
checking for tigetnum()... yes
checking for use_env()... yes
checking for vidattr()... yes
checking for vid_attr()... yes
checking for wattr_on()... yes
checking for wattr_off()... yes
checking for wattr_set()... yes
checking for wchgat()... yes
checking for wcolor_set()... yes
checking for getattrs()... yes
checking which debugging functions to wrap...
checking for _tracef()... no
checking for _tracedump()... no
checking for _nc_tracebits()... no
checking for _traceattr()... no
checking for _traceattr2()... no
checking for _tracechar()... no
checking for _tracechtype()... no
checking for _tracechtype2()... no
checking for _tracemouse()... no
checking for other functions that appeared after ncurses version 5.0...
checking for assume_default_colors()... yes
checking for attr_get()... yes
checking for the panel library...
checking for panel.h... yes
checking for panel_hidden() in -lpanel... yes
checking for the form library...
checking for form.h... yes
checking for new_form() in -lform... yes
checking for the menu library...
checking for menu.h... yes
checking for new_menu() in -lmenu... yes
creating Makefile

However make still fails, but it's a new issue.

$ make           
compiling form_wrap.c
In file included from form_wrap.c:31:
ncurses_wrap.h:76:1: warning: "NCURSES_OPAQUE" redefined
In file included from /usr/include/form.h:38,
                 from form_wrap.h:26,
                 from form_wrap.c:30:
/usr/include/curses.h:109:1: warning: this is the location of the previous definition
compiling menu_wrap.c
In file included from menu_wrap.c:27:
ncurses_wrap.h:76:1: warning: "NCURSES_OPAQUE" redefined
In file included from /usr/include/menu.h:42,
                 from menu_wrap.h:27,
                 from menu_wrap.c:26:
/usr/include/curses.h:109:1: warning: this is the location of the previous definition
compiling ncurses_wrap.c
ncurses_wrap.c: In function ‘rbncurshelper_nonblocking_wgetch’:
ncurses_wrap.c:831: warning: ‘rb_thread_select’ is deprecated (declared at /Users/nixpulvis/.rbenv/versions/2.1.0/include/ruby-2.1.0/ruby/intern.h:440)
compiling panel_wrap.c
In file included from panel_wrap.c:25:
ncurses_wrap.h:76:1: warning: "NCURSES_OPAQUE" redefined
In file included from /usr/include/panel.h:41,
                 from panel_wrap.h:24,
                 from panel_wrap.c:24:
/usr/include/curses.h:109:1: warning: this is the location of the previous definition
linking shared-object ncurses.bundle
ld: warning: directory not found for option '-L/usr/pkg/lib'
eclubb commented 10 years ago

I'm on linux and have no Mac experience. It looks like the linker can't find the /usr/pkg/lib directory. Does that directory exist?

marble-sh commented 10 years ago

Just tested this on my mac now and got a similar problem. The error is in the newly generated Makefile, this line:

ldflags  = -L. -L/Users/mpapis/.sm/pkg/active/lib -L/usr/lib -fPIC -Bstatic -fstack-protector -L/usr/pkg/lib

Commenting it out seems to allow it to build, I think the error stems from the ext/ncurses/extconf.rb file, line 30:

30:$LDFLAGS += " -L/usr/pkg/lib"

Though I do not know enough about this project, or ruby's extconf.rb to suggest a patch. I assume a simple if statement inside the extconf.rb file to only add the LDFLAGS on linux based systems will do... Though it may still fail because of the following flag inside the makefile:

-L/Users/mpapis/.sm/pkg/active/lib

I wasn't able to determine where this was added though.

EDIT:

Maybe something like this? (forgive me if this is crazy hackish)

diff --git a/ext/ncurses/extconf.rb b/ext/ncurses/extconf.rb
index eb3de4c..258b8e3 100755
--- a/ext/ncurses/extconf.rb
+++ b/ext/ncurses/extconf.rb
@@ -27,7 +27,11 @@ $CXXFLAGS  = $CFLAGS

 # Add paths for NetBSD.
 $CFLAGS  += " -I/usr/pkg/include"
-$LDFLAGS += " -L/usr/pkg/lib"
+if (/darwin/ =~ RUBY_PLATFORM) != nil
+  $LDFLAGS = "-L. -L/usr/lib -fPIC -Bstatic -fstack-protector"
+else
+  $LDFLAGS += " -L/usr/pkg/lib"
+end

 have_header("unistd.h")
 if have_header("ncurses.h")
eclubb commented 10 years ago

I'm not able to work on this at the moment, but pull requests are welcome.

marble-sh commented 10 years ago

Done, pull request here: https://github.com/eclubb/ncurses-ruby/commit/87a7f4879fa91509692481dedda9f3ae4b9f927c

I don't know how well it'll hold up over time, though it'll compile (at least for me).

eclubb commented 10 years ago

Fixed by a174b433bc826cef65fbd5fdea500d4b9fe558bd