franko / gsl-shell

GSL library shell based on LuaJIT2
http://franko.github.io/gsl-shell/
GNU General Public License v3.0
92 stars 12 forks source link

OSX make error #32

Open ghost opened 5 years ago

ghost commented 5 years ago

Mac OSX sierra & High sierra is make Error. How can I make it?

I used LuaJIT (lujit 2.1.0 beta3)

install is brew.

brew install --with-gc64 --devel luajit
brew install gsl
brew cask install xquartz
brew install fox
git clone https://github.com/franko/gsl-shell
cd gsl-shell
make

error

$ make
make: dpkg-architecture: Command not found
Compiling completion.c
completion.c:7:10: fatal error: 'readline.h' file not found
#include <readline.h>
         ^~~~~~~~~~~~
1 error generated.
make: *** [completion.o] Error 1

readline is brew install

brew list |grep readline
readline

I will try and report any necessary information and survey methods if instructed.

best regards.

franko commented 5 years ago

Hi,

thank you for reporting the problem. I think I found why it happens, is in the file completion.c, the line

#include <readline.h>

should be replaced by:

#include <readline/readline.h>

and it should fix the error. I have already fixed this in the github repository.

Otherwise you may ensure that you have installed the ncurses package as well as gsl, fox and libagg.

Please note also, the error about dpkg-architecture is harmless. The command is just needed on linux to create a debian package.

ghost commented 5 years ago

@franko

Thank you for the quick answer.

I pull the latest and confirmed it.

$ make
make: dpkg-architecture: Command not found
Compiling completion.c
completion.c:8:10: fatal error: 'history.h' file not found
#include <history.h>
         ^~~~~~~~~~~
1 error generated.
make: *** [completion.o] Error 1

Is this also a similar problem?

We are looking forward to using GSL-shell on my machine.

If you have something else to investigate, please tell me.

best regards.

franko commented 5 years ago

Oups, I forgot about history.h, sorry.

Yes it is exactly the same problem, I just added "readline/" in the line including "history.h" like with the line above.

I hope it will works now but let me know.

Kind regards

ghost commented 5 years ago

@franko

Thank you for the quick answer.

I pull the latest and confirmed it.

but make error...

$ make
make: dpkg-architecture: Command not found
Compiling completion.c
completion.c:19:34: warning: incompatible pointer types assigning to
      'Function *' (aka 'int (*)(const char *, int)') from 'char *(const char *,
      int)' [-Wincompatible-pointer-types]
    rl_completion_entry_function = my_generator;
                                 ^ ~~~~~~~~~~~~
completion.c:120:21: error: use of undeclared identifier
      'rl_completion_suppress_append'
                    rl_completion_suppress_append = 1;
                    ^
1 warning and 1 error generated.
make: *** [completion.o] Error 1

Is there a lack of make options or dependent modules?

best regards.

franko commented 5 years ago

Hmmm, very strange. On my system I have libreadline 7.0-3 and the signatures of rl_completion_entry_function match.

Here the extract from completion.c:

static char *my_generator (const char *text, int state);

and from libreadline include files. First readline/readline.h:

#  include <readline/rltypedefs.h>
#  include <readline/keymaps.h>
#  include <readline/tilde.h>
#endif

/* Hex-encoded Readline version number. */
#define RL_READLINE_VERSION     0x0700          /* Readline 7.0 */
#define RL_VERSION_MAJOR        7
#define RL_VERSION_MINOR        0

[...]

/* Completion variables. */
/* Pointer to the generator function for completion_matches ().
   NULL means to use rl_filename_completion_function (), the default
   filename completer. */
extern rl_compentry_func_t *rl_completion_entry_function;

and readline/rltypedefs.h where rl_compentry_func_t is defined:

typedef char *rl_compentry_func_t PARAMS((const char *, int));

So essentially both my_generator and rl_completion_entry_function have the same signature.

In addition it seems that Homebrew is providing the readline package version 7.0.5 as from the list here.

I suggest that you check the version of the readline library you have installed and you may also inspect the file readline/rltypedefs.h.

