Portable?

I’m a total C++/SDL newbie. I just completed my first program using SDL, and I’m just wondering how I can get it to run on other computers, or perhaps how I could upload it and get it to run within a browser. Right now, the only way I can get my program to run is from within my IDE (which is Mac Xcode). Back when I was writing purely text-based STL programs, I could just go into the Xcode project folder and find the executable file and launch it. But now that I’m using SDL, that doesn’t seem to work anymore. Now when I try to launch the executable, a window opens but then it immediately closes. I’m assuming it’s not finding the library or something.

I realize that the scope of this question is really broad, but perhaps someone could at least give me a link to some sort of tutorial. Thanks.

Likely due to mismatch between SDL Dll and the SDL Lib you are using to
compile. Are you developing on windows 8?On Thu, Nov 21, 2013 at 12:45 PM, Explodey wrote:

I’m a total C++/SDL newbie. I just completed my first program using SDL,
and I’m just wondering how I can get it to run on other computers, or
perhaps how I could upload it and get it to run within a browser. Right
now, the only way I can get my program to run is from within my IDE (which
is Mac Xcode). Back when I was writing purely text-based STL programs, I
could just go into the Xcode project folder and find the executable file
and launch it. But now that I’m using SDL, that doesn’t seem to work
anymore. Now when I try to launch the executable, a window opens but then
it immediately closes. I’m assuming it’s not finding the library or
something.

I realize that the scope of this question is really broad, but perhaps
someone could at least give me a link to some sort of tutorial. Thanks.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Pallav Nawani
IronCode Gaming Private Limited
Website: http://www.ironcode.com
Twitter: http://twitter.com/Ironcode_Gaming
Facebook: http://www.facebook.com/Ironcode.Gaming
Mobile: 9997478768

Could be anything, though if your dynamic loader cannot locate the library,
it will not open a window at all. The fact that something happens shows
that it is find finding the library just fine. I would suspect that you are
loading some kind of data files (images) in your program from a relative
location, which means it will only work when calling the executable from
the correct directory (maybe the base directory of your project? I don’t
know Xcode).
If that is the issue, then you can fix it by referring to any data files
loaded at runtime from absolute locations (starting with /).
As portability goes, you will most likely not be running your applications
from a web browsers, especially not if you are using C++. If you want it to
run on other computers (non-mac) you will either need to compile the code
on those other operating systems or get a cross-compiler toolchain. Source
distributions are generally preferable on Linux, and for Windows… Well,
you need to cross compile it, which is easy on Linux, but I think its a bit
more complicated on OS X, if you have a Linux machine then you can find a
toolchain easily, and if you have a Windows machine you can use mingw32.
You will also need to have a cross-compiled version of SDL to do
cross-compiling of your application.On Thu, Nov 21, 2013 at 4:55 PM, Pallav Nawani wrote:

Likely due to mismatch between SDL Dll and the SDL Lib you are using to
compile. Are you developing on windows 8?

On Thu, Nov 21, 2013 at 12:45 PM, Explodey wrote:

I’m a total C++/SDL newbie. I just completed my first program using
SDL, and I’m just wondering how I can get it to run on other computers, or
perhaps how I could upload it and get it to run within a browser. Right
now, the only way I can get my program to run is from within my IDE (which
is Mac Xcode). Back when I was writing purely text-based STL programs, I
could just go into the Xcode project folder and find the executable file
and launch it. But now that I’m using SDL, that doesn’t seem to work
anymore. Now when I try to launch the executable, a window opens but then
it immediately closes. I’m assuming it’s not finding the library or
something.

I realize that the scope of this question is really broad, but perhaps
someone could at least give me a link to some sort of tutorial. Thanks.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Pallav Nawani
IronCode Gaming Private Limited
Website: http://www.ironcode.com
Twitter: http://twitter.com/Ironcode_Gaming
Facebook: http://www.facebook.com/Ironcode.Gaming
Mobile: 9997478768


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Thank you for your replies. You were right, prushik, I put in the absolute file locations of the images I was using, and then I was able to launch it without using the IDE. I don’t understand why, though, since the images are in the same folder as the executable.

Of course, now that I’m using absolute file locations, I won’t be able to run it on another computer that doesn’t have the same folders as me. I really just want to get it to run on another Mac. I tried it on my dad’s Mac, but no dice. Is there a way to make it self-contained, so the computer doesn’t have to have SDL on it?

Link statically.On Fri, Nov 22, 2013 at 12:46 AM, Explodey wrote:

Thank you for your replies. You were right, prushik, I put in the
absolute file locations of the images I was using, and then I was able to
launch it without using the IDE. I don’t understand why, though, since the
images are in the same folder as the executable.

Of course, now that I’m using absolute file locations, I won’t be able to
run it on another computer that doesn’t have the same folders as me. I
really just want to get it to run on another Mac. I tried it on my dad’s
Mac, but no dice. Is there a way to make it self-contained, so the computer
doesn’t have to have SDL on it?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Explodey wrote:

Thank you for your replies. You were right, prushik, I put in the absolute file locations of the images I was using, and then I was able to launch it without using the IDE. I don’t understand why, though, since the images are in the same folder as the executable.

Of course, now that I’m using absolute file locations, I won’t be able to run it on another computer that doesn’t have the same folders as me. I really just want to get it to run on another Mac. I tried it on my dad’s Mac, but no dice. Is there a way to make it self-contained, so the computer doesn’t have to have SDL on it?

you are on a Mac; that is exactly what application bundles are for.

I believe SDL2’s file abstraction API can help you here, check it out here:
https://wiki.libsdl.org/CategoryFilesystem

You could also load file paths through something such as a configuration
file, and have your program search several “standard” locations for it such
as /etc/ and ~/.local/, this would work well on Unix-like operating
systems, but Windows is the problem (again).

But if you can use SDL2 file abstraction, that is probably the best option
IMHOOn Fri, Nov 22, 2013 at 8:43 AM, brada wrote:

Explodey wrote:

Thank you for your replies. You were right, prushik, I put in the
absolute file locations of the images I was using, and then I was able to
launch it without using the IDE. I don’t understand why, though, since the
images are in the same folder as the executable.

Of course, now that I’m using absolute file locations, I won’t be able to
run it on another computer that doesn’t have the same folders as me. I
really just want to get it to run on another Mac. I tried it on my dad’s
Mac, but no dice. Is there a way to make it self-contained, so the computer
doesn’t have to have SDL on it?

you are on a Mac; that is exactly what application bundles are for.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Message-ID: <1385018126.m2f.40777 at forums.libsdl.org>
Content-Type: text/plain; charset=“iso-8859-1”

I’m a total C++/SDL newbie. I just completed my first program using SDL,
and I’m just wondering how I can get it to run on other computers, or
perhaps how I could upload it and get it to run within a browser.

A bit of info on this. C & C++ are intended to be portable, but in the
"code it correctly, and you can compile it for anything" sense, not in
the Java-ish “compile it, and you can run it anywhere” sense. Now,
there are C compilers that target the JVM, and there are apparently
C++ compilers that target C, so you should be able to pull it off if
you REALLY want to (I don’t think these are free compilers,
necessarily), but it’s not something achievable with the standard
tools. Normally you have to recompile for each platform.

As for running a SDL program in a web browser, Fabrice Bellard (the
guy that created the Tiny C Compiler) has written a minimalist PC
emulator for browsers (http://bellard.org/jslinux/tech.html), but it
doesn’t seem to support any video hardware (though who knows, maybe
someone will change that; I have a HTML+Javascript windowing framework
that I’m planning to eventually use for a SDL2 for Javascript
fallback, should anyone be interested in changing this), and it
wouldn’t have an SDL2 backend anyways (due to “bare metal” not being a
current target). Beyond that, there’s only SDL2 backends that target
browser plugin APIs, and none of those have been implemented yet.> Date: Thu, 21 Nov 2013 07:15:26 +0000

From: “Explodey”
To: sdl at lists.libsdl.org
Subject: [SDL] Portable?

Thanks for your help everyone. It looks like I’ve got a lot to learn! I actually did finally manage to get my program to work on my dad’s computer. I finally realized that even though he did have SDL on his computer, he still needed SDL_image and SDL_ttf.

Also: I’ve been wondering what it would take to get my programs to run on iOS or Android. I’m guessing it wouldn’t be easy. Is one mobile platform easier than the other? Can I even use SDL, or would I have to use a different library/framework?

Message-ID: <1385356265.m2f.40850 at forums.libsdl.org>
Content-Type: text/plain; charset=“iso-8859-1”

Also: I’ve been wondering what it would take to get my programs to run on
iOS or Android. I’m guessing it wouldn’t be easy. Is one mobile platform
easier than the other? Can I even use SDL, or would I have to use a
different library/framework?

I’ve never done it myself, but it can be done. Most of the steps I
don’t know (e.g. what compilers to download) but I can point you to
something that works on desktops and is vitally required on PDAs,
Smartphones, etc.: the Event Filter and Event Watch support found in
the events.h header. On most mobile handheld OSes you’ll have
occasional system messages that you MUST react to, because the OS will
do mean things to you otherwise (e.g. kill the program). More
importantly, you need to do them quickly because the OS will respond
to your inaction within a certain timeframe. The Event Filter and
Event Watch support allows you to see an event when it’s first added
to the queue instead of whenever you get around to taking it off.
They’re especially important on iOS, which will kill you in response
to things like not releasing memory before your program returns from
an iOS call about being short on memory, and simply WILL kill you if
there’s power problems.

I’d suggest taking your first steps into this field by just writing a
program that tells you what messages it receives, and slowly expanding
it until you get all of the relevant info from it, even for system
messages that don’t get translated into standard SDL events. This will
be particularly useful for future porting efforts, since it should be
easy to port, and can give you all sorts of useful bug-hunt
information.

I particularly recommend it for power messages, since those have been
in e.g. MSWindows for quite some time (even before Windows CE, you
still had computers with UPS power backup, and THOSE traditionally
have been capable of telling computers how much power they still
have), and I would assume that they won’t be going away, since
everyone cares about the battery-powered market now.> Date: Mon, 25 Nov 2013 05:11:05 +0000

From: “Explodey”
To: sdl at lists.libsdl.org
Subject: Re: [SDL] Portable?

SDL 2 works on iOS but 1.2 does not. You will need to find some pre built iOS libraries or build SDL yourself. A good first step would be to port to SDL 2.0

The filesystem is different and may require a little setup to get assets loading.

OpenGLES has a stripped down set of commands so you may need to modify some of your rendering code if you make bare OpenGL calls. Similarly your extension loading code may need some ifdefs.

You will want to start with a new clean SDL 2.0 project running in simulator before trying to get your whole code base up and running so you can verify simple project stuff is set up.

It took me a couple weeks to port my game library, don’t be discouraged if it takes some troubleshooting.Sent from my iPhone

On 2013-11-24, at 9:11 PM, “Explodey” wrote:

Also: I’ve been wondering what it would take to get my programs to run on iOS or Android. I’m guessing it wouldn’t be easy. Is one mobile platform easier than the other? Can I even use SDL, or would I have to use a different library/framework?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org