Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » linux simple prg file paths error #11

This thread is locked; no one can reply to it. rss feed Print
linux simple prg file paths error #11
305Linux
Member #12,144
July 2010

In windows(Basically saying I am new to Linux) the line was:

Red = load_bitmap("images/red.bmp", NULL);

In Linux with the newest version of Allegro with all files in "/root/hworld/hworld/bin/Released/images", "/root/hworld/hworld/bin/Released/sounds" with images and sounds in their respected folders and the program in the Released folder. I get a

Quote:

Shutting down Allegro due to signal #11

gdb gave these results:

Quote:

Starting program: /root/hworld/hworld/bin/Debug/hworld
[Thread debugging using libthread_db enabled]
[New Thread 0xb7b826c0 (LWP 25615)]
[New Thread 0xb7a69b90 (LWP 25616)]
[New Thread 0xb7268b90 (LWP 25617)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb7b826c0 (LWP 25615)]
0xb7fda99b in draw_sprite () from /usr/lib/liballeg.so.4.2
(gdb) bt
#0 0xb7fda99b in draw_sprite () from /usr/lib/liballeg.so.4.2
#1 0x00000000 in ?? ()

I am also unable to do just a simple barebones audio/bitmap load, which makes me believe that my path location setup is incorrect.

Thanks a lot for any and all help that is given. This has been bothering me and google has failed me.

Arthur Kalliokoski
Second in Command
February 2005
avatar

305Linux said:

"/root/hworld/hworld/bin/Released/images"

Wouldn't it have to be Released/images/red.bmp?

And it's very unwise to run stuff as root.

[EDIT]

Oh, wait, the binary is in Released? I don't do that crappy Release/Debug MS setup thing.

They all watch too much MSNBC... they get ideas.

305Linux
Member #12,144
July 2010

You are correct the appropriate files are located in the designated folders. red.bmp would be located "/root/hworld/hworld/bin/Released/images" or the Debug folder instead of the Released folder for the debugging.

Billybob
Member #3,136
January 2003

Are you running the EXE from within the Released folder?
Did you check the capitalization on the path? Linux is case-sensitive whereas windows is not.

305Linux
Member #12,144
July 2010

All spellings are correct, I copied the two folders(images and sounds) into the Released folder. I even copied all the files directly to the Released folder and just had "red.bmp" as the file name. Neither worked.

BITMAP *Red;
...
Red = load_bitmap("red.bmp", NULL);
...
draw_sprite(activepage, Red, GameBoard[Boardloc].xloc, GameBoard[Boardloc].yloc);

If I comment out the draw_sprite line everything works, as in doesn't crash, but again no changes and in windows there are no problems. Puzzling.

Arthur Kalliokoski
Second in Command
February 2005
avatar

Can you load this red.bmp file with allegro/examples/ex_bitmap?

They all watch too much MSNBC... they get ideas.

Thomas Fjellstrom
Member #476
June 2000
avatar

Check if Red and activepage are valid, see which one has gone bad. Also try printing out the return value of getcwd.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

305Linux
Member #12,144
July 2010

Even the example won't load any of the bmp files which are the same files used in windows.

activepage works, I use it for page flipping which works fine. I am almost positive that the directory is incorrect.

If my bmp files are in the same directory and the EXE file in the linuxOS wouldn't:
Red = load_bitmap("red.bmp", NULL);
work? or do I need to do something differently? The same things happens when trying to load a datafile or a sample. It acts as if the files do not exist.

Using Code::Blocks on BackTrack 4 on a USB drive with persistence on, not sure if that matters but figured I would throw it out there. I tried moving the files over to the main hard drive but that didn't help either.

Arthur Kalliokoski
Second in Command
February 2005
avatar

Are the first two bytes of this file 'BM'? IIRC ms-paint will gladly save jpg's as bmp, and you might have had the jpeg library installed in allegro or something.

They all watch too much MSNBC... they get ideas.

305Linux
Member #12,144
July 2010

Fresh Windows 7 install and just downloaded Dev-Cpp and downloaded Allegro 4.2.2 from the package manager. Source files and bmp/wav are the same when used for both linux and windows. Though the example won't load bmps either(sample bmps from a cd taken from a book on allegro).

Arthur Kalliokoski
Second in Command
February 2005
avatar

Can you load it into the Gimp or some image viewer? Maybe the cd is scratched or something.

They all watch too much MSNBC... they get ideas.

305Linux
Member #12,144
July 2010

copied the files over, didn't load off the CD. Images load just fine in a viewer.

Thomas Fjellstrom
Member #476
June 2000
avatar

305Linux said:

Images load just fine in a viewer.

Maybe, but allegro is quite a bit more picky about what its loading. You have to make absolute sure they are plain, normal old bitmap files, with no compression.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

305Linux
Member #12,144
July 2010

100% sure. Allegro might not like it but allegro is the same from windows to linux on if it will be picky on loading a file. Why would the file load in windows/WINE and not in linux.

Matthew Leverton
Supreme Loser
January 1999
avatar

The filename will be case sensitive.

305Linux
Member #12,144
July 2010

double checked that, case sensitivity has been checked.

Evert
Member #794
November 2000
avatar

305Linux said:

If my bmp files are in the same directory and the EXE file in the linuxOS wouldn't:
Red = load_bitmap("red.bmp", NULL);
work?

No. Only if the file is in the current directory.

fissionchips
Member #8,891
August 2007

Hi,
There could be several issues here,
I'd check that the bitmap is actually loaded, as in:

BITMAP *Red = NULL; // give it a default value so it can be checked.

Red = load_bitmap("images/red.bmp", NULL);

if (Red == NULL) // failed to load!!
call_error_function(ERROR_CODE); // whatever it's called

// rest of drawing code etc.

If BITMAP is declared within a function it can have any value that happens to occupy that memory spot unless you specify one. This will make it easier to test the loading functions return value.

Just a suggestion...

305Linux
Member #12,144
July 2010

The bitmaps are not being loaded, nor the datafiles, sounds or any files needed at run time.

Thomas Fjellstrom
Member #476
June 2000
avatar

Then the files aren't where your program is expecting them to be. As I suggested earlier, try calling getcwd, and printing out the returned string to see where exactly the program is running from.

To be honest though its best to only use ABSOLUTE paths, and build them at run time.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Billybob
Member #3,136
January 2003

Also try chmod +r red.bmp in case the permissions on the file are wrong.

305Linux
Member #12,144
July 2010

2 errors. The files were not in the location they should have been in. Apparently the compiling location is different than the run time location for the path. Fixed that problem.

2nd problem was the inability to create_video_bitmap for page flipping. I was wrong about the flipping working before I guess as activepage was part of the crash problem. I need to get linux drivers for this AOA150 Acer Netbook. Till then guess I will have to program in windows for now.

Being new to linux taught me a bit about path locations, and user usage.

Evert
Member #794
November 2000
avatar

305Linux said:

2nd problem was the inability to create_video_bitmap for page flipping.

That always fails in X11, unless you set a virtual screen size that is large enough to contain the additional video bitmaps. Your drivers have nothing to do with this.

By the way, "page flipping" doesn't really work as such on X11; it really just gives you a background X11 surface to draw on that is displayed later on. In Allegro-speak, what it's doing internally is double buffering rather than page flipping.

In general, you should write your code so it still works if page flipping is not available.

Go to: