Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: You cannot use the screensaver on this computer (MacOsx 10.6.8, SFML 2.0, xcode  (Read 12202 times)

0 Members and 1 Guest are viewing this topic.

starmessage

  • Newbie
  • *
  • Posts: 27
    • View Profile
    • View the moon phase and write your name in the stars
Hi, I am trying to create a cross platform screensaver.

I have xcode 3.2.6.
Downloaded and installed the ready .pkg of SFML 2.0
I did not use the project templates of the .pkg as they are for xcode 4.
I added the SFML frameworks in my project's linked frameworks.
Compilation and linking go Ok.

The problem is when I try to run the screensaver.
Mac shows the following error:
Quote
You cannot use the screensaver on this computer.
Contact the developer of this screensaver for a newer version
Searching in the apple forums, it seems this is created by two reasons:
1) a 32 bit screensaver that is run under a 64 bit system (my mac is 64 bit)
2) under the compilation settings, the garbage collection must be set to "supported"

For (1) I am creating the screensaver for both 32 and 64 bits, and also the screensaver was not showing this error before using the SFML. Therefore I believe it is related to the SFML frameworks.
For (2) I already have this setting Ok.

I also included the frameworks in the final package.
It does not matter if I am in Debug or Release mode.
I tried to use the Dylibs but the error remains.

Can you please give me some ideas on how to advance from here?
Thanks !

starmessage

  • Newbie
  • *
  • Posts: 27
    • View Profile
    • View the moon phase and write your name in the stars
and here is some information from apple.
http://developer.apple.com/library/mac/#qa/qa1666/_index.html

I am new to SFML and MAC so please forgive me if I do not see an obvious mistake I did.

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Question:
Quote
The problem is when I try to run the screensaver.
How did you create this screensaver with SFML ?

Quote
For (1) I am creating the screensaver for both 32 and 64 bits, and also the screensaver was not showing this error before using the SFML. Therefore I believe it is related to the SFML frameworks.
SFML is compiled for both 32 and 64 bits. You can check this with the file command.

Quote
2) under the compilation settings, the garbage collection must be set to "supported"

snip

For (2) I already have this setting Ok.

Maybe you need to recompile SFML with this flag ?
SFML / OS X developer

starmessage

  • Newbie
  • *
  • Posts: 27
    • View Profile
    • View the moon phase and write your name in the stars
To create the screensaver on the mac, I used the ready xcode template for screensaver.
This tempate gives an objective-c file which extends the screensaver library of mac osx and receives all the events of a screensaver (startup, shutdown, animateFrame, etc).

This objective-c unit calls my own C++ abstract screensaver class.
That class uses a SFML::renderwindow as a drawing canvas.

(BTW, on windows this worked great).

1) Has anyone build a mac screensaver with SFML?

2) I a bit affraid to recompile SFML in xcode 3.2.6, as my understading of mac is not very good. Also I am not at all an expert in CMAKE and this kind of tools.
Does anyone have a ready xcode 3.2.6 SFML build project that he can share? (I mean a project that compiles SFML to produce its frameworks)

3) Do you think my error message is because I use the ready SFML framework that was compiled with xcode 4?

4) what is your advice to get this forward?

thanks !
« Last Edit: October 24, 2012, 10:08:49 pm by starmessage »

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
1) Not that know of. It's good to know that you are trying something new here!  :D

2&3) There are some confusion here.

The version of Xcode doesn't really matter (because you can install whatever compiler on your machine, e.g. using brew). What could matter is the version of your compiler but I don't think the issue lies here.

When you compile SFML you don't need an Xcode project, either for 3.x or for 4.x. In fact, you don't want any Xcode project (cf. the note in the Cmake tutorial).

If you need to recompile SFML, simply follow the Cmake tutorial. It's pretty straight forward as long as you follow the instructions.


4) Before recompiling anything, check :
Quote
SFML is compiled for both 32 and 64 bits. You can check this with the file command.

Then I've one more question for you : what line of code do you use to create your render window ?
SFML / OS X developer

starmessage

  • Newbie
  • *
  • Posts: 27
    • View Profile
    • View the moon phase and write your name in the stars
Thanks for the info Hiura,

my SFML experience on windows is so nice that I do not want something to stop me from using it as a cross platform tool to move my screensaver to mac osx.

4)
Quote
SFML is compiled for both 32 and 64 bits. You can check this with the file command.
What is the "file command" on mac?
Do you mean to look at the file properties of the frameworks?
I hope the problem is there.

5) SFML command to create render window
This is an incomplete "SFMLcanvas" class.
I had a WINcanvas and tried to to a MACOSXcanvas. The win/mac drawing is so different that I decided to go for a GUI abstraction library (SFML was the winner).

In the SFML canvas you can see 3 constructors.
I use the first in windows to start the screensaver. It does take the hWnd and behave correctly.
I use the second in the mac osx screensaver lib.


class TmioanCanvasSFML: public TmioanCanvasAbstract //, protected TmioanNativeWindowAutoDetect
{
protected:
        NativeWindowHandle windowHandle;
        sf::RenderWindow sfmlWindow;

public: // data

public: // constructor
        TmioanCanvasSFML(const NativeWindowHandle wHandle):  
                        windowHandle(wHandle),
                        sfmlWindow(wHandle)
                {
                TmioanUtils::DebugLogLn("TmioanCanvasWin(wHandle) constructor start");
                };

        TmioanCanvasSFML(const int aTop, const int aLeft, const int aWidth, const int aHeight):
                windowHandle(NULL),
                sfmlWindow(sf::VideoMode(aWidth, aHeight),"")
       
        {
                TmioanUtils::DebugLogLn("TmioanCanvasWin(top,left,bottom,right) constructor start");
                // toDo: na balo window styles
        };
       
        TmioanCanvasSFML():
                        windowHandle(NULL)
                {
                TmioanUtils::DebugLogLn("TmioanCanvasWin() constructor start");
                //sfmlWindowPtr = new sf::RenderWindow(wHandle);
                };

        ~TmioanCanvasSFML()
                {
               
                };

public: // functions
        void clear(void)
                {
                sfmlWindow.clear();
                }

        void repaint(void)
                {
                //TmioanUtils::DebugLogLn("TmioanCanvasWin.repaint()");
                sfmlWindow.display();
                };

        void drawSprite(const sf::Drawable &aSprite)
                {
                sfmlWindow.draw(aSprite);
                };

        /*
        virtual void setRect(LPRECT aRect)
                {
                TmioanCanvasAbstract::setTLBR(aRect->top, aRect->left, aRect->bottom, aRect->right);
                };
        */


        void fillWithColor(const TmioanColor &aColor)
                {
                //RECT tmpRect = toRect();
                //FillRect(hDC, &tmpRect ,(HBRUSH) CreateSolidBrush(aColor));
                };
               

        void blitFrom(const int myX, const int myY,
                                  const TmioanCanvasAbstract *fromCanvas,
                                  const int fromCanvasX, const int fromCanvasY,
                                  const int fromCanvasWidth, const int fromCanvasHeight)
                {
                };


        void textOut(int x, int y, const char *text)
                {
                //TmioanUtils::DebugLogLn("TmioanCanvasWin textOut:",text);
       
                sf::Text Txt;
                Txt.setString(text);
                Txt.setColor(sf::Color(0, 128, 128));
                Txt.move((float)x, (float)y);
                sfmlWindow.draw(Txt);
                };
               
        void setPixel(int x, int y, const TmioanColor &aColor)
                {
               
                };
               
        const TmioanColor getPixel(int x, int y)
                {
                return 0;
                };

        int getWidth(void)
                {
                return sfmlWindow.getSize().x;
                };

        int getHeight(void)
                {
                return sfmlWindow.getSize().y;
                };

};

 


Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
4) No I'm speaking of the file command.

5) Maybe the problem comes from your 2nd ctor. If you use this one, at some point the setUpProcess function is called and that might be the cause of your issues.

Can you use only your 1st instead ?
SFML / OS X developer

