I put a game into an executable with Ocra. The file seems to contain all files (from its filesize) but when I start it the cmd window says me that the path C:\...\src\file cannot be found. It doesn't seem to have problems with libraries, just with images and maybe other additional files (like music)
Ocra doesn't embed the ressource the program uses, only the libraries needs to execute+the ruby interpreter. you still need to provide the images/sound/whatever file with you .exe
@ Trebor777: But in the documentation it says: "Additional files and resources
You can add additional files to the OCRA executable (for example images) by appending them to the command line. They should be placed in the source directory with your main script (or a subdirectory).
I've mailed the Ocra-author about if the packed exe could change into the tmp directory it creates before executing the ruby-script.. I think this might solve some common problems.
My solution has always been using full paths in my games... File.join(ROOT, "gfx", "player.png") bla bla
You can also try changing the current directory, I think it is Dir.cd(File.dirname(__FILE__)). With some luck it happens early enough to get Windows to find FMOD.dll in the right place.
> Hi again Lars, > > A question that's popped up on the gosu-forums and #gosu: > > Someone packs an EXE in the games rootdir and it works. Then he movse > the EXE to c:\ for example and it stops working. I can only read this as > a path-problem (He hasn't used full paths in your script). > > Now, is there any reason why Ocra doesn't change into the tmp directory > it creates before executing? >
If you mean, chdir to the temp directory then yes, there is a good reason. Suppose someone creates a command line utility with ocra; they wouldn't want ocra to "magically" change the current working directory of the Ruby script, as you would expect it to be able to read/write files in the current directory, where the command is execute. Therefore, ocra leaves your current working directory alone. The current working directory can be set to all kinds of places, depending on how you launch your program (command line, explorer, file association, as a service, etc etc.), so its better to not assume anything.
You can get the temp directory this way: File.dirname(File.dirname($0))
I understand his point, I guess just don't think in terms of command line utilities on Windows. Anyway, all the Gosu examples and games DO NOT do the chdir properly—so I'm still thinking if I should bake it in or just include it at the top of every Gosu game. Oh, I was so looking forward to being able to start out with just require 'gosu' as the only required boilerplate in Ruby 1.9. :(
Yes. Would you want to run the game from a different directory based on a different set of resources? Actually my use case is more often that I am lazy and just want to run some_dir/Main.rb and wish it would do the chdir by itself :)