Compiling on macOS with cmake and CLion

Get help with compiling or installing the game, and discuss announcements of new official releases.

Moderators: Forum Moderators, Developers

Compiling on macOS with cmake and CLion

Postby nosba » August 6th, 2017, 11:46 am

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: https://forums.wesnoth.org/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][/code]::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


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)


but now when I run the executable "wesnoth" It prints the following output and it blocks it self (waiting something, I suppose):
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.


what should I do to make it run?
nosba
 
Posts: 7
Joined: January 17th, 2016, 4:49 pm

Re: Compiling on macOS with cmake and CLion

Postby Celtic_Minstrel » August 13th, 2017, 2:49 am

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?
Author of The Black Cross of Aleron campaign and Default++ era.
Maintainer of Steelhive.
User avatar
Celtic_Minstrel
Developer
 
Posts: 723
Joined: August 3rd, 2012, 11:26 pm

Re: Compiling on macOS with cmake and CLion

Postby mattsc » August 13th, 2017, 3:02 am

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.
mattsc
 
Posts: 945
Joined: October 13th, 2010, 6:14 pm
Location: Canada

Re: Compiling on macOS with cmake and CLion

Postby nosba » August 17th, 2017, 5:04 pm

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:
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


to

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


doing that changes it's possible to restore the original CMakeLists.txt.
nosba
 
Posts: 7
Joined: January 17th, 2016, 4:49 pm


Return to Release Announcements, Compiling & Installation

Who is online

Users browsing this forum: No registered users and 3 guests