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

can't install with nimble (mongoose.h) #8

Closed
konsumer opened this issue Mar 30, 2023 · 9 comments
Closed

can't install with nimble (mongoose.h) #8

konsumer opened this issue Mar 30, 2023 · 9 comments
Labels
bug Something isn't working

Comments

@konsumer
Copy link
Contributor

Possibly related to #2

I am on OSX (M1) Ventura 13.3, nim 1.6.10, nimble 0.13.1

I can do nimble install webui without error, but not track it as a dependency in my project.

If I add this to my nimble file:

requires "https://github.com/neroist/webui.git"

or:

requires "webui >= 0.2.1"

I get this, when I try to nimble run:

/Users/konsumer/.nimble/pkgs/webui-0.2.1/webui/webui/src/mongoose.c:20:10: fatal error: 'mongoose.h' file not found
#include "mongoose.h"
         ^~~~~~~~~~~~
@konsumer
Copy link
Contributor Author

I get the same error if I do this:

git clone --recursive https://github.com/neroist/webui.git
cd webui
nim c examples/minimal.nim

@konsumer konsumer changed the title can't install with nimble can't install with nimble (mongoos.h) Mar 30, 2023
@konsumer konsumer changed the title can't install with nimble (mongoos.h) can't install with nimble (mongoose.h) Mar 30, 2023
@konsumer
Copy link
Contributor Author

konsumer commented Mar 30, 2023

I made some bindings for soloud, pntr, and physfs (see here) that use nim to do the compiling. Similar idea might make it work better:

{.passC: "-Ivendor/".}

{.emit: """
#define PNTR_IMPLEMENTATION
#define PNTR_PIXELFORMAT_ARGB
#define PNTR_ENABLE_DEFAULT_FONT
#define PNTR_ENABLE_TTF
#define PNTR_ENABLE_FILTER_SMOOTH

#include "pntr/pntr.h"
""".}

or

{.passC: "-Ivendor/soloud/src/ -Ivendor/soloud/include/ -DWITH_NULL -DWITH_MINIAUDIO -DWITH_NOSOUND".}
{.compile: "vendor/soloud/src/audiosource/openmpt/soloud_openmpt.cpp".}

Basically, I setup the compiler/linker flags in passC or passL and emit and compile to inline the C. Paths are all relative to the root of the project (where the nimble file is) so can simplify finding files and stuff. Nim likes compile calls to be .c or. cpp extensions (not .h) so you can inject an include for header-only things with emit.

@hassandraga
Copy link
Member

I re-test it in Windows, using nim v1.6.12. It's working fine.

git clone --recursive https://github.com/neroist/webui.git
cd webui\examples
nim c minimal.nim

Hint: used config file 'C:\Nim\config\nim.cfg' [Conf]
Hint: used config file 'C:\Nim\config\config.nims' [Conf]
Hint: used config file 'C:\...\webui\examples\nim.cfg' [Conf]
............................................................................................
CC: mongoose
CC: webui
CC: C:/Nim/lib/std/private/digitsutils.nim
CC: C:/Nim/lib/system/dollars.nim
CC: C:/Nim/lib/system/io.nim
CC: C:/Nim/lib/system.nim
CC: C:/Nim/lib/pure/base64.nim
CC: C:/Nim/lib/pure/dynlib.nim
CC: C:/Nim/lib/windows/winlean.nim
CC: C:/Nim/lib/pure/times.nim
CC: C:/Nim/lib/std/private/win_setenv.nim
CC: C:/Nim/lib/pure/os.nim
CC: ../webui/bindings.nim
CC: ../webui.nim
CC: minimal.nim
Hint:  [Link]
Hint: gc: orc; opt: speed; options: -d:release
49113 lines; 4.128s; 75.457MiB peakmem; proj: C:\...\webui\examples\minimal.nim; out: C:\...\webui\examples\minimal.exe [SuccessX]

Something is missing in this line. I don't know.

@konsumer
Copy link
Contributor Author

If I add this I can get it further:

{.passC: "-I../webui/webui/include".}

but then it fails again:

/Users/konsumer/Desktop/webui/webui/webui/src/webui.c:2539:39: error: use of undeclared identifier 'WEBUI_MAX_PATH'
    win->path = (char*) _webui_malloc(WEBUI_MAX_PATH);
                                      ^
/Users/konsumer/Desktop/webui/webui/webui/src/webui.c:2643:42: error: use of undeclared identifier 'WEBUI_MAX_PATH'
    if((path == NULL) || (strlen(path) > WEBUI_MAX_PATH))
                                         ^
/Users/konsumer/Desktop/webui/webui/webui/src/webui.c:3240:40: error: use of undeclared identifier 'WEBUI_MAX_PATH'
    char* path = (char*) _webui_malloc(WEBUI_MAX_PATH);
                                       ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
4 errors generated.
Error: execution of an external compiler program 'clang -c  -w -ferror-limit=3 -I../webui/webui/include -O3   -I/opt/homebrew/Cellar/nim/1.6.10/nim/lib -I/Users/konsumer/Desktop/webui/examples -o /Users/konsumer/.cache/nim/minimal_r/webui.c.o /Users/konsumer/Desktop/webui/webui/webui/src/webui.c' failed with exit code: 1

which seems to rely on MAX_PATH, which is a windows-only thing, as far as I can tell.

Adding a define for it, it still couldn't find the C files, so I did this:

{.passC: "-I../webui/webui/include -DWEBUI_MAX_PATH=256".}
{.compile: "../webui/webui/src/webui.c".}
{.compile: "../webui/webui/src/mongoose.c".}

And I am still getting undefined symbols:

Undefined symbols for architecture arm64:
  "_WEBUI_FILE_EXIST", referenced from:
      __webui_file_exist_mg in webui.c.o
      __webui_file_exist in webui.c.o
      __webui_interpret_file in webui.c.o
      __webui_server_event_handler in webui.c.o
      __webui_file_exist_mg in webui.c.o
      __webui_file_exist in webui.c.o
      __webui_interpret_file in webui.c.o
      ...
  "_WEBUI_GET_CURRENT_DIR", referenced from:
      _webui_script in webui.c.o
      _webui_new_window in webui.c.o
      _webui_close in webui.c.o
      _webui_is_any_window_running in webui.c.o
      _webui_new_server in webui.c.o
      _webui_set_timeout in webui.c.o
      _webui_show in webui.c.o
      ...
  "_WEBUI_PCLOSE", referenced from:
      __webui_interpret_command in webui.c.o
      __webui_interpret_command in webui.c.o
  "_WEBUI_POPEN", referenced from:
      __webui_interpret_command in webui.c.o
      __webui_interpret_command in webui.c.o

@konsumer
Copy link
Contributor Author

konsumer commented Mar 30, 2023

I have no problems with building upstream lib:

git clone https://github.com/alifcommunity/webui.git
cd webui/build/MacOS/Clang
make

@neroist neroist added the bug Something isn't working label Mar 30, 2023
@konsumer
Copy link
Contributor Author

Here is me having the trouble on mac.

I tried on docker (nimlang/nim) and arm64 linux in qemu, and it built and ran ok, so I think it's some mac-specific problem.

Screenshot 2023-03-30 at 3 51 13 PM

@konsumer
Copy link
Contributor Author

konsumer commented Mar 30, 2023

I made my own simpler wrapper here and it pops up a window with nimble test and no error building. For some reason it doesn't insert the content (opens an empty window) and doesn't wait(), but it might be some hint as to why it's not working.

@konsumer konsumer mentioned this issue Mar 31, 2023
@neroist
Copy link
Contributor

neroist commented Mar 31, 2023

@konsumer do you think this can be closed due to #9?

@konsumer
Copy link
Contributor Author

@neroist yep, I think it's as good as it gets for now, since there are some problems on mac on upstream. If those get resolved, we should update the upstream again, here, I think. The original problem of "won't build on mac" is resolved with #9, though, so I will close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants