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

Failed to build on MacOS. #42

Closed ValeryKV closed 5 years ago

ValeryKV commented 5 years ago

My env: macOS 10.13.6, Xcode 9.4.1, wxWidgets 3.0.4, wxLua 3.0 (master)

I followed the steps from https://github.com/pkulchenko/wxlua/blob/master/wxLua/docs/install.txt. I built wxWidgets as release, unicode, without (mediactrl).

Here is the error:

api:wx3.0-us valery$ make
[ 20%] Built target LuaLib
[ 21%] Built target lua
[ 22%] Built target luac
[ 23%] Building CXX object modules/wxlua/CMakeFiles/wxLuaLib.dir/wxlbind.cpp.o
In file included from /Users/valery/Downloads/wxlua-master/wxLua/modules/wxlua/wxlbind.cpp:17:
In file included from /Users/valery/Downloads/wxWidgets-3.0.4/include/wx/wx.h:15:
In file included from /Users/valery/Downloads/wxWidgets-3.0.4/include/wx/object.h:19:
In file included from /Users/valery/Downloads/wxWidgets-3.0.4/include/wx/memory.h:15:
In file included from /Users/valery/Downloads/wxWidgets-3.0.4/include/wx/string.h:46:
/Users/valery/Downloads/wxWidgets-3.0.4/include/wx/strvararg.h:30:18: fatal error: 'tr1/type_traits' file not found
        #include <tr1/type_traits>
                 ^~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [modules/wxlua/CMakeFiles/wxLuaLib.dir/wxlbind.cpp.o] Error 1
make[1]: *** [modules/wxlua/CMakeFiles/wxLuaLib.dir/all] Error 2
make: *** [all] Error 2

Here are all type_traits I have:

/opt/local/include/gcc/c++/experimental/type_traits
/opt/local/include/gcc/c++/tr1/type_traits
/opt/local/include/gcc/c++/tr2/type_traits
/opt/local/include/gcc/c++/type_traits

I do not know why /opt/local/include/gcc/c++ is not included in the compilation. Should I provide other information that may help to fix it?

I also tried to install wxWidgets & wxLua using macport and it works. It installs shared libs for wxWidgets-3.0 and wxLua 2.8. But I also want to build wxLua 3.0 and static libs.

pkulchenko commented 5 years ago

@ValeryKV, you may need to roll back the changes in the earlier commit: 244c5f157619522101b7c0346605daedaeafae8f. It was done to fix the conflict with stdlib for compilers supporting c++11. If both (old and new) compilers need to be supported, then the check needs to be updated to only get activated for a specific version of xcode, but I'm not sure how to describe that in cmake.

ValeryKV commented 5 years ago

I rolled back the commit and all completed successfully. The error is in linking now:

make[2]: *** No rule to make target `.../wxWidgets-3.0.4/build_osxu/lib/libwx_osx_cocoau_media-3.0.a', needed by `lib/Release/libwx.dylib'.  Stop.
make[1]: *** [modules/luamodule/CMakeFiles/wxLuaModule.dir/all] Error 2
make: *** [all] Error 2

I configured wxWidgets with --disable-mediactrl. Otherwise it is not compiled. I cannot find the issue about it, but as workaround they advised to add this flag.

What can I do to fix linking?

pkulchenko commented 5 years ago

@ValeryKV, what's the content of the lib folder where the missing library is expected to be? I suspect it may be a name mismatch; for example, you may find libwxmedia-3.0.a in that folder instead of libwx_osx_cocoau_media-3.0.a. I've seen this happening with libwxscintilla, but I haven't used mediactrl, so can't be sure.

ValeryKV commented 5 years ago

@pkulchenko, I had to guess. I compiled wxWidgets with "--disable-mediactrl" and it did not build media library. I remove 'media' from wxLuaBind_COMPONENTS and wxWidgets_COMPONENTS and regenerated files. Now make shows many link errors Undefined symbols for architecture x86_64:

...
  "_lua_xmove", referenced from:
      wxLuaState::lua_XMove(wxLuaState const&, int) in wxlstate.cpp.o
  "_lua_yieldk", referenced from:
      wxLuaState::lua_Yield(int) in wxlstate.cpp.o
  "_luaopen_bit32", referenced from:
      wxLuaState::Create(lua_State*, int) in wxlstate.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [lib/Release/libwx.dylib] Error 1
make[1]: *** [modules/luamodule/CMakeFiles/wxLuaModule.dir/all] Error 2
make: *** [all] Error 2

How can I fix that?

pkulchenko commented 5 years ago

Now make shows many link errors Undefined symbols for architecture x86_64

This looks like build errors on a mixed (not clean) build. Try running the following before rebuilding from wxlua/wxLua folder: make clean; git checkout .; git clean -fd (the last command will remove all files that are not in the repo, so if you have any new files or modifications you need, save them).

ValeryKV commented 5 years ago

@pkulchenko, here are my steps:

1. git clone to new location.
2. rollback #244c5f1.
3. configure and generate to new clean location.
4. run 'make'.

The error is the same. It seems that the linker requires lib/Release/libwx.dylib. But my Release folder contains:

libwxlua-wx30osx_cocoau-3.0.0.3.dylib
libwxlua_bind-wx30osx_cocoau-3.0.0.3.dylib
libwxlua_debug-wx30osx_cocoau-3.0.0.3.dylib
libwxlua_debugger-wx30osx_cocoau-3.0.0.3.dylib
libwxlua_lua52-wx30osx_cocoau-3.0.0.3.dylib
pkulchenko commented 5 years ago

what's your full configure call?

ValeryKV commented 5 years ago

Do you mean configure for wxWidgets? I attached the output of cmake output.txt .

pkulchenko commented 5 years ago

I mean the configure command itself. Did you pass any parameters to it?

ValeryKV commented 5 years ago

I did not run configure for wxLua, only for wxWidgets. All my cmake-gui settings are attached. Screen Shot 2019-08-15 at 8 05 51 AM

BTW. I did not find liblua.a/dylib inside my build folder. I have many compiled .o files, but there is no the library. Does it matter?

pkulchenko commented 5 years ago

@ValeryKV, I don't see anything wrong with the settings. BTW, linker can't require lib/Release/libwx.dylib, as it's going to build that library.

pkulchenko commented 5 years ago

Closing as the current master branch builds on macOS without issues.

If you still have the problem, can you check if your configuration builds against wxwidgets 3.1? Are you required to use 3.0.4?