starmessage

  • Newbie
  • *
  • Posts: 27
    • View Profile
    • View the moon phase and write your name in the stars
4) to check if SFML is 32 and 64 bits:

I checked the SFML lib that is included in my bundle inside the .screensaver
there are several SFML libs there

These are the result of the various files

/Library/Screen Savers/StarMessage screensaver.saver/Contents/Frameworks/SFML.framework/Versions/2.0.0/SFML
file SFML

SFML: Mach-O universal binary with 2 architectures
SFML (for architecture i386):   Mach-O dynamically linked shared library i386
SFML (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
 

/Library/Screen Savers/StarMessage screensaver.saver/Contents/Frameworks/sfml-graphics.framework/Versions/2.0.0/sfml-graphics

file sfml-graphics

sfml-graphics: Mach-O universal binary with 2 architectures
sfml-graphics (for architecture i386):  Mach-O dynamically linked shared library i386
sfml-graphics (for architecture x86_64):        Mach-O 64-bit dynamically linked shared library x86_64
 

/Library/Screen Savers/StarMessage screensaver.saver/Contents/Frameworks/sfml-window.framework/Versions/2.0.0

file sfml-window

sfml-window: Mach-O universal binary with 2 architectures
sfml-window (for architecture i386):    Mach-O dynamically linked shared library i386
sfml-window (for architecture x86_64):  Mach-O 64-bit dynamically linked shared library x86_64
 

And also the same file, from the computer's frameworks (not what is bundled inside the screensaver).
/Library/Frameworks/sfml-window.framework/Versions/2.0.0

Code: [Select]
file sfml-window

sfml-window: Mach-O universal binary with 2 architectures
sfml-window (for architecture i386): Mach-O dynamically linked shared library i386
sfml-window (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64

I will do the other test you suggested and report on that as well.
thanks

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Apparently your frameworks are perfectly fine so the issue must lies somewhere else. Let me know what you find.
SFML / OS X developer

starmessage

  • Newbie
  • *
  • Posts: 27
    • View Profile
    • View the moon phase and write your name in the stars
I completely remmed out the creation of the canvas, ie the sfml::renderwindow
and the screensaver behaved the same way.

Additionally, the console captures the following error ("GC capability mismatch"), which means that is related the the Garbage collection setting of the precompiled sfml 2.0 framework.


[Session started at 2012-10-27 21:32:42 +0300.]
GNU gdb 6.3.50-20050815 (Apple version gdb-1515) (Sat Jan 15 08:33:48 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".tty /dev/ttys001
Loading program into debugger…
Program loaded.
run
[Switching to process 1839]
Running…
memory_pressure: 0memory_pressure: 02012-10-27 21:32:43.608 ScreenSaverEngine[1839:a0f] Error loading /Library/Screen Savers/StarMessage.saver/Contents/MacOS/StarMessage:  dlopen(/Library/Screen Savers/StarMessage.saver/Contents/MacOS/StarMessage, 265): Library not loaded: @executable_path/../Frameworks/sfml-window.framework/Versions/2.0.0/sfml-window
  Referenced from: /Library/Screen Savers/StarMessage.saver/Contents/MacOS/StarMessage
  Reason: no suitable image found.  Did find:
        /Library/Frameworks/sfml-window.framework/Versions/2.0.0/sfml-window: GC capability mismatch
2012-10-27 21:32:43.613 ScreenSaverEngine[1839:a0f] ScreenSaverModules: can't get principalClass for /Library/Screen Savers/StarMessage.saver

Debugger stopped.
Program exited with status value:0.
 

6)
Does anyone happen to have compiled SFML 2.0 frameworks with the Garbage collection = supported?

7)
Maybe the DYLIBS can be used without a problem if MacOSX cannot check this setting on them?
Based on the following quote, I guess the DYLibs are loaded by macosx differently and probably less strictly.

Quote
Frameworks *are* dylibs, with some additional content (headers, resources, etc.) bundled along with them for convenience.
If you don't need the additional wrapping, then there's nothing to gain by using a framework.


starmessage

  • Newbie
  • *
  • Posts: 27
    • View Profile
    • View the moon phase and write your name in the stars
Some more tests:

8 )
reading at
http://stackoverflow.com/questions/9319518/is-it-possible-to-load-gced-libraries-from-a-program-that-barely-supports-it
I tried to switch off the GC requirement by adding a user defined setting: OBJC_DISABLE_GC=YES
but I did not get away from my problem (GC capability mismatch) .

9)
the file at
http://www.opensource.apple.com/source/objc4/objc4-437/runtime/objc-os.m
under the routine of
gc_enforcer
is probably the one containing the error message string.
This routine may give ideas on how to bypass the error.

I see for example
// Linked images get a free pass
    if (InitialDyldRegistration) return NULL;
 

How can I qualify the SFML dylibs as "linked images"?

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
6) [if 8) doesn't work :]
Not yet, but you'll be a pioneer here !  :D

You can try to add -fobjc-gc to CMAKE_CXX_FLAGS when recompiling SFML.


7) No, it won't change a thing.


8) You're absolutely sure you don't enable GC in your project preferences ? GC is now deprecated in 10.8 and Apple encourage using ARC instead (not available with Xcode 3). So I guess sticking with classic retain/release would be the best for you.

Have a look at page 11 of this document.


9) No idea. But it's probably not the easiest way to solve the issue.
SFML / OS X developer

starmessage

  • Newbie
  • *
  • Posts: 27
    • View Profile
    • View the moon phase and write your name in the stars
8 ) Indeed, my previous test did not actually disable the GC.
I had put OBJC_DISABLE_GC=YES as a user defined setting in xcode, but now I learnt this is an environment variable. Not an xcode setting.

I set it for the debuger (Executables -> myApp -> GetInfo -> Environment variables) and in this case the screensaver started Ok.

All paths seem to lead to the task of recompiling FSML with GC=supported.

10)
A last attempt to escape from that task: The above environment setting works only if run from the xcode debugger (of course).
Is there a way that an .app can define an environment variable before starting its main execution, and in particular before loading the frameworks it needs?
It does not need to change the environment variable globally, but only for its own thread (or execution space, I am not sure how to name it)

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
10) to my knowledge it's not possible.

but you know, compiling SFML is not that difficult.  ;)
SFML / OS X developer

starmessage

  • Newbie
  • *
  • Posts: 27
    • View Profile
    • View the moon phase and write your name in the stars
ok, I compiled the RC.102 with xcode 3.2.
I used cmake to create the "SFML.xcodeproj"
All ok, except one minor error when building the SFML target.


PhaseScriptExecution "CMake PostBuild Rules" /temp/xcode/sfml-build-intermediate/SFML.build/Release/SFML.build/Script-89F8B399000C4AF993DDFCB4.sh
cd /Users/cto/Documents/work/C-Proj/SFML-2.0-latest
/bin/sh -c /temp/xcode/sfml-build-intermediate/SFML.build/Release/SFML.build/Script-89F8B399000C4AF993DDFCB4.sh

cp -r /Users/cto/Documents/work/C-Proj/SFML-2.0-latest/include/SFML/* SFML.framework/Versions/2.0.0/Headers
usage: cp [-R [-H | -L | -P]] [-f | -i | -n] [-apvX] source_file target_file
       cp [-R [-H | -L | -P]] [-f | -i | -n] [-apvX] source_file ... target_directory
make: *** [SFML_buildpart_0] Error 64
Command /bin/sh failed with exit code 2


 
I believe the error is because the target directory for the copy command is a relative directory and probably not found via the current working directory.
I was not able to find where this post-build step is defined inside the xcode project.
 
The other targets (sfml-Audio, sfml-window, etc) were built without errors.

11) Should I post the frameworks here (garbage collection= supported) in case other people may want them as well?

12) By the way, I am under the impression that if garbage collection= supported it would work in both cases of non supported and requiref GC. Therefore, maybe it is a good idea to have the standard compilation of SFML with GC = supported if it does not make any other harm? (I am new to MAC and SFML so you know better)
« Last Edit: November 04, 2012, 08:42:48 am by starmessage »

 

anything