What is needed for a proper Mac support - Page 2

What is needed for a proper Mac support

Discuss everything related to compiling and running Spring on Mac OS X.

Moderator: Moderators

lamer
Posts: 153
Joined: 08 Mar 2014, 23:13

Re: What is needed for a proper Mac support

Post by lamer »

I think i was too afraid of libstdc++ compatibility issue and made few mistaken assumptions.
In the end properly compiled spring (libstdc++) and springlobby (libc++) are running fine.
Last time i forgot to statically link boost and that gave me error with libunitsync.dylib, not libstdc++.
Sorry for misleading.

Also to compile springlobby i used moobyfr's cmake fix and

Code: Select all

diff --git a/src/lsl/spring/spring.cpp b/src/lsl/spring/spring.cpp
index 298d986..0612cc6 100644
--- a/src/lsl/spring/spring.cpp
+++ b/src/lsl/spring/spring.cpp
@@ -35,6 +35,8 @@
 #include <boost/filesystem/fstream.hpp>
 #include <boost/algorithm/string.hpp>
 
+#include <wx/filename.h>
+
 namespace LSL {
 
 namespace BF = boost::filesystem;
@@ -207,7 +209,8 @@ bool Spring::LaunchSpring( const std::string& params  )
     std::string cmd;// =  "\"" + sett().GetCurrentUsedSpringBinary();
 #ifdef __WXMAC__
     wxChar sep = wxFileName::GetPathSeparator();
-    if ( sett().GetCurrentUsedSpringBinary().AfterLast('.') == "app" )
+       std::string binary = Util::config().GetCurrentUsedSpringBinary();
+       if ( binary.substr(binary.rfind('.') + 1) == "app" )
         cmd += sep + std::string("Contents") + sep + std::string("MacOS") + sep + std::string("spring"); // append app bundle inner path
 #endif
     cmd += "\" " + configfileflags + params;
abma
Spring Developer
Posts: 3798
Joined: 01 Jun 2009, 00:08

Re: What is needed for a proper Mac support

Post by abma »

1) Is there an easy way to forbid springlobby from using libunitsync?
rename/delete libunitsync.so
lamer
Posts: 153
Joined: 08 Mar 2014, 23:13

Re: What is needed for a proper Mac support

Post by lamer »

Made PR from previous comment with code.
springlobby/lsl PR
abma
Spring Developer
Posts: 3798
Joined: 01 Jun 2009, 00:08

Re: What is needed for a proper Mac support

Post by abma »

thanks, merged both pull requests into springlobby!

merged also the pull request to spring, thanks a lot!
darklord42
Posts: 96
Joined: 26 Jul 2014, 07:11

Re: What is needed for a proper Mac support

Post by darklord42 »

Does this mean that there will finally be a proper osx app bundle for spring and spring lobby, with all the resources/libraries needed to run bundled and linked together, on the next major release?

Do we know if it compiles with clang? Gcc can be installed on macports, but then it needs to link against the gcc libraries inside the macports install. There might be a way around it, but it is a hurdle.
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: What is needed for a proper Mac support

Post by Silentwings »

1) Possibly. (There is one with RC2 for 99.0)
2) No, it has to be gcc (or it won't sync).
darklord42
Posts: 96
Joined: 26 Jul 2014, 07:11

Re: What is needed for a proper Mac support

Post by darklord42 »

oh great, I didn't see the download page updated! Unfortionatly I get an error 404 on that link. :(

Out of curiosity I assume you bundled the gcc c libraries with the app?
lamer
Posts: 153
Joined: 08 Mar 2014, 23:13

Re: What is needed for a proper Mac support

Post by lamer »

Did someone actually make a bundle? Can't find any links (Download_Testing is just a template and doesn't point to a bundle).
I know that its possible atleast for particular OS X version (10.10). But i assume the official buildbot is still not working (or rather there is no dedicated OS X environment to build spring), no?
I guess so far there will be only proper home-made bundles.

Maybe it's easier to install bubuntu? :) Who needs apples anyway?
darklord42
Posts: 96
Joined: 26 Jul 2014, 07:11

Re: What is needed for a proper Mac support

Post by darklord42 »

