Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Klabuster opened this issue Jan 21, 2022 · 6 comments

Comments

@Klabuster
Copy link

Klabuster commented Jan 21, 2022

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

@ianharrigan
Copy link
Member

Hi,

So there are a couple of things i would try:

  1. use git version of haxeui-core, haxeui-hxwdgets & hxWidgets (lemme know if you are unsure how to install haxelibs from git)
  2. use git version of hxcpp (and build it: https://github.com/HaxeFoundation/hxcpp#building-the-tools)
  3. use git version of wxWidgets: https://github.com/wxWidgets/wxWidgets (and build from source, instructions are really simple on linux - though it will take some time: https://github.com/haxeui/hxWidgets#building-wxwidgets-from-source-linux--osx)

My personal guess is that 2 is going to fix it (ive seen things like this before i think). But doesnt hurt to be on git versions of haxeui either - the last release was months ago - im hoping to get a new release out in the week or so, but currently the haxelib version is still painfully out of date.

@Klabuster
Copy link
Author

TL;DR: compiles fine with wxWidgets 3.1.4, had linker errors for 3.1.5

Hi Ian,
since you made that guess, I tried no. 2 first. It spits the exact same errors.
(Here, I followed the instructions from the hxcpp repo and did the build steps pointed out there.)

Secondly, I tried no. 1. I don't assume it being the proper way; I do a quick & dirty git clone --recursive [repo url] . in each lib's version folder to make sure the github version isn't ignored due to any kind of explicit version references hidden within build files. Please correct me if this doesn't suffice. This step didn't resolve the failing build, it also ends with essentially the same log output.

For the last step, I undo apt install -y libwxgtk3.0-gtk3-dev libwxbase3.0-dev libwxgtk-webview3.0-gtk3-dev by issuing sudo apt purge -y libwxgtk3.0-gtk3-dev libwxbase3.0-dev libwxgtk-webview3.0-gtk3-dev, but keeping the original deps the install pulled in. I then followed all instructions precisely.
This solves the error reported above, and it looked like it would compile fine, however the linker complains now.

--- snip ---

  • /home/compile/haxelib/hxcpp/4,2,1/project/thirdparty/mbedtls-2.9.0/library/sha1.c
  • /home/compile/haxelib/hxcpp/4,2,1/project/thirdparty/mbedtls-2.9.0/library/des.c
  • /home/compile/haxelib/hxcpp/4,2,1/project/thirdparty/mbedtls-2.9.0/library/oid.c
  • /home/compile/haxelib/hxcpp/4,2,1/project/thirdparty/mbedtls-2.9.0/library/version_features.c
  • /home/compile/haxelib/hxcpp/4,2,1/project/thirdparty/mbedtls-2.9.0/library/xtea.c
    Link: Main
    /usr/bin/ld: obj/linux64/edf3cd3c_SystemOptions.o: in function 'hx::widgets::SystemOptions_obj::setOption(String, int)':
    SystemOptions.cpp:(.text+0x731): undefined reference to 'wxMBConv::~wxMBConv()'
    /usr/bin/ld: obj/linux64/edf3cd3c_SystemOptions.o: in function 'hx::widgets::SystemOptions_obj::getOption(String)':
    SystemOptions.cpp:(.text+0x94d): undefined reference to 'wxMBConv::~wxMBConv()'
    /usr/bin/ld: obj/linux64/edf3cd3c_SystemOptions.o: in function 'hx::widgets::SystemOptions_obj::setOption(String, int) [clone .cold]':
    SystemOptions.cpp:(.text.unlikely+0x34): undefined reference to 'wxMBConv::~wxMBConv()'
    /usr/bin/ld: obj/linux64/edf3cd3c_SystemOptions.o: in function 'hx::widgets::SystemOptions_obj::getOption(String) [clone .cold]':
    SystemOptions.cpp:(.text.unlikely+0x84): undefined reference to 'wxMBConv::~wxMBConv()'
    /usr/bin/ld: obj/linux64/edf3cd3c_CheckBox.o: in function 'hx::widgets::CheckBox_obj::__construct(hx::ObjectPtrhx::widgets::Window_obj, String, hx::Null, hx::Null)':
    CheckBox.cpp:(.text+0x718): undefined reference to 'wxMBConv::~wxMBConv()'
    /usr/bin/ld: obj/linux64/edf3cd3c_CheckBox.o:CheckBox.cpp:(.text.unlikely+0x7c): more undefined references to 'wxMBConv::~wxMBConv()' follow
    /usr/bin/ld: obj/linux64/edf3cd3c_ComboBox.o: in function 'hx::widgets::ComboBox_obj::__construct(hx::ObjectPtrhx::widgets::Window_obj, String, hx::Null, hx::Null)':
    ComboBox.cpp:(.text+0xdba): undefined reference to 'wxBaseArrayPtrVoid::wxBaseArrayPtrVoid()'
    /usr/bin/ld: obj/linux64/edf3cd3c_ComboBox.o: in function 'hx::widgets::ComboBox_obj::getString(int) [clone .cold]':
    ComboBox.cpp:(.text.unlikely+0x38): undefined reference to 'wxMBConv::~wxMBConv()'
    /usr/bin/ld: obj/linux64/edf3cd3c_ComboBox.o: in function 'hx::widgets::ComboBox_obj::__construct(hx::ObjectPtrhx::widgets::Window_obj, String, hx::Null, hx::Null) [clone .cold]':
    ComboBox.cpp:(.text.unlikely+0x180): undefined reference to 'wxBaseArrayPtrVoid::~wxBaseArrayPtrVoid()'
    collect2: error: ld returned 1 exit status
    Error: Build failed

The Ubuntu 20.04 distribution version of wxWidgets seems to be 3.0.4 (while the latest stable is 3.0.5), the latest dev release is 3.1.5, which I tried above.

I then tried to move backwards in versions and had success with 3.1.4.
I'll stick with this setup for now. Thank you!

Guess these are tough times for many, I struggle keeping my own schedules. Thank you and the other fine people working on this very much for all your efforts!

@mcebular
Copy link
Contributor

Just chiming in that I've had the same error on Linux Mint 21.1, the wxWidget version that currently installs from apt is 3.0.5.

I've removed that and then built wxWidgets from source (version 3.2.2) as per instructions in the README of this repo and it worked fine (no installs of haxelibs from git were necessary).

$ haxelib list  
haxeui-core: [1.5.0]
haxeui-hxwidgets: [1.5.0]
hxcpp: [4.2.1]
hxWidgets: [1.10.0]

$ wx-config --version
3.2.2

@nonlin-lin-chaos-order-etc-etal

I also had similar log errors on stable haxe compiler, messages differ with latest haxe (reported here haxeui/haxeui-core#523 )

Will try updating everything from gits as you proposed

@nonlin-lin-chaos-order-etc-etal
Copy link

@ianharrigan Could you please tell how to install haxelibs from git?

@ianharrigan
Copy link
Member

ianharrigan commented Apr 19, 2023

haxelib git haxeui-core https://github.com/haxeui/haxeui-core
haxelib git haxeui-hxwidgets https://github.com/haxeui/haxeui-hxwidgets
haxelib git hxWidgets https://github.com/haxeui/hxWidgets

after that confirm with haxelib list (as you have previously) they should now show [git] (surrounded with square brackets to indicate its the currently selected version)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants