Building a dylib of my engine and need some help

Nibbie
Posts: 3
Joined: 2010.04
Post: #1
I am trying to make a generic game engine for all my little projects.

I was using GLUT and got it working quite right but then I went to SDL and this is where I am having problems.

This is the error that I am getting when I run ./game from my build directory.

Code:
2010-04-25 17:24:59.426 game[39778:10b] *** _NSAutoreleaseNoPool(): Object 0x119df0 of class NSCFNumber autoreleased with no pool in place - just leaking
Stack: (0x94af565c 0x94a22810 0x9418f6c4 0x9533aab4 0x95339010 0x9534b0c8 0x941e51dc 0x941e40d8 0x941e26bc 0x941e20b4 0x941dfdb8 0x30033508 0x30027dec 0x3002c848 0x3002c98c 0x48c0)
2010-04-25 17:24:59.431 game[39778:10b] *** _NSAutoreleaseNoPool(): Object 0x11a270 of class NSCFNumber autoreleased with no pool in place - just leaking
Stack: (0x94af565c 0x94a22810 0x9418f6dc 0x9533aab4 0x95339010 0x9534b0c8 0x941e51dc 0x941e40d8 0x941e26bc 0x941e20b4 0x941dfdb8 0x30033508 0x30027dec 0x3002c848 0x3002c98c 0x48c0)
2010-04-25 17:24:59.434 game[39778:10b] *** _NSAutoreleaseNoPool(): Object 0x11a890 of class NSCFNumber autoreleased with no pool in place - just leaking
Stack: (0x94af565c 0x94a22810 0x9418f6fc 0x9533aab4 0x95339010 0x9534b0c8 0x941e51dc 0x941e40d8 0x941e26bc 0x941e20b4 0x941dfdb8 0x30033508 0x30027dec 0x3002c848 0x3002c98c 0x48c0)

This is how I built my dylib game engine library.


Code:
MACHINE=$(shell uname -s)

ifeq ($(MACHINE), Darwin)
  CPPFLAGS+=-I/Library/Frameworks/SDL.framework/Headers -I/System/Library/Frameworks/OpenGL.framework/Headers
  LDFLAGS+=-framework SDL -framework OpenGL
endif

EXE=platform/lib/Engine.dylib

SOURCES=engine_src/Engine.cpp \
        engine_src/Log.cpp
OBJECTS=$(SOURCES:.cpp=.o)

$(EXE): $(OBJECTS)
  $(LINK.cc) -dynamiclib -install_name ./lib/Engine.dylib -current_version 1.0 $^ -o $@

This is where I think the problem lies in the SDL section with this: @executable_path/../

Code:
% otool -L lib/Engine.dylib                    
lib/Engine.dylib:
    ./lib/Engine.dylib (compatibility version 0.0.0, current version 1.0.0)
    @executable_path/../Frameworks/SDL.framework/Versions/A/SDL (compatibility version 1.0.0, current version 1.0.0)
    /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
    /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.4.0)
    /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.1.3)

If you guys need anything else let me know.
Quote this message in a reply
⌘-R in Chief
Posts: 1,247
Joined: 2002.05
Post: #2
The warnings you're getting are really quite trivial. All it says is that no NSAutoreleasePool was setup, but 3 NSCFNumber instances were set to be autoreleased, which means they'll just leak. In other words, you're just leaking a handful of bytes. No big deal.

Now the thing is to figure out which numbers those are and who didn't create the autorelease pool. Since you said you switched to SDL, my first guess is that you or SDL is creating those number objects before its pool is setup, or somehow you're doing something which makes a secondary thread with no pool and that's where it's leaking.

http://www.idevgames.com/forum/showthread.php?t=7710
Quote this message in a reply
Nibbie
Posts: 3
Joined: 2010.04
Post: #3
There was nothing huge that I was doing in SDL.

I had an void Init function:
Code:
const SDL_VideoInfo *vInfo;

    if ( SDL_Init( SDL_INIT_VIDEO ) != 0 )
    {
        LOG( "Unable to init SDL: %s\n", SDL_GetError() );
        return -1;
    }

    vInfo = SDL_GetVideoInfo();
    if(!vInfo)
    {
        LOG("Unable to get Video Info: %s\n", SDL_GetError() );
        return -1;
    }

    SDL_WM_SetCaption("GameEngine4", NULL);

This was all that was in there and and it was failing.
Quote this message in a reply
Nibbie
Posts: 3
Joined: 2010.04
Post: #4
I think I found out the problem. Since I am creating a dylib of my engine that is linked to SDL I have another c++ file that links against my dylib file, this is my game logic. I do not include any "SDL.h" or "SDL_opengl.h" in my game logic. My game logic only includes "Engine.h" once which gives some simple prototypes to my game engine. Pretty much just Init()

But I think the issue is that I don't build use the SDLMain.m file (which maybe I should be doing) So I don't include any of the SDL stuff. So my main function in my game logic code doesn't get replaced with the macro SDL_main()
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Building a game building tool leRiCl 9 4,884 Apr 12, 2008 12:16 AM
Last Post: leRiCl
  Building and installing PortAudio Nevada 4 3,394 Feb 18, 2007 04:38 PM
Last Post: Nevada