If it compiles, I can reset my dev environment and try to build a bundle. I have 10.6 server installed on Oracle's VM VirtualBox, for such purposes. Last time I tried it with cmake IIRC it isn't setup to build an actual bundle. i don't know enough about cmake to make it happen

Normally with other projects, I use dylibbundler tool to scan the binary after compilation, copy all linked dylibs into the bundle and (plus their dependencies), and relink everything to the new folder destination relative to the binary.

Of course, if all this can be done at build time with cmake, that would be much better and easier to automate, which I know has the mechanisms for it. But I have no idea how it would deal with the gcc libraries.
lamer
Posts: 153
Joined: 08 Mar 2014, 23:13

Re: What is needed for a proper Mac support

Post by lamer »

Here's my steps for OS X 10.10 build:
#1 macports

Code: Select all

sudo port install gcc49 cmake libdevil p7zip libvorbis libsdl2 freetype glew xorg-libXcursor
#2 boost
Download src and compile with gcc49.
Unfortunately i forgot actual steps :(.
#3 download and install java (jdk) for less compile errors or JavaAI support.
#4 clone develop branch, compile spring with

Code: Select all

cmake . -DCMAKE_CXX_COMPILER=/opt/local/bin/g++-mp-4.9 -DCMAKE_C_COMPILER=/opt/local/bin/gcc-mp-4.9 -DGLEW_INCLUDE_DIR=/opt/local/include/GL -DBOOST_ROOT=/path/to/gcc/boost -DBoost_USE_STATIC_LIBS=YES
make spring -j8
#5 run ./spring

Never tested bundling or proper static linking.

I assume there can be an issue with springlobby, because it uses wxWidgets and they use system sdk libraries (libc++, OS X >= 10.9). E.g. springlobby needs separate 10.6, 10.9, 10.10 versions, but not sure about it.
For springlobby only had to install wxWidgets:

Code: Select all

sudo port install wxWidgets-3.0-libcxx
@moobyfr also compiled spring with homebrew, but i don't remember if he published actual steps.
ikinz
Posts: 5
Joined: 11 Apr 2014, 19:41

Re: What is needed for a proper Mac support

Post by ikinz »

EDIT: Accidentally replied to Anarchid's post on the first page.

CarRepairer has successfully compiled and run swl on his Mac. It involved some silly hacks to hack around Qt's silly hacks because we didn't know anything and the motivation to package it was low since spring didn't work on Mac anyway.

Here's the hack list: https://github.com/springweblobby/swl-w ... evelopment
darklord42
Posts: 96
Joined: 26 Jul 2014, 07:11

Re: What is needed for a proper Mac support

Post by darklord42 »

Thanks lamer for the hep!

Regarding boost. I don't think its a good idea to install a boost dependent on your macports install on your system. Personally I don't think it's a good idea to install such unix software directly on your system potentially cluttering things up, and causing problems later down the road. Definitely not without a package manager.

Macports did have a variant of boost for each compiler to build it directly with that compiler but they seem to have gotten rid of it. Therefore the thing to do should be something like

Code: Select all

sudo -s port install boost configure.compiler=macports-gcc-4.9
In an ideal world, I haven't gotten it to work yet. Well it configures with the appropriate gcc and fails for some other reason yet to be determined.
lamer
Posts: 153
Joined: 08 Mar 2014, 23:13

Re: What is needed for a proper Mac support

Post by lamer »

I intentionally omit macport's gcc-boost version, because public system library should be libc++, also springlobby needs libc++ boost (if my memory doesn't fail me), and gcc-boost used only once - to statically link with spring.
Thats why i compiled boost manually in non-default hidden place (there is no need to install it, -DBOOST_ROOT points to it).
darklord42
Posts: 96
Joined: 26 Jul 2014, 07:11

Re: What is needed for a proper Mac support

Post by darklord42 »

Ah! I see now the method to your madness. :) Sounds good
darklord42
Posts: 96
Joined: 26 Jul 2014, 07:11

Re: What is needed for a proper Mac support

Post by darklord42 »

well that stinks. libsdl2 requires 10.7 or later. So 10.6 is out. And I don't have a 10.7 system. (macports is very finicky when it comes to building for previous OS on a later one.) I suppose the app will be 10.10 only
darklord42
Posts: 96
Joined: 26 Jul 2014, 07:11

Re: What is needed for a proper Mac support

Post by darklord42 »

dang I have hit a wall It just says

Code: Select all

[ 65%] Built target assimp
[ 65%] Building CXX object rts/Sim/CMakeFiles/engineSim.dir/Weapons/WeaponDefHandler.cpp.o
[ 65%] Building CXX object rts/Sim/CMakeFiles/engineSim.dir/Weapons/WeaponLoader.cpp.o
Linking CXX static library libengineSim.a
[ 65%] Built target engineSim
make[1]: *** [rts/builds/CMakeFiles/spring.dir/rule] Error 2
make: *** [spring] Error 2
any ideas?

I actually suspect I compiled boost incorrectly

I put in project-config.jam

Code: Select all

using gcc : : /opt/local/bin/g++-mp-4.9 ;
as the compiler configuration, instead of the darwin stuff and ran
./b2

Any of that ringing a bell?
Last edited by darklord42 on 16 Jan 2015, 23:19, edited 1 time in total.
abma
Spring Developer
Posts: 3798
Joined: 01 Jun 2009, 00:08

Re: What is needed for a proper Mac support

Post by abma »

a compile error happened which isn't visible in the copy and pasted text.
lamer
Posts: 153
Joined: 08 Mar 2014, 23:13

Re: What is needed for a proper Mac support

Post by lamer »

Paste more info. Try "make spring" (single thread -j1) and the error should be near bottom of the log. Or search for error message in the middle (as threaded compilation doesn't instantly terminates all build targets).
darklord42
Posts: 96
Joined: 26 Jul 2014, 07:11

Re: What is needed for a proper Mac support

Post by darklord42 »

EDIT
never mind I think I found the answer, boy I get a lot of junk on my computer. I'll have to try again tomorrow.
darklord42
Posts: 96
Joined: 26 Jul 2014, 07:11

Re: What is needed for a proper Mac support

Post by darklord42 »

So close. I reached the linking stage and got this

Code: Select all

Undefined symbols for architecture x86_64:
  "___GLEW_ARB_ES3_compatibility", referenced from:
      CSMFGroundTextures::LoadTiles(CSMFMapFile&)       in SMFGroundTextures.cpp.o
  "___GLEW_ARB_buffer_storage", referenced from:
      VBO::VBO(unsigned int, bool) in VBO.cpp.o
      VBO::VBO(unsigned int, bool) in VBO.cpp.o
  "___GLEW_ARB_debug_output", referenced from:
      LoadExtensions()     in myGL.cpp.o
  "___GLEW_ARB_invalidate_subdata", referenced from:
      VBO::Invalidate()      in VBO.cpp.o
  "___GLEW_ARB_texture_storage", referenced from:
      glSpringTexStorage2D(unsigned int, int, int, int, int) in myGL.cpp.o
  "___GLEW_NVX_gpu_memory_info", referenced from:
      LoadExtensions()     in myGL.cpp.o
  "___glewBufferStorage", referenced from:
      VBO::New(long, unsigned int, void const*) in VBO.cpp.o
  "___glewDebugMessageCallbackARB", referenced from:
      LoadExtensions()     in myGL.cpp.o
  "___glewInvalidateBufferData", referenced from:
      VBO::Invalidate()      in VBO.cpp.o
  "___glewProgramParameteri", referenced from:
      Shader::GLSLCopyState(unsigned int, unsigned int, std::unordered_map<unsigned long, Shader::UniformState, fast_hash, std::equal_to<unsigned long>, std::allocator<std::pair<unsigned long const, Shader::UniformState> > >*) in GLSLCopyState.cpp.o
  "___glewTexStorage2D", referenced from:
      glSpringTexStorage2D(unsigned int, int, int, int, int) in myGL.cpp.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[3]: *** [spring] Error 1
make[2]: *** [rts/builds/legacy/CMakeFiles/engine-legacy.dir/all] Error 2
make[1]: *** [rts/builds/CMakeFiles/spring.dir/rule] Error 2
make: *** [spring] Error 2
Joshuas-MacBook-Pro:build her
I remembered to point to the Glew headers under /opt/local/include/Gl

At first I thought it was an errant Glew Framework folder in my /Library/Frameworks folder, but I guess not...
Post Reply

Return to “Mac OS X”