Compiling on macOS with cmake and CLion
Moderator: Forum Moderators
Compiling on macOS with cmake and CLion
Hi all,
I'm trying again to compile and run Wesnoth from sources in CLion with cmake in macOS (I tried last year and I failed: viewtopic.php?f=5&t=44120), while I was compiling I got this errors:
::send_notification(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, desktop::notifications::type)", referenced from:
desktop::notifications::send(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, desktop::notifications::type) in notifications.cpp.o
"apple_notifications::available()", referenced from:
desktop::notifications::available() in notifications.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[3]: *** [wesnoth] Error 1
make[2]: *** [src/CMakeFiles/wesnoth.dir/all] Error 2
make[1]: *** [src/CMakeFiles/wesnoth.dir/rule] Error 2
make: *** [wesnoth] Error 2
[/code]
I've solved all the errors adding this line to cmake file:
but now when I run the executable "wesnoth" It prints the following output and it blocks it self (waiting something, I suppose):
what should I do to make it run?
I'm trying again to compile and run Wesnoth from sources in CLion with cmake in macOS (I tried last year and I failed: viewtopic.php?f=5&t=44120), while I was compiling I got this errors:
Code: Select all
Undefined symbols for architecture x86_64:
"_SDL_main", referenced from:
-[SDLMain applicationDidFinishLaunching:] in libSDLmain.a(SDLMain.o)
"apple_notifications[code]
desktop::notifications::send(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, desktop::notifications::type) in notifications.cpp.o
"apple_notifications::available()", referenced from:
desktop::notifications::available() in notifications.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[3]: *** [wesnoth] Error 1
make[2]: *** [src/CMakeFiles/wesnoth.dir/all] Error 2
make[1]: *** [src/CMakeFiles/wesnoth.dir/rule] Error 2
make: *** [wesnoth] Error 2
[/code]
I've solved all the errors adding this line to cmake file:
Code: Select all
if(APPLE)
set(libwesnoth-game_STAT_SRC
${libwesnoth-game_STAT_SRC}
desktop/apple_notification.mm
macosx/SDLmain.mm
)
endif(APPLE)
Code: Select all
objc[51789]: Class SDLApplication is implemented in both /usr/local/opt/sdl2/lib/libSDL2-2.0.0.dylib (0x1137f0d70) and ~/git/wesnoth/cmake-build-debug/wesnoth (0x1106d6308). One of the two will be used. Which one is undefined.
- Celtic_Minstrel
- Developer
- Posts: 2222
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Compiling on macOS with cmake and CLion
I've seen that warning before and it appeared to be harmless; I'm not sure how to fix it, though. Maybe we could just rename the SDLApplication class, I guess? You'd also update the Info.plist file to refer to the renamed class instead of SDLApplication. I don't really expect this to fix your hang, but I guess it's worth a try?
Re: Compiling on macOS with cmake and CLion
Unfortunately I don't know how to help you either, but I can second what Celtic_Minstrel wrote. I get that message every time I start master (compiled using Xcode) and Wesnoth runs just fine after that. So I doubt that that causes your hang.
Edit: One thing to note might be that sometimes, when I first compile a new version, it might take a long time before the Wesnoth window actually appears. As in, a couple minutes or so. After that first time, it usually pops up in a couple seconds.
Edit: One thing to note might be that sometimes, when I first compile a new version, it might take a long time before the Wesnoth window actually appears. As in, a couple minutes or so. After that first time, it usually pops up in a couple seconds.
SP campaigns: Galuldur's First Journey (1.12 & 1.14) & Grnk the Mighty (1.10 & 1.12)
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
Re: Compiling on macOS with cmake and CLion
Hi all,
I found a way to compile and run, thanks to singalen who helped me in the discord's server.
The solution is to change the line 944 in the wesnoth.cpp file (src/wesnoth.cpp) from:
to
doing that changes it's possible to restore the original CMakeLists.txt.
I found a way to compile and run, thanks to singalen who helped me in the discord's server.
The solution is to change the line 944 in the wesnoth.cpp file (src/wesnoth.cpp) from:
Code: Select all
#ifdef __APPLE__
extern "C" int wesnoth_main(int argc, char** argv);
int wesnoth_main(int argc, char** argv)
#else
int main(int argc, char** argv)
#endif
Code: Select all
#ifdef __IPHONEOS__
extern "C" int wesnoth_main(int argc, char** argv);
int wesnoth_main(int argc, char** argv)
#else
int main(int argc, char** argv)
#endif
- Celtic_Minstrel
- Developer
- Posts: 2222
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Compiling on macOS with cmake and CLion
I wonder if everything works correctly when you do that, though. There should be some custom menuitems in the application menu to launch the website and show the changelog, for example. And do key-equivalents for the application menu work? For example, Cmd+H for hide. Basically anything in this file. Also, if you don't change the CMake file to include apple_notifications.mm, I assume you won't be able to enable the native notifications that pop up to inform you that it's your turn.