In alternative you may disable the readline library from makeconfig. Just use:

USE_READLINE = no

I hope now it will works but let me know :-)

ghost commented 5 years ago

@franko

Sorry...

brew link --force readline

Maybe, because the paths of the system 's readline and brew' s readline were mixed.

make next step.

And the next problem occurred.

export CPPFLAGS=-I/opt/X11/include
$ make
make: dpkg-architecture: Command not found
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C agg-plot
Compiling agg_platform_support_x11.cpp
agg_platform_support_x11.cpp:31:10: fatal error: 'X11/Xlib.h' file not found
#include <X11/Xlib.h>
         ^~~~~~~~~~~~
1 error generated.
make[1]: *** [agg_platform_support_x11.o] Error 1
make: *** [agg-plot] Error 2

The file exists.

 ls /opt/X11/include/X11/Xlib.h
/opt/X11/include/X11/Xlib.h

If you have something else to investigate, please tell me.

best regards.

franko commented 5 years ago

Hi,

sorry, yet another error... :-/

Ok, normally the idea was that the Xlib include flags should be provided by the FOX library but may be I am wrong about that.

If you look at the file makepackages you should see for the"Darwin" architecture (Mac OS X):

FOX_INCLUDES := $(shell pkg-config fox --cflags)
FOX_LIBS = $(shell pkg-config fox --libs)

but now I am thinking that may be the flags for xwindow should be included explicitly.

Otherwise please note that the Makefiles for GSL Shell ignores the variable CPPFLAGS you have tried to use. Instead you can use

> INCLUDES=-I/opt/X11/include

Please not also that in makedefs the path to x11 libraries is given explicitly to the variable LDFLAGS:

  ifeq ($(HOST_SYS),Darwin)
    LINK_EXE = $(CXX) $(LDFLAGS)
    # Use rsync because the --parents option to cp doesn't exist in
    # Mac OS X
    CP_REL = rsync -R
    LDFLAGS += -L/usr/X11/lib -undefined dynamic_lookup -pagezero_size 10000 -image_base 100000000
  else
    LDFLAGS += -Wl,-E

so you may want to adjust this by using -L/opt/X11/lib instead. If you find a way to make it work I may try to figure out a good solution to improve the makefiles about that.

Are the x11 libraries provided by Homebrew or they can from somewhere else ? There is pkg-config file for x11 so that you can do something like pkg-config --cflags x11 ?

ghost commented 5 years ago

@franko

Thank teache me.

I tried export Enviroment. but Error.

export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig/:/opt/X11/lib/pkgconfig
make
make: dpkg-architecture: Command not found
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C agg-plot
Compiling agg_platform_support_x11.cpp
agg_platform_support_x11.cpp:31:10: fatal error: 'X11/Xlib.h' file not found
#include <X11/Xlib.h>
         ^~~~~~~~~~~~
1 error generated.
make[1]: *** [agg_platform_support_x11.o] Error 1
make: *** [agg-plot] Error 2

My Enviroment Path is

$ pkg-config fox --libs
-lFOX-1.6
$ pkg-config X11 --cflags
-I/opt/X11/include
$ pkg-config X11 --libs
-L/opt/X11/lib -lX11

Change makedef make is same error.

48c48
<     LDFLAGS += $(shell pkg-config X11 --cflags) -undefined dynamic_lookup -pagezero_size 10000 -image_base 100000000
---
>     LDFLAGS += -L/usr/X11/lib -undefined dynamic_lookup -pagezero_size 10000 -image_base 100000000

but same error...

What is the cause? . . .

franko commented 5 years ago

Ok, now it is almost good I think :-)

For the LDFLAGS you should use pkg-config with the --libs flags

LDFLAGS += $(shell pkg-config X11 --libs) -undefined dynamic_lookup -pagezero_size 10000 -image_base 100000000

and you should use $(shell pkg-config X11 --cflags) in the INCLUDES variable. For example you may add it in the AGG_INCLUDES variable in makepackages:

# GWH: determined all of the following flags (except for pthread)
# using the pkg-config utility, except I had to add -lX11 to AGG_LIBS.

  AGG_INCLUDES = $(shell pkg-config libagg --cflags) $(shell pkg-config X11 --cflags)
  AGG_LIBS = $(shell pkg-config libagg --libs) -lX11

The idea is that the result of $(shell pkg-config X11 --cflags) should go into the INCLUDES variables.

ghost commented 5 years ago

@franko

Thank you for teaching me! !

I change makedefs

LDFLAGS += $(shell pkg-config X11 --libs) -undefined dynamic_lookup -pagezero_size 10000 -image_base 100000000

and makepackages

# GWH: determined all of the following flags (except for pthread)
# using the pkg-config utility, except I had to add -lX11 to AGG_LIBS.

  AGG_INCLUDES = $(shell pkg-config libagg --cflags) $(shell pkg-config X11 --cflags)
  AGG_LIBS = $(shell pkg-config libagg --libs) -lX11

make run...

$ make
make: dpkg-architecture: Command not found
Compiling completion.c
Compiling gsl-shell-jit.c
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C agg-plot
Compiling support_x11.cpp
Compiling agg_platform_support_x11.cpp
Compiling printf_check.cpp
Compiling fonts.cpp
Compiling gamma.cpp
Compiling agg_font_freetype.cpp
Compiling plot.cpp
plot.cpp:412:13: warning: variable 'px' is used uninitialized whenever switch
      default is taken [-Wsometimes-uninitialized]
            default:
            ^~~~~~~
plot.cpp:417:17: note: uninitialized use occurs here
            if (px >= 0 && py >= 0 && px + dx < sx && py + dy < sy)
                ^~
plot.cpp:381:22: note: initialize the variable 'px' to silence this warning
            double px, py;
                     ^
                      = 0.0
1 warning generated.
Compiling plot-auto.cpp
Compiling utils.cpp
Compiling units.cpp
Compiling colors.cpp
Compiling markers.cpp
Compiling draw_svg.cpp
Compiling canvas_svg.cpp
Compiling lua-draw.cpp
Compiling lua-text.cpp
Compiling text.cpp
Compiling agg-parse-trans.cpp
Compiling window_registry.cpp
Compiling window.cpp
Compiling lua-plot.cpp
lua-plot.cpp:783:14: warning: variable 'pos' is used uninitialized whenever 'if'
      condition is false [-Wsometimes-uninitialized]
    else if (letter == 't')
             ^~~~~~~~~~~~~
lua-plot.cpp:788:12: note: uninitialized use occurs here
    return pos;
           ^~~
lua-plot.cpp:783:10: note: remove the 'if' if its condition is always true
    else if (letter == 't')
         ^~~~~~~~~~~~~~~~~~
lua-plot.cpp:774:5: note: variable 'pos' is declared here
    sg_plot::placement_e pos;
    ^
1 warning generated.
Compiling canvas-window.cpp
Compiling bitmap-plot.cpp
Compiling lua-graph.cpp
Archive libaggplot.a
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C luajit2
==== Building LuaJIT 2.0.3 ====
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C src
HOSTCC    host/minilua.o
HOSTLINK  host/minilua
DYNASM    host/buildvm_arch.h
HOSTCC    host/buildvm.o
HOSTCC    host/buildvm_asm.o
HOSTCC    host/buildvm_peobj.o
HOSTCC    host/buildvm_lib.o
HOSTCC    host/buildvm_fold.o
HOSTLINK  host/buildvm
BUILDVM   lj_vm.s
ASM       lj_vm.o
CC        lj_gc.o
BUILDVM   lj_ffdef.h
CC        lj_err.o
CC        lj_char.o
BUILDVM   lj_bcdef.h
CC        lj_bc.o
CC        lj_obj.o
CC        lj_str.o
CC        lj_tab.o
CC        lj_func.o
CC        lj_udata.o
CC        lj_meta.o
CC        lj_debug.o
CC        lj_state.o
CC        lj_dispatch.o
CC        lj_vmevent.o
CC        lj_vmmath.o
CC        lj_strscan.o
CC        lj_api.o
CC        lj_lex.o
CC        lj_parse.o
CC        lj_bcread.o
CC        lj_bcwrite.o
CC        lj_load.o
CC        lj_ir.o
CC        lj_opt_mem.o
BUILDVM   lj_folddef.h
CC        lj_opt_fold.o
CC        lj_opt_narrow.o
CC        lj_opt_dce.o
CC        lj_opt_loop.o
CC        lj_opt_split.o
CC        lj_opt_sink.o
CC        lj_mcode.o
CC        lj_snap.o
CC        lj_record.o
CC        lj_crecord.o
BUILDVM   lj_recdef.h
CC        lj_ffrecord.o
CC        lj_asm.o
CC        lj_trace.o
CC        lj_gdbjit.o
CC        lj_ctype.o
CC        lj_cdata.o
CC        lj_cconv.o
CC        lj_ccall.o
CC        lj_ccallback.o
CC        lj_carith.o
CC        lj_clib.o
CC        lj_cparse.o
CC        lj_lib.o
CC        lj_alloc.o
CC        lib_aux.o
BUILDVM   lj_libdef.h
CC        lib_base.o
CC        lib_math.o
CC        lib_bit.o
CC        lib_string.o
CC        lib_table.o
CC        lib_io.o
CC        lib_os.o
CC        lib_package.o
CC        lib_debug.o
CC        lib_jit.o
CC        lib_ffi.o
CC        lib_init.o
AR        libluajit.a
CC        luajit.o
BUILDVM   jit/vmdef.lua
LINK      luajit
OK        Successfully built LuaJIT
test -f libluajit.so && cp libluajit.so ../.. || :
test -f libluajit.a && cp libluajit.a ../../.libs || :
==== Successfully built LuaJIT 2.0.3 ====
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C lua-gsl
Compiling lua-properties.c
Compiling gs-types.c
Compiling lua-utils.c
Compiling lua-gsl.c
Compiling str.c
Compiling fatal.c
Archive libluagsl.a
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C gdt
Compiling char_buffer.c
Compiling gdt_index.c
Compiling gdt_table.c
gdt_table.c:17:1: warning: unused function 'elem_is_undef' [-Wunused-function]
elem_is_undef(const gdt_element* e)
^
1 warning generated.
Archive libgdt.a
Linking gsl-shell
g++ -L/opt/X11/lib -lX11 -undefined dynamic_lookup -pagezero_size 10000 -image_base 100000000 -L/usr/X11/lib -undefined dynamic_lookup -pagezero_size 10000 -image_base 100000000 -o gsl-shell completion.o gsl-shell-jit.o ./.libs/libaggplot.a ./.libs/libluajit.a ./.libs/libluagsl.a ./.libs/libgdt.a -pthread -ldl -lreadline -lncurses  -L/usr/local/Cellar/libagg/2.5/lib -Wl,-rpath,/usr/local/Cellar/libagg/2.5/lib -lagg -lX11 -L/usr/local/opt/freetype/lib -lfreetype -lpthread -L/usr/local/Cellar/gsl/2.5/lib -lgsl -lgslcblas -lm -lm
clang: warning: argument unused during compilation: '-pthread' [-Wunused-command-line-argument]
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C fox-gui
Compiling io_thread.cpp
Compiling window_surface.cpp
Compiling fx_console.cpp
Compiling redirect.cpp
Compiling gsl_shell_interp.cpp
Compiling gsl_shell_thread.cpp
Compiling fox_gsl_shell.cpp
Compiling gsl_shell_window.cpp
Compiling window_part.cpp
Compiling fx_plot_canvas.cpp
Compiling fx_plot_window.cpp
Compiling lua_plot_window.cpp
Compiling gsl_shell_app.cpp
Compiling gsl-shell-fox.cpp
Archive libfoxgui.a
Linking gsl-shell-gui
g++ -L/opt/X11/lib -lX11 -undefined dynamic_lookup -pagezero_size 10000 -image_base 100000000 -L/usr/X11/lib -undefined dynamic_lookup -pagezero_size 10000 -image_base 100000000 -o gsl-shell-gui ./.libs/libfoxgui.a ./.libs/libaggplot.a ./.libs/libluajit.a ./.libs/libluagsl.a ./.libs/libgdt.a -pthread -ldl -lreadline -lncurses  -L/usr/local/Cellar/libagg/2.5/lib -Wl,-rpath,/usr/local/Cellar/libagg/2.5/lib -lagg -lX11 -L/usr/local/opt/freetype/lib -lfreetype -lpthread -L/usr/local/Cellar/gsl/2.5/lib -lgsl -lgslcblas -lm -lm -lFOX-1.6 -lm -ldl
clang: warning: argument unused during compilation: '-pthread' [-Wunused-command-line-argument]

