Author Topic: Linker problems when building the quest editor in OS X Sierra  (Read 1350 times)

chadius

  • Newbie
  • *
  • Posts: 6
    • View Profile
Linker problems when building the quest editor in OS X Sierra
« 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.
Code: [Select]
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.

Code: [Select]
//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?

chadius

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Linker problems when building the quest editor in OS X Sierra
« Reply #1 on: January 08, 2017, 04:43:13 pm »
Okay, I got it to compile by using Lua instead of LuaJIT:

Code: [Select]
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.

Code: [Select]
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!

chadius

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Linker problems when building the quest editor in OS X Sierra
« Reply #2 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.

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1172
    • View Profile
Re: Linker problems when building the quest editor in OS X Sierra
« Reply #3 on: January 08, 2017, 06:25:49 pm »
Sorry, I can't help you a lot on Mac OS X.

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1172
    • View Profile
Re: Linker problems when building the quest editor in OS X Sierra
« Reply #4 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.)

chadius

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Linker problems when building the quest editor in OS X Sierra
« Reply #5 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.

Code: [Select]
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?

chadius

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Linker problems when building the quest editor in OS X Sierra
« Reply #6 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.

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1172
    • View Profile
Re: Linker problems when building the quest editor in OS X Sierra
« Reply #7 on: January 08, 2017, 07:56:04 pm »
I confirm that Solarus works with Lua 5.1 (or LuaJIT) but no other versions.

chadius

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Linker problems when building the quest editor in OS X Sierra
« Reply #8 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)

Code: [Select]
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!