Skip to content

hxwidgets hello world fails to compile on fresh Ubuntu 20.04 (because of macro usage?) #81

@Klabuster

Description

@Klabuster

Expected Behavior

The Hello-World project (haxelib run haxeui-core create hxwidgets) compiles fine.

Current Behavior

Compilation ends with errors, as follows:

--- snip ---
  - src/hx/widgets/ComboBox.cpp
  - src/haxe/ui/layouts/VerticalGridLayout.cpp
  - src/haxe/ui/events/UIEvent.cpp
 Error: In file included from /home/ubuntu/haxelib/hxcpp/4,2,1/include/hxcpp.h:345,
  from ./src/boot.cpp:1:
include/hx/widgets/AnyButton.h:19:30: error: expected identifier before numeric constant
  19 | HX_DECLARE_CLASS2(hx,widgets,AnyButton)
  | ^~~~~~~~~
/home/ubuntu/haxelib/hxcpp/4,2,1/include/hx/Macros.h:16:8: note: in definition of macro ‘HX_DECLARE_CLASS0’
16 | class klass##_obj;
| ^~~~~
/home/ubuntu/haxelib/hxcpp/4,2,1/include/hx/Macros.h:19:58: note: in expansion of macro ‘HX_DECLARE_CLASS1’
19 | #define HX_DECLARE_CLASS2(ns2,ns1,klass) namespace ns2 { HX_DECLARE_CLASS1(ns1,klass) }
| ^~~~~~~~~~~~~~~~~
include/hx/widgets/AnyButton.h:19:1: note: in expansion of macro ‘HX_DECLARE_CLASS2’
19 | HX_DECLARE_CLASS2(hx,widgets,AnyButton)
| ^~~~~~~~~~~~~~~~~
include/hx/widgets/AnyButton.h:19:30: error: expected unqualified-id before numeric constant
19 | HX_DECLARE_CLASS2(hx,widgets,AnyButton)
| ^~~~~~~~~
--- snip ---

Possible Solution

I hope you tell me. ;)
I've seen a case from a few years ago with a similar log output (and this was the only one I found, -> in repo "haxeui-hxwidgets", Issue 1), which didn't end in a solution described there, but just died somewhere. I also tried to get behind all the macro expansion wizardry happening there, but I was unable to recognise the root cause. I tried to replace the "stable" releases from haxelib with their current state in the respective github repos, but didn't get any further. I also tried compiling the current wxwidgets dependency as stated in the wiki.
As there's lots of active development going on, I assume the error on my side; yet, I think, precisely (as far as possible) following the recommendations should result in a positive outcome. I'm afraid I might have overlooked sth. obvious.

Steps to Reproduce (for bugs)

I use Linux Containers (LXD / LXC) here, so prerequisites might include:
snap install lxd
lxd init

  1. Load fresh Ubuntu 20.04 image and enter it:
    lxc launch ubuntu:20.04 hximage
    lxc exec hximage bash

  2. Install haxe as suggested on the respective websites
    add-apt-repository ppa:haxe/releases -y
    apt update
    apt install haxe -y

  3. Install some prerequisites:
    Won't work: apt install libwxgtk3.0-dev libwxbase3.0-dev libwxgtk-webview3.0-dev
    Will work: apt install -y libwxgtk3.0-gtk3-dev libwxbase3.0-dev libwxgtk-webview3.0-gtk3-dev
    apt install build-essential -y

  4. Install haxe libs:
    su ubuntu
    mkdir ~/haxelib && haxelib setup ~/haxelib
    haxelib install haxeui haxeui-hxwidgets

  5. Make the default hello-world project:
    mkdir haxetest && cd haxetest
    haxelib run haxeui-core create hxwidgets
    haxe hxwidgets.hxml
    (fails here.)

-> Full output log

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions