4

I cannot get wxErlang to work at all. Do i need to include a module. Can't find any basic information relating to it. Please help. I am look for a very basic example of a module.

the error I am getting is

undefined function wx:start/0

R. Carbone
  • 71
  • 4
Damian
  • 1,543
  • 15
  • 22

3 Answers3

4

This should display an empty frame:

1> wx:new().
{wx_ref,0,wx,[]}

2> Frame = wxFrame:new(wx:null(), 0, "myFrame").
{wx_ref,36,wxFrame,[]}

3> wxFrame:show(Frame).
true
Zed
  • 57,028
  • 9
  • 76
  • 100
  • OK I am getting "bad function wx:new()." i am guessing I am missing a library. How do I go about solving that? – Damian Aug 28 '09 at 19:45
  • Are you using R13? Did you compile with wx support? I think the library dependencies are: freeglut3-dev and libwxgtk2.8-dev – Zed Aug 28 '09 at 19:49
  • 2
    You must also enable SMP support for wx. – Zed Aug 28 '09 at 19:56
  • unfortunatly atm i am on a windows box. I have just searched through the erl/lib directory and did not find wxerlang. I have now downloaded the latest release of erlang and seems that I now have the wxerlang lib. I have another problem now, but I will look into it before posting another question. – Damian Aug 28 '09 at 20:02
  • 1
    I have plucked the following code from some tutorial but I think it must be very old could you confirm this and point me in the right direction if possible. -module(test). -export([start/0]). start() -> wx:start(), XRC = wx:xml_resource_get(), wx:init_all_handlers(XRC), wx:load(XRC, "gui.xrc"), Frame = wx:load_frame(XRC, ?NULL, "frame_1"), wx:show(Frame). – Damian Aug 28 '09 at 20:11
  • I think that is for an old version of wxerlang.sourceforge.net – Zed Aug 28 '09 at 20:23
  • I have the standard install of erl 5.7.1 on Windows and Zed's script above certainly shows a window. I did no builds - simply downloaded the standard windows install... – Alan Moore Aug 28 '09 at 20:23
  • M:\>"c:\Program Files\erl5.7.1\bin\erl.exe" Eshell V5.7.1 (abort with ^G) 1> wx:new(). {wx_ref,0,wx,[]} 2> Frame = wxFrame:new(wx:null(), 0, "myFrame"). {wx_ref,35,wxFrame,[]} 3> wxFrame:show(Frame). true 4> – Alan Moore Aug 28 '09 at 20:24
  • Your erlang install should have a lib\wx-VER\examples directory containing some examples – Zed Aug 28 '09 at 20:26
1

To find the ex-erlang-samples You should issue the following call in EShell to locate the base directory for wx-erlang:

code:lib_dir(wx).

On Windows the returned path uses "/" instead of "\", so just replace them.

Inside that directory there shoud be a directory "examples". Start with "simple" inside those examples.

Also You should check if wx is working properly: use

wx:demo().

in EShell.

Boris Mühmer
  • 476
  • 3
  • 10
0

I just needed to include the wx lib using the following line

-include_lib("include/wx.hrl").

include/ is a sub directory in my project containing the wx library.

Damian
  • 1,543
  • 15
  • 22
  • 3
    Note: It should be: -include_lib("wx/include/wx.hrl"). Right? – Mazen Harake Sep 11 '09 at 11:54
  • I am on a windows box and have setup my application on a different drive. I added and include directory and placed the wx files in that, so it works in my situation. – Damian Sep 16 '09 at 19:01