Solarus-Games English Forum

Solarus => Development => Topic started by: chadius on January 08, 2017, 04:20:02 PM

Title: Linker problems when building the quest editor in OS X Sierra
Post by: chadius on January 08, 2017, 04:20:02 PM
New poster, here. I want to add new features to the quest editor, but I can't get it to link on OS X Sierra.

I compiled the engine with almost no trouble. When I try to build the quest engine, it compiles everything but fails to link correctly.
make
[  1%] Automatic moc for target solarus-quest-editor
[  1%] Built target solarus-quest-editor_automoc
[  2%] Linking CXX executable solarus-quest-editor
Undefined symbols for architecture x86_64:
  "_lua_pcallk", referenced from:
      SolarusEditor::ExternalScriptDialog::run_script() in external_script_dialog.cpp.o
  "_lua_setglobal", referenced from:
      SolarusEditor::ExternalScriptDialog::run_script() in external_script_dialog.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]: *** [solarus-quest-editor] Error 1
make[1]: *** [CMakeFiles/solarus-quest-editor.dir/all] Error 2
make: *** [all] Error 2


When I Google for similar errors, it says clang should use the old standard C library libstdc++ instead of the newer libc++. cmake is using libc++ for LuaJIT, which was recommended.

//LuaJIT woraround
CMAKE_EXE_LINKER_FLAGS:STRING= -stdlib=libc++ -Xlinker -rpath -Xlinker @loader_path/../Frameworks/ -pagezero_size 10000 -image_base 100000000


Was anyone able to compile this with LuaJIT? Were you able to compile with Lua?
Title: Re: Linker problems when building the quest editor in OS X Sierra
Post by: chadius on January 08, 2017, 04:43:13 PM
Okay, I got it to compile by using Lua instead of LuaJIT:

cmake -DCMAKE_PREFIX_PATH="/usr/local/Cellar/qt5/5.7.1_1/lib/cmake/" -DSOLARUS_USE_LUAJIT=OFF -Wno-dev ..

Note that I still had to install LuaJIT, solarus quest editor is still looking for it.

bash-3.2$ ./solarus-quest-editor
dyld: Library not loaded: /usr/local/opt/luajit/lib/libluajit-5.1.2.dylib
  Referenced from: /usr/local/lib/libsolarus.1.dylib
  Reason: image not found
Abort trap: 6


Alright, now it's time to to tweak! Thanks for making this!
Title: Re: Linker problems when building the quest editor in OS X Sierra
Post by: chadius on January 08, 2017, 05:59:37 PM
I can start the quest editor, but it doesn't react to any input. I can't open any menu items. I'll keep poking it and see if I can find out what's going on.
Title: Re: Linker problems when building the quest editor in OS X Sierra
Post by: Christopho on January 08, 2017, 06:25:49 PM
Sorry, I can't help you a lot on Mac OS X.
Title: Re: Linker problems when building the quest editor in OS X Sierra
Post by: Christopho on January 08, 2017, 06:30:08 PM
But if you compile the quest editor also with -DSOLARUS_USE_LUAJIT=OFF, they should both agree not to use LuaJIT. (Maybe a clean is needed first.)
Title: Re: Linker problems when building the quest editor in OS X Sierra
Post by: chadius on January 08, 2017, 06:40:05 PM
I figured out the problem with the menus, it's specific to QT5 on Mac OS X. The menus don't respond until you unfocus and refocus to the quest editor.

Now I can try to open a quest... and it crashes when it tries to read the dat file. Maybe my Lua workaround isn't working, in which case I'm back to square one.

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libluajit-5.1.2.dylib          0x00000001095f7bf9 lua_pushfstring + 89
1   solarus-quest-editor          0x0000000103c89415 SolarusEditor::QuestProperties::reload() + 181
2   org.qt-project.QtCore          0x0000000109226ca9 QMetaObject::activate(QObject*, int, int, void**) + 3113
3   solarus-quest-editor          0x0000000103cb4885 SolarusEditor::Quest::root_path_changed(QString const&) + 53
4   solarus-quest-editor          0x0000000103c7575e SolarusEditor::Quest::set_root_path(QString const&) + 142
5   solarus-quest-editor          0x0000000103bbf49b SolarusEditor::MainWindow::open_quest(QString const&) + 59




Christopho, is there a flag I can use that will give me more debug information?
Title: Re: Linker problems when building the quest editor in OS X Sierra
Post by: chadius on January 08, 2017, 07:07:06 PM
Okay, it is an issue with Lua on Mac OS X. Use Lua version 5.1. ("brew lua51" if you're using Homebrew)

I've seen some posts where toluapp fails to compile on Lua 5.2+, or it compiles and fails to link. I had to rebuild both the solarus engine AND the solarus quest editor with Lua 5.1 to get it running.
Title: Re: Linker problems when building the quest editor in OS X Sierra
Post by: Christopho on January 08, 2017, 07:56:04 PM
I confirm that Solarus works with Lua 5.1 (or LuaJIT) but no other versions.
Title: Re: Linker problems when building the quest editor in OS X Sierra
Post by: chadius on January 08, 2017, 08:32:55 PM
Thanks for confirming, Christopho!

You may want to mention a few caveats for the Mac OS compilers:
- compile against Lua 5.1.
- When you open the quest editor, the menubar may be unresponsive. You can switch to a different application then switch back to regain control of it.
- If the quest editor crashes when you open a quest, you must recompile the solarus engine and the quest editor without LuaJIT support. (One of my Macs works with it, the other doesn't)

cmake -DCMAKE_PREFIX_PATH="/usr/local/Cellar/qt5/5.7.1_1/lib/cmake/" -DSOLARUS_USE_LUAJIT=OFF -Wno-dev ..

If you want me to I can make the changes and make a pull request/send you a patch.

Okay, now I can start tinkering with the engine. Thanks for making it!