Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » How to generate a standalone .exe ?

This thread is locked; no one can reply to it. rss feed Print
How to generate a standalone .exe ?
jw716264
Member #17,098
June 2019

I want the game to be playable on computers without allegro,mingw,codeblocks etc.
OS is : window7
IDE is : codeblocks
Allegro version is : allegro-mingw-gcc6.2.0-x86-static-5.2.2
The game project contains only one file which is a .c file.

I have tried the method" gcc -o game main.c `allegro-config --libs --static` "but my cmd can't recognize either allegro-config or --libs or --static .

MikiZX
Member #17,092
June 2019

I've never used the command line but possibly you are using an obsolete command line switch? See on https://wiki.allegro.cc/index.php?title=Compiling_Allegro_Programs

Allegro 4.4.x starts using 'pkg-config' instead of 'allegro-config' - possibly this is an issue?

again, not sure this can help at all.

Audric
Member #907
January 2001

The syntax with the backticks requires a command interpreter like bash (or sh).
Later you may want to install a complete toolset like MSYS, but for what you want now, yo u can simply run allegro-config --libs --static in cmd.exe, it will output the command-line arguments that depends on your installation. You can then stop using `allegro-config` and replace it with the result of the command. Don't keep the ` `

jw716264
Member #17,098
June 2019

what do you mean" run allegro-config --libs --static "?

Audric
Member #907
January 2001

I mean open a console, and type the command (what is between the ` `)

bamccaig
Member #7,536
July 2006
avatar

I'm pretty sure allegro-config was only used by 4.2 and less. You should be using pkg-config for Allegro 5. It is available for MSYS2. Ultimately, allegro-config and pkg-config are used to output compiler options that link in Allegro and its dependencies. This is predominantly used by Makefiles and other such build systems. If you're going to use your IDE to do the building/linking then you probably won't need this.

Where's Edgar when you need him? :P He knows how to setup Code::Blocks for Allegro development in Windows. I think he wrote this guide: https://wiki.allegro.cc/index.php?title=Windows,_Code::Blocks_and_Allegro_5. That should get you started, but you might need him to come help you get it working ultimately.

It's important that your MinGW version that you're using in Code::Blocks matches the version Allegro was compiled with. If they don't match you could either have linking errors or runtime errors. It's not clear to me which version of MinGW was used to build that distribution though. Where did you download Allegro from?

Edgar Reynaldo
Member #8,592
May 2007
avatar

haha don't worry Edgar is here.

jw716264 said:

Posted on 06-27-2019 02:32

I want the game to be playable on computers without allegro,mingw,codeblocks etc.
OS is : window7
IDE is : codeblocks
Allegro version is : allegro-mingw-gcc6.2.0-x86-static-5.2.2
The game project contains only one file which is a .c file.

I have tried the method" gcc -o game main.c `allegro-config --libs --static` "but my cmd can't recognize either allegro-config or --libs or --static .

Since you're using Allegro 5.2.2 (Allegro 5.2.5.1 is the latest version now btw), that means you no longer use allegro-config etc....

If you're using Linux or MSYS(2) you use pkg-config.

First, use grep and pkg-config to list the installed allegro packages you have :

pkg-config --list-all | grep allegro

Then use the names given by pkg-config as its argument list. (Use the names provided, not the $NAME I use)

Usage :

g++ -Wall -Wextra -Wshadow -g -o Proggie.exe `pkg-config --includes --static $ALLEGRO_LIBRARY_NAME $ALLEGRO_OPTIONAL_ADDON_LIBRARY_NAMES
    Main.c `pkg-config --libs --static $SAME_NAMES_AS_ABOVE` -static-libstdc++ -static-libgcc

Then to test it open another command terminal, set the path to empty, and then execute your program. If everything works, you did it right. Otherwise you forgot resources or the working directory was wrong, etc...

cmd.exe
set path=""
Proggie.exe
exit

MikiZX said:

Posted on 06-27-2019 04:24

I've never used the command line but possibly you are using an obsolete command line switch? See on https://wiki.allegro.cc/index.php?title=Compiling_Allegro_Programs

Allegro 4.4.x starts using 'pkg-config' instead of 'allegro-config' - possibly this is an issue?

again, not sure this can help at all.

Yes, Allegro 4.2 and previous used allegro-config. Allegro 4.4+ uses pkg-config, as well as Allegro 5 and up.

Audric said:

Posted on 06-27-2019 05:02, revised 06-27-2019 05:03

The syntax with the backticks requires a command interpreter like bash (or sh).
Later you may want to install a complete toolset like MSYS, but for what you want now, yo u can simply run allegro-config --libs --static in cmd.exe, it will output the command-line arguments that depends on your installation. You can then stop using allegro-config and replace it with the result of the command. Don't keep the ` `

Yes, but pkg-config.

jw716264 said:

Posted on 06-27-2019 05:11

what do you mean" run allegro-config --libs --static "?

Type it at a command prompt (terminal / console / etc...)

bamccaig said:

Posted on 06-27-2019 10:07
...If you're going to use your IDE to do the building/linking then you probably won't need this.

...I think he wrote this guide: https://wiki.allegro.cc/index.php?title=Windows,_Code::Blocks_and_Allegro_5.

That should get you started, but you might need him to come help you get it working ultimately.

It's important that your MinGW version that you're using in Code::Blocks matches the version Allegro was compiled with. If they don't match you could either have linking errors or runtime errors. It's not clear to me which version of MinGW was used to build that distribution though. Where did you download Allegro from?

jw716264 said:

allegro-mingw-gcc6.2.0-x86-static-5.2.2

He's using MinGW GCC 6.2.0 with allegro 5.2.2 in 32 bit mode.

I suggest upgrading to the latest version.

There are several ways to do that.

MSYS2 package manager

See SiegeLord's guide to MSYS2 here : https://wiki.allegro.cc/index.php?title=Building_with_msys2

MinGW-W64 binaries I provide

I provide up to date binaries for MinGW-W64 packages for Allegro 5.2 and 4.4 on my bitbucket download page here :

https://bitbucket.org/bugsquasher/unofficial-allegro-5-binaries/src/master/

Compile Allegro from GIT yourself

See my Windows and MinGW-W64 compile guide in my sig for info on building allegro.

Phew. That only took an hour. ;D

Doctor Cop
Member #16,833
April 2018
avatar

You don't even need MSYS or MSYS2. I use Git bash or Babun when I need Linux capabilities and GNU suit is always at your disposal.

Edgar Reynaldo
Member #8,592
May 2007
avatar

No, you don't need MSYS2, but it's package manager can be nice to have.

GullRaDriel
Member #3,861
September 2003
avatar

Particularly to keep things up to date.

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

bamccaig
Member #7,536
July 2006
avatar

You don't even need MSYS or MSYS2. I use Git bash or Babun when I need Linux capabilities and GNU suit is always at your disposal.

Git for Windows is based on MSYS. You are getting a minimal MSYS system bundled with Git. That's why Git Bash exists at all in Windows (on other platforms you'd just use bash, and run git inside of it; bash is a completely separate project). :) Git for Windows has some core Unix utilities included, but for something like building Allegro you need much more.

Go to: