PMunch / wxnim

Nim wrapper for wxWidgets.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compile under OSX

teras opened this issue · comments

Hello
I am trying to compile wxnim in my OSX machine.
Warning: new nim user here!
Thus, I have even serious problems installing wxnim itself.

  • nimble compains that "wxnim.nim" file is missing.
  • wxCompile.nim compiles
  • nim c wx.nim complains about missing wx/wxprec.h

Result of wx-config --cppflags:
-I/usr/local/lib/wx/include/osx_cocoa-unicode-3.0 -I/usr/local/include/wx-3.0 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXMAC__ -D__WXOSX__ -D__WXOSX_COCOA__

How can I approach this issue?

Have you tried compiling one of the examples? Neither wxCompile.nim nor wx.nim are meant to be compiled as stand alone modules. If that doesn't work please post any error messages or warnings the compilation spits out. I really want to know that this runs on OSX as well, although I've never had a Mac to try it on, so I'll do my best to help you.

Thank you for the answer.
I didn't think that in order to test it, the examples should be compiled directly. Maybe the "Install wxnim" in the beginning of the instructions is misleading? Maybe something like "go to examples and compile them" would be preferable?

Now, to the real stuff.
Unfortunately it still doesn't work (both as c and cpp compilations).

The file wxprec.h exists under /usr/local/include/wx-3.0/wx/
Also here is the output of wx-config
-I/usr/local/lib/wx/include/osx_cocoa-unicode-3.0 -I/usr/local/include/wx-3.0 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXMAC__ -D__WXOSX__ -D__WXOSX_COCOA__

It seems that it is missing the output of wx-config as compiler options?

Output of the compiler:

nim cpp -f example1.nim
Hint: used config file '/usr/local/Cellar/nim/0.19.4/nim/config/nim.cfg' [Conf]
Hint: used config file '/Users/teras/Sources/wxnim/examples/purewx/nim.cfg' [Conf]
Hint: system [Processing]
Hint: example1 [Processing]
Hint: wx [Processing]
Hint: ospaths [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint: math [Processing]
Hint: bitops [Processing]
Hint: algorithm [Processing]
Hint: unicode [Processing]
../../wxCompile.nim(14, 14) Warning: Compiling without wxWidgetsPath assumes wx-config is in your path [User]
../../wx.nim(15, 12) Warning: use {.experimental: "codeReordering.".} instead; {.noForward.} is deprecated [Deprecated]
CC: wxnim_example1
CC: stdlib_system
CC: wxnim_wx
CC: stdlib_ospaths
CC: stdlib_strutils
CC: stdlib_parseutils
CC: stdlib_math
CC: stdlib_bitops
Error: execution of an external compiler program 'clang++ -c  -w  -I/usr/local/Cellar/nim/0.19.4/nim/lib -o /Users/teras/.cache/nim/example1_d/wxnim_wx.cpp.o /Users/teras/.cache/nim/example1_d/wxnim_wx.cpp' failed with exit code: 1

/Users/teras/.cache/nim/example1_d/wxnim_wx.cpp:11:10: fatal error: 'wx/wxprec.h' file not found
#include <wx/wxprec.h>
         ^~~~~~~~~~~~~
1 error generated.

Also tried with the wxWidgetsPath command line argument, to point where the wx-config is, still error:

# nim cpp -f -d:wxWidgetsPath=/usr/local/bin example1.nim
Hint: used config file '/usr/local/Cellar/nim/0.19.4/nim/config/nim.cfg' [Conf]
Hint: used config file '/Users/teras/Sources/wxnim/examples/purewx/nim.cfg' [Conf]
Hint: system [Processing]
Hint: example1 [Processing]
Hint: wx [Processing]
Hint: ospaths [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint: math [Processing]
Hint: bitops [Processing]
Hint: algorithm [Processing]
Hint: unicode [Processing]
../../wxCompile.nim(7, 47) Error: type mismatch: got <nil> but expected 'string'

If I manually give compiler/linker flags like this, it works.

nim -f cpp "--passC:-I/usr/local/lib/wx/include/osx_cocoa-unicode-3.0 -I/usr/local/include/wx-3.0 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXMAC__ -D__WXOSX__ -D__WXOSX_COCOA__" "--passL:-L/usr/local/lib   -framework IOKit -framework Carbon -framework Cocoa -framework AudioToolbox -framework System -framework OpenGL -lwx_osx_cocoau_xrc-3.0 -lwx_osx_cocoau_webview-3.0 -lwx_osx_cocoau_html-3.0 -lwx_osx_cocoau_qa-3.0 -lwx_osx_cocoau_adv-3.0 -lwx_osx_cocoau_core-3.0 -lwx_baseu_xml-3.0 -lwx_baseu_net-3.0 -lwx_baseu-3.0" controlgallery.nim

Well the "install wxnim" line refers to using "nimble install" in the base directory. This will put wxnim in the correct path for your other programs to import it as a library. As for the other issues it seems like the giving the path to wx-config flag is broken as of 0.19.0 since strings can't be nil past that version. That's an easy fix. What C++ compiler does Nim call on your system? The wxCompile script only has paths for VCC and GCC so if you use e.g. clang it won't currently work. I'm guessing that copying the block from L96-L102 in wxCompile.nim into a block that will catch for clang (or just be a generic fallback) should make it work.

As per PR #17 it should now work. Would you mind writing a short sub-chapter on installation on OSX?

Of course.