Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Problems with Code:Blocks

This thread is locked; no one can reply to it. rss feed Print
Problems with Code:Blocks
Scooter
Member #16,799
January 2018

Hi Guys:
It's been awhile since I have posted anything on this site, but I have
a couple of questions:

1- I have a program I am trying to run from my Desktop. It requires loading
(6) Jpg files. When I make the link and copy it to my Desktop the screen
just blinks. The reason for this happening is the Jpg files and not
included in the executable file generated with Code:Blocks. In other
words, this is not a standalone file. How do I configure Code:Blocks to
make this file so I can run it on my Desktop and on another computer.
I am running Ubuntu 14.04, Code:blocks 13.12.

2- The other day I took another disc and installed Ubuntu 18.04.1. I installed
Code:Blocks and loaded all my programs and compiled and linked them all.
Everything went well except I noticed there were no executable showing
up in my directory. I assume the reason was Ubuntu 18.04.1 is 64 bit and
my programs are 32 bit. I checked the box to set the flag in Code:Blocks
for 32 bit and another file showed up next to my original file. Have no
idea what was being told to me. I may be getting in over my head on this
one! Anyway, if someone has the time could you give me some help?

Thanks and I hope all is well. Merry Christmas to everyone!!!!

Edgar Reynaldo
Member #8,592
May 2007
avatar

Those jpeg files have to be in the same directory as your program. Your program is not an exe on linux. It doesn't have any extension.

Scooter
Member #16,799
January 2018

Hi Edgar:
They are in the directory. The program compiles and links fine.
It won't run from in the Desktop directory from the link. I have
other programs that are standalone that run fine from the Desktop.
Something must not be configured right in Code:Blocks.

Edgar Reynaldo
Member #8,592
May 2007
avatar

You have to set the working executable directory, for the shortcut. The start in directory.

EDIT
Well, if you were on Windows you would.

Every program has a current working directory. When it is started from a different directory, things aren't where they are expected to be in terms of relative paths.

What you need to do is set the working directory of the program at run time.

   ALLEGRO_PATH* p = al_get_standard_path(ALLEGRO_RESOURCES_PATH);
   al_change_directory(al_path_cstr(p));
   al_destroy_path(p);

Edit
That won't work because you have to strip the file name off the folder path first my computer is broken so I can't help right now. Maybe it will I can't test right now.

princeofspace
Member #11,874
April 2010
avatar

It sounds to me like you'd like to embed the resource files into the executable, which is something most of us don't do -- typically, I send a game to somebody with a resource archive, so two files instead of one.

I switched to Code::Blocks recently, and discovered that if you put the resource files in the same directory as the source files (one level up from bin, where the Debug/Release code is compiled to) the executable finds the resources just fine. In other words, what Edgar was saying about the current working directory was correct: Code::Blocks set the CWD to the project root.

If you've found the Code::Blocks project file, with the extension cbp, you've found the right directory!

Scooter
Member #16,799
January 2018

Thanks prince for your reply. I have never created a project
using Code:Blocks because all the programs I do are single files.
I never do programs containing multiple files.
After reading your comment, I decided maybe that has been my problem.
I tried to create a Console Application and Code:Blocks said it
could not create the directory for the project. I will continue
trying different things to see if it will comply.
Thanks again.

I finally got a project created. Loaded my program to compile and
run. It created an executable file in the project directory. I double
clicked the file but it did not run. Oh well, I will keep at it!!!!

Go to: