undefined function :wx_object.start/3

2019-07-25 18:10发布

问题:

I have tried to install ErLang on my Mac 64bit, Capitan, I've tried to install it via brew, but when I try to run :observer.start I get this error:

** (UndefinedFunctionError) undefined function :wx_object.start/3 (module :wx_object is not available)
    :wx_object.start(:observer_wx, [], [])
    observer_wx.erl:72: :observer_wx.start/0

I also tried to install erLang otp 18.3 using erlang solutions, but I got the same error.

Any idea?

EDIT

If I try to start the observer directly from the Erlang shell:

^CiMac:~ Apple$ erl 
Erlang/OTP 18 [erts-7.3] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V7.3  (abort with ^G)
1> observer:start().
** exception error: undefined function wx_object:start/3
     in function  observer_wx:start/0 (observer_wx.erl, line 72)

EDIT2

iMac:~ Apple$ brew info erlang
erlang: stable 18.3 (bottled), HEAD
Programming language for highly scalable real-time systems
https://www.erlang.org/
/usr/local/Cellar/erlang/18.3 (7,489 files, 273.8M)
  Poured from bottle on 2016-05-13 at 12:24:59
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/erlang.rb
==> Dependencies
Build: autoconf ✔, automake ✔, libtool ✔
Required: openssl ✔
Recommended: wxmac ✔
Optional: fop ✘
==> Options
--with-dirty-schedulers
    Enable experimental dirty schedulers
--with-fop
    Build with fop support
--with-native-libs
    Enable native library compilation
--without-docs
    Do not install documentation
--without-hipe
    Disable building hipe; fails on various OS X systems
--without-wxmac
    Build without wxmac support
--HEAD
    Install HEAD version
==> Caveats
Man pages can be found in:
  /usr/local/opt/erlang/lib/erlang/man

Access them with `erl -man`, or add this directory to MANPATH.
iMac:~ Apple$ which erl
/opt/local/bin/erl

erl at brew info is: /usr/local/Cellar/erlang/18.3 but, which erl is: /opt/local/bin/erl which points to /opt/local/lib/erlang/bin/erl

if I started /usr/local/Cellar/erlang/18.3/bin/erl observer will work!

so, I deleted the alias by mouse and I:

sudo ln -s /usr/local/Cellar/erlang/18.3/lib/erlang/bin/erl /opt/local/bin/erl

but I am not sure about /opt/local/lib/erlang/bin/erl how it was created.. any way, it works now..

回答1:

Given the syntax it looks like you are using Elixir :-)

Anyway, one possible answer is that you need Erlang built with WxWidgets, which is the GUI toolkit used by the observer.

If I look at the homebrew formula for Erlang (http://brewformulas.org/Erlang), it shows that it will install the "Wxmac" dependency, so it should bring in WxWidgets...

What happens if you try to start the observer directly from the Erlang shell as follows?

1> observer:start().

(I have installed it with MacPorts and it works out of the box).

EDIT

It really looks like that Erlang doesn't have WxWidgets. You can try brew info erlang, it will show you which version is installed and wether the wxmac dependency is installed or not.

Are you sure actually you are starting the right erl? The one installed by brew? (does "which erl" in the console print the expected path?)



回答2:

On many systems Erlang with wx isn't supported by default. It can be enabled by a compilation option. Sometimes there is a separate package that has been compiled with wx support, e.g. erlang-wx on FreeBSD.

A quick Google search shows this example article that provides some info about recompiling Erlang on Mac with wx enabled.



标签: erlang elixir