Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SFML 1.6 without admin priviliges

Tags:

c++

macos

gcc

sfml

So I have this SFML 1.6 application that works well on Mac OS X Lion. Currently the way I have it is that the SFML frameworks are in /Library/Frameworks and it works well, however to install on other machines it requires admin privileges. So I want to do one of the following:

  1. Be able to install the libraries in /User/idk/Library/Frameworks or similar

  2. Package the libraries and the app into a Mac disk image and have it reference the libraries from there

  3. Statically link the libraries

Now since the program is built using the Terminal with makefiles, I would prefer the solution to be in the Terminal rather than XCode, but if absolutely necessary then I guess I could somehow import the project to XCode.

So can anyone explain (precisely) how to do any of the three above, whichever is the easiest to do?

By the way I'm using the LLVM GCC 4.2 that ships with XCode 4.1 for the compilation.

EDIT:

How about someone tries the other two, aside from statically linking?

like image 796
slartibartfast Avatar asked Feb 09 '12 03:02

slartibartfast


2 Answers

I solved it so... kind of a waste of bounty points... SUCKS FOR YOU! :P

I did something quite simple and was surprised no one else had suggested it:

I used install_name_tool to change the names and dependencies of the SFML dynamic libraries so that they can be placed in the same directory as the executable, or in a special folder, but that's relative to the executable's directory. So it requires no admin privileges, and I easily packaged it all into an application bundle.

like image 118
slartibartfast Avatar answered Oct 12 '22 15:10

slartibartfast


You should probably statically link to SFML. To do this you will have to compile SFML as a static library. The easiest way to do this is probably to modify the Xcode project that comes with SFML ("SFML with Intel 64 bits.xcodeproj"). You need to change the Mach-O type of the libraries to Static Library.

I've uploaded the modified version of SFML with Intel 64 bits.xcodeproj that I use, you can get it here. (This project requires GCC4.2, and so only works with Xcode 3).

Statically linking to SFML is very similar to dynamically linking to it, just remember that you also need to link to Cocoa.framework, OpenGL.framework, and CoreFoundation.framework.

Also note that if you want to deploy to OSX 10.4 or earlier, you should statically link to libfreetype. The libfreetype that is supplied with the OS is in a different location in 10.4 and earlier, and this causes problems when it is dynamically linked.

like image 44
Mankarse Avatar answered Oct 12 '22 17:10

Mankarse