pkulchenko / wxlua

wxlua: Lua bindings for wxWidgets cross-platform GUI toolkit; supports Lua 5.1, 5.2, 5.3, 5.4, LuaJIT and wxWidgets 3.x
306 stars 59 forks source link

building error in branch wxwidges310 #2

Closed dingmingxin closed 7 years ago

dingmingxin commented 7 years ago
[ 27%] Built target wxLuaLib
[ 27%] Building CXX object modules/wxbind/CMakeFiles/wxLuaBindLib.dir/src/wxgl_bind.cpp.o
/somepath/wxlua/wxLua/modules/wxbind/src/wxgl_bind.cpp:80:22: error: too few arguments to function call, single argument 'context' was not
      specified
    self->SetCurrent();
    ~~~~~~~~~~~~~~~~ ^
/somepath/wxWidgets/3.1/include/wx-3.1/wx/glcanvas.h:219:5: note: 'SetCurrent' declared here
    bool SetCurrent(const wxGLContext& context) const;
    ^
1 error generated.
make[2]: *** [modules/wxbind/CMakeFiles/wxLuaBindLib.dir/src/wxgl_bind.cpp.o] Error 1
make[1]: *** [modules/wxbind/CMakeFiles/wxLuaBindLib.dir/all] Error 2
make: *** [all] Error 2

How to fix this? Is the binding code writed manually or generated by program ?

pkulchenko commented 7 years ago

The bindings are generated from .i interface files, which are used to be written manually, but now can be generated using the script any-bind-sync.lua, but that script hasn't yet been updated to cover wxGL.

This is still strange as I've compiled wxlua library for ZeroBrane Studio with wxGL support and without any issues.

Are you trying to compile it on MacOS? Here is how the definition looks in the interface file:

    %mac void SetCurrent( );
    %wxchkver_2_8&!%mac void SetCurrent(const wxGLContext& RC) const;

So, it looks like it explicitly uses SetCurrent() on MacOS, but I'm not sure whether it's correct or not. It seems like this fragment hasn't had any changes since 2012.

pkulchenko commented 7 years ago

@dingmingxin, can you also try building using wxwidgets311 branch? wxwidgets310 was a temporary branch I've been working on and wxwidgets311 should also support earlier versions (like wxwidgets 3.0 and wxwidgets 3.1), just not all methods may be available.

dingmingxin commented 7 years ago

My environment is macos 10.12.5. I will try branch wxwidges311 later.

pkulchenko commented 7 years ago

ok; update the ticket with the results when you get a chance.

dingmingxin commented 7 years ago

In branch wxwidgets311, the same error occurs.

dingmingxin commented 7 years ago

After I comment the lines which cause the error above, and continue to compile, I got this:

[ 33%] Building CXX object modules/wxbind/CMakeFiles/wxLuaBindLib.dir/src/wxadv_bind.cpp.o
/Users/dmx/Documents/wxwidgets/wxlua/wxLua/modules/wxbind/src/wxadv_bind.cpp:16296:50: error: use of undeclared identifier 'wxGRIDTABLE_REQUEST_VIEW_GET_VALUES'
        { "wxGRIDTABLE_REQUEST_VIEW_GET_VALUES", wxGRIDTABLE_REQUEST_VIEW_GET_VALUES },
                                                 ^
/Users/dmx/Documents/wxwidgets/wxlua/wxLua/modules/wxbind/src/wxadv_bind.cpp:16297:51: error: use of undeclared identifier 'wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES'
        { "wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES", wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES },
                                                  ^
/Users/dmx/Documents/wxwidgets/wxlua/wxLua/modules/wxbind/src/wxadv_bind.cpp:16367:19: error: invalid application of 'sizeof' to an incomplete type
      'wxLuaBindNumber []'
    count = sizeof(numberList)/sizeof(wxLuaBindNumber) - 1;
                  ^~~~~~~~~~~~
3 errors generated.
make[2]: *** [modules/wxbind/CMakeFiles/wxLuaBindLib.dir/src/wxadv_bind.cpp.o] Error 1
make[1]: *** [modules/wxbind/CMakeFiles/wxLuaBindLib.dir/all] Error 2
make: *** [all] Error 2

It seems like that using sizeof on a static array is illegal when crossing compile with c and c++. I try test the sizeof behavior on a static array in a function in pure c code, it is ok, no error occured. Are there any compiling options that can avoid this error ?

pkulchenko commented 7 years ago

@dingmingxin, that's interesting. I wonder what compiler (and version) you are using.

I've compiled with the following configure command for wxwidgets:

  ./configure --prefix="$INSTALL_DIR" $WXWIDGETSDEBUG --disable-shared --enable-unicode \
    --enable-compat28 \
    --with-libjpeg=builtin --with-libpng=builtin --with-libtiff=no --with-expat=no \
    --with-zlib=builtin --disable-richtext \
    --enable-macosx_arch=$MACOSX_ARCH --with-macosx-version-min=$MACOSX_VERSION $MINSDK \
    --with-osx_cocoa CFLAGS="-Os" CXXFLAGS="-Os"

and the following cmake command for wxlua:

  cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" -DCMAKE_BUILD_TYPE=$WXLUABUILD -DBUILD_SHARED_LIBS=FALSE \
    -DCMAKE_OSX_ARCHITECTURES=$MACOSX_ARCH -DCMAKE_OSX_DEPLOYMENT_TARGET=$MACOSX_VERSION $MINSDK \
    -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ -DwxWidgets_CONFIG_EXECUTABLE="$INSTALL_DIR/bin/wx-config" \
    -DwxWidgets_COMPONENTS="stc;gl;html;aui;adv;core;net;base" \
    -DwxLuaBind_COMPONENTS="stc;gl;html;aui;adv;core;net;base" -DwxLua_LUA_LIBRARY_USE_BUILTIN=FALSE \
    -DwxLua_LUA_INCLUDE_DIR="$INSTALL_DIR/include" -DwxLua_LUA_LIBRARY="$INSTALL_DIR/lib/liblua.dylib" .
pkulchenko commented 7 years ago

@dingmingxin, do you still have the issue with the commands I shown earlier?

pkulchenko commented 7 years ago

@dingmingxin, closing for now; feel free to reopen if you have additional information.