Does this make it succeed?

Also, since I would like to use something using luajit 2.1, in that case, do I have to use master-lj 2.1? I installed luajit with brew install - with - gc64 - dev luajit, but is there any influence?

If this problem can be solved, I will send a pull request.

best regards.

franko commented 5 years ago

Hi,

normally the build succeeded and you should be able to run the executables

so now you may test if they work.

As for LuaJIT 2.1 it cannot be used trivially because GSL Shell use a slightly modified version of luajit so if you want to use luajit 2.1 first one have to perform the same modification and integrate luajit 2.1 in the gsl shell code base.

I may do this but for the moment I don't have a lot of time to work on that, sorry.

Otherwise, can I know if there is a specific reason you want to use GSL shell and why GSL Shell with LuaJIT 2.1 ?

ghost commented 5 years ago

@franko

Thanks teach me.

run result.

./gsl-shell
dyld: Symbol not found: _rl_completion_suppress_append
  Referenced from: /Users/dai_yamashita/src/gsl-shell/./gsl-shell
  Expected in: flat namespace
 in /Users/dai_yamashita/src/gsl-shell/./gsl-shell
Abort trap: 6
dai-yamashita-no-iMac:gsl-shell dai_yamashita$ ./gsl-shell-gui
gsl_shell_app::openDisplay: unable to open display :0.0

luajit 2.1 is 64bit support.

I want to use memory at 64 bit.

franko commented 5 years ago

Hi,

you are now getting two errors. The one

dyld: Symbol not found: _rl_completion_suppress_append

I don't know about, I don't know Mac OS X enough to tell. What I understand is that the gsl-shell executable is dynamically linked to the readline shared library and when the OS try to start the process one of the symbol of the readline library cannot be found.

May be you have two readline libraries installed on your system and the OS is trying to use one of them taht was not the one used to build gsl shell. On Max OS X I don't know but on Linux you can set the environment variable LD_LIBRARY_PATH to provide a path to where the custom shared library are located.

For the seconde error:

gsl_shell_app::openDisplay: unable to open display :0.0

It means that GSL Shell tries to use a XWindow display but your OS is not providing one. This is may be normal because by default Mac OS X does not use the xwindow system. I don't know to to enable it, may be you can look on internet "how to enable xwindow server on Mac OS X" or something like that.

As for Luajit 2.1, I am wondering what kind of computations you need to perform and if you really need gsl shell or you can just use plain luajit. Can you tell me more about what you want to do ?

GSL shell is useful especially to do matrix calculations, access functions from the GSL library or create some 2D graphics. Do you need some specific functions from the GSL library ? which one ?

nguyenquangchien commented 9 months ago

GSL-Shell is marvellous for classroom use. The executable is minimal and clean. That's wonderful for Windows and Linux platforms.

However I realise that students are using more Mac OS recently.

Would you think that making a Mac package pkg is feasible? Just a rough build and might not be very updated - but just work for someone who wants to use Mac without compiling (as most users are novice in command line skills)?

franko commented 9 months ago

Unfortunately GSL Shell graphics system and GUI cannot work on macOS. It can run with graphics disabled but this of limited interest.

From the technical point of view the graphics system can run on macOS but it requires the user to install an X window server but I didn't want to push for this option.

Making the graphics system work in GSL Shell requires some substantial work that unfortunately I cannot do at this moment.