Allegro.cc - Online Community

Allegro.cc Forums » Installation, Setup & Configuration » Help getting Allegro 5 and Dev-C++ to work together on 64 bit Windows 7 machine

This thread is locked; no one can reply to it. rss feed Print
 1   2   3 
Help getting Allegro 5 and Dev-C++ to work together on 64 bit Windows 7 machine
Edgar Reynaldo
Major Reynaldo
May 2007
avatar

I will show you how to do it from scratch.

Uninstall CodeBlocks 20.03 and reinstall it. This time don't install the MinGW compiler. You will be using your own installation of MinGW.

Second, your allegro binaries need to match the compiler they were created with in order to work. You're using SiegeLord's GCC 9.2 binaries with a different compiler. That won't work.

This time, make sure they match. For instance, these are my builds, which already match :

The compiler I'm using is MinGW-W64 i686 (32 bit) GCC 8.1, which you can get here :

https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/8.1.0/threads-posix/dwarf/i686-8.1.0-release-posix-dwarf-rt_v6-rev0.7z

The allegro binaries I built you can find here :

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

Specifically, these :

https://bitbucket.org/bugsquasher/unofficial-allegro-5-binaries/downloads/Allegro525_GCC81_MinGW_W64_i686_posix_dwarf.7z

Extract the compiler and move it to c:\mingw . Now ONCE go into your global compiler settings then make sure they look like this :
{"name":"612629","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/1\/a\/1a8d089f602f652deab726a95abede71.png","w":923,"h":821,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/1\/a\/1a8d089f602f652deab726a95abede71"}612629

Extract the binaries and move it to c:\libs . You should now have c:\libs\include and c:\libs\lib and c:\libs\bin .

Now, don't touch your global compiler settings again.

Next, load the project I gave you earlier and change the project search directories to match your c:\libs\ include and lib folders.

Then double check your linker settings for each project. They should be preset to the necessary libraries.

Add a source file to your project. Go to File->New->File and add it under the current project. Add it to all configs. Put in a basic main and build the project. All should go smoothly. If it does NOT, post screenshots and logs of your errors.

;)

BletchleyPark
Member #18,406
September 2020

{"name":"612634","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/6\/8661ad6181cae85644d44028915d11f0.png","w":600,"h":586,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/6\/8661ad6181cae85644d44028915d11f0"}612634
{"name":"612635","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/4\/6\/46beb9693f6a036f23941dcbfce6a81c.png","w":611,"h":221,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/4\/6\/46beb9693f6a036f23941dcbfce6a81c"}612635
{"name":"612636","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/9\/b\/9b4a906edfb23822442a1131dd7bfca7.png","w":608,"h":211,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/9\/b\/9b4a906edfb23822442a1131dd7bfca7"}612636
{"name":"612637","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/0\/003480a0ef6f9bc988e6d21e161081d3.png","w":592,"h":598,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/0\/003480a0ef6f9bc988e6d21e161081d3"}612637

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Bob Keane
Member #7,342
June 2006

...My bad. I should have been more specific in my earlier post. Do not use the auto-detect button in the toolchains executables tab, this could be causing confusion. In your C:\MINGW folder, you should have a folder labelled "i686-8.1.0-release-posix-dwarf-rt_v6-rev0". If you have it, there will be a "mingw32" folder under the i686-8.1.0-release-posix-dwarf-rt_v6-rev0 folder. Under the "mingw32" there should be a "bin" folder. Start Code::Blocks, go into settings, bring up the toolchains executable tab, use the "..." button to navigate to the "C:\i686-8.1.0-release-posix-dwarf-rt_v6-rev0\mingw32" folder, opening each folder as you find them until you see the "bin" folder. Highlight the bin folder, and click the select folder button at the bottom. That should select the correct folder for the compiler. Now, the c compiler and c++ compiler lines should default to the proper bin folder. Click the "..." button next to the c compiler line and find the gcc.exe file, click on it once and press the open file button at the bottom. Do the exact same for the c++ compiler line, selecting the g++.exe file. Then press okay and you should be okay.

If you do not have the i686-8.1.0-release-posix-dwarf-rt_v6-rev0 you have the wrong compiler for the Allegro binaries Edgar provided and I linked to earlier. In that case, delete the C:\MINGW folder, delete any and all downloaded compilers from your download folder and download the compiler I linked earlier. Create a new C:\MINGW folder and unzip the downloaded compiler to that folder and look for the i686-8.1.0-release-posix-dwarf-rt_v6-rev0. Then go into the toolchains executables tab in Code::Blocks and navigate to the C:\i686-8.1.0-release-posix-dwarf-rt_v6-rev0\mingw32 folder, highlight the "bin" folder and press the select folder button. Then select the c and c++ compilers as previously instructed and you should be good.Do not use the Auto-detect button in the toolchains executable tab, that ma be causing some confusion.

Did I miss anything Edgar?

By reading this sig, I, the reader, agree to render my soul to Bob Keane. I, the reader, understand this is a legally binding contract and freely render my soul.
"Love thy neighbor as much as you love yourself means be nice to the people next door. Everyone else can go to hell. Missy Cooper.
The advantage to learning something on your own is that there is no one there to tell you something can't be done.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

All you need to do is extract the 7z file and rename the folder to mingw and move it to c:.

Then follow the picture from above :

{"name":"1a8d089f602f652deab726a95abede71.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/1\/a\/1a8d089f602f652deab726a95abede71.png","w":923,"h":821,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/1\/a\/1a8d089f602f652deab726a95abede71"}1a8d089f602f652deab726a95abede71.png

BletchleyPark
Member #18,406
September 2020

{"name":"612643","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/b\/5\/b55e45cec5a7cdc1b17954d87ef32af0.png","w":1153,"h":179,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/b\/5\/b55e45cec5a7cdc1b17954d87ef32af0"}612643
{"name":"612641","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/3\/f\/3f675d3f21df955931b3dbe067587488.png","w":552,"h":207,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/3\/f\/3f675d3f21df955931b3dbe067587488"}612641
{"name":"612642","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/f\/e\/feef39e414256bf55c4a959cc5518256.png","w":641,"h":533,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/f\/e\/feef39e414256bf55c4a959cc5518256"}612642
{"name":"612644","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/3\/83019db37223e2f87fbd55a71f285662.png","w":743,"h":1016,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/3\/83019db37223e2f87fbd55a71f285662"}612644
{"name":"612645","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/b\/5\/b55e45cec5a7cdc1b17954d87ef32af0.png","w":1153,"h":179,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/b\/5\/b55e45cec5a7cdc1b17954d87ef32af0"}612645

I hadn't seen Mr. Reynaldo's post before I posted my last reply, so my last reply did not encompass the assistance he provided. My apologies for the confusion.

I had looked through a guide on this site regarding compiler compatibility and assumed, foolishly, that because the MINGW version numbers on my Allegro download matched the MINGW numbers in my Dev and CB versions, that they would work together. I was mistaken.

I used the project Mr. Reynaldo provided, made the changes indicated as best as I understood them, noted the linker settings for the various debug release settings, but left those settings alone. The code I added was a an Allegro version of Hello World that I found online.

I have gathered that the Allegro files can reside anywhere on the machine, and the Search Directory tabs allow you to tell CB where those folders are so the compiler and linker can find the appropriate files. Assuming that this is true, and CB doesn't have a problem following the path, its inability to locate the file it claims is missing is perplexing. The screenshot shows it clearly in the folder on the path I gave it.

I appreciate the patience you have both shown in assisting me.

Bob Keane
Member #7,342
June 2006

Try copying the allegro_monolith-5.3.dll from your Documents folder to the folder with the executable in it. If that works, try copying the list I provided earlier for static linking.

By reading this sig, I, the reader, agree to render my soul to Bob Keane. I, the reader, understand this is a legally binding contract and freely render my soul.
"Love thy neighbor as much as you love yourself means be nice to the people next door. Everyone else can go to hell. Missy Cooper.
The advantage to learning something on your own is that there is no one there to tell you something can't be done.

DanielH
Member #934
January 2001
avatar

You got it. It's compiling and linking properly.

The problem when you run it is that you need to tell Windows where the DLL is. Either copy the DLL to your working folder or set the environment to include the folder where the DLL is located.

Not sure id Dev C++ has that option.

For newbies, the hardest part is getting the environment set up properly.

Bob Keane
Member #7,342
June 2006

I typically go with static linking (my list) because the users may not have the Allegro library on their computers.

By reading this sig, I, the reader, agree to render my soul to Bob Keane. I, the reader, understand this is a legally binding contract and freely render my soul.
"Love thy neighbor as much as you love yourself means be nice to the people next door. Everyone else can go to hell. Missy Cooper.
The advantage to learning something on your own is that there is no one there to tell you something can't be done.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

No, that's still not quite right.

Everything is correct except the link library. Link to the .a file, not the .dll .

The syntax is '-lNAME' where the link library is libNAME.a .

So you're linking to the 5.2 dll, that's not it. You want to link to liballegro_monolith-debug.a by using -lallegro_monolith-debug

Technically you can link to a .dll, but the dll is not in the lib folder so that wouldn't work anyway.

BletchleyPark
Member #18,406
September 2020

I'm not clear on what is meant by the folder with the executable in it. I tried pasting the dll into the folder with the source code, pasting into the folder where the executable will end up, and using the -L flag under Linker Settings --> Other Linker Options to point the way to the directory. The dll couldn't be found.

EDIT: I have now seen Mr. Reynaldo's reply. It seems I changed one of his settings after all. Though the smugness on the cat's face for the past 12 hours suggests who is actually guilty. ;D

The screenshot shows the state of things now.

{"name":"612646","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/4\/046d87d46019f88b2618b29b4cb10bdf.png","w":623,"h":292,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/4\/046d87d46019f88b2618b29b4cb10bdf"}612646

Bob Keane
Member #7,342
June 2006

In your project folder, there should be a bin subfolder. Under the bin sub folder you will see a release and debug folder. The executable will be in one of those folders, most likely the debug folder. Try copying the list I provided for static linking to your other linker options page under linker settings for now. That should tell us if the compiler is set properly.

By reading this sig, I, the reader, agree to render my soul to Bob Keane. I, the reader, understand this is a legally binding contract and freely render my soul.
"Love thy neighbor as much as you love yourself means be nice to the people next door. Everyone else can go to hell. Missy Cooper.
The advantage to learning something on your own is that there is no one there to tell you something can't be done.

BletchleyPark
Member #18,406
September 2020

{"name":"612647","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/f\/ef06e7e103437ec0c92cbbbed6e48e73.png","w":484,"h":294,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/f\/ef06e7e103437ec0c92cbbbed6e48e73"}612647

I tried pasting a copy of the dll into the bin folder you describe. The same inability to find the dll occurred. The result of linking the corresponding .a file as Mr. Reynaldo said is shown in the screenshot.

Bob Keane
Member #7,342
June 2006

I'm at work now, but could you post a screen shot of your linker settings please? I'll take another look later. Also, take screen shots of your Allegro\Allegro5 lib directories. And a screenshot of the error.

By reading this sig, I, the reader, agree to render my soul to Bob Keane. I, the reader, understand this is a legally binding contract and freely render my soul.
"Love thy neighbor as much as you love yourself means be nice to the people next door. Everyone else can go to hell. Missy Cooper.
The advantage to learning something on your own is that there is no one there to tell you something can't be done.

DanielH
Member #934
January 2001
avatar

find out where the exe file was made. Put the DLL file in that same folder. When the program is executed, that is the first place Windows looks for the DLL.

Also, if you distribute this program just include the dll.

Option 2 is less favorable. Add the Allegro path to the global path that windows uses to look for dlls.

Path = (..Do not change what was there but add to it..);MyAllegroDirectoryThatHasTheDLL

I googled this, don't know what version Windows you are using.

How to change environment variables on Windows 10

Open the Start Search, type in “env”, and choose “Edit the system environment variables”:
Click the “Environment Variables…” button.
Set the environment variables as needed. The New button adds an additional variable. ...
Dismiss all of the dialogs by choosing “OK”. Your changes are saved!

Bob Keane
Member #7,342
June 2006

He is on Windows 7 per the title.

http://geekswithblogs.net/renso/archive/2009/10/21/how-to-set-the-windows-path-in-windows-7.aspx

One thing I am worried about is Edgar's toolchain executables looks a little different than mine. Bletchley may be using a set up that is part mine and part Edgar's.

By reading this sig, I, the reader, agree to render my soul to Bob Keane. I, the reader, understand this is a legally binding contract and freely render my soul.
"Love thy neighbor as much as you love yourself means be nice to the people next door. Everyone else can go to hell. Missy Cooper.
The advantage to learning something on your own is that there is no one there to tell you something can't be done.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

I'm guessing it won't run because of the runtime working directory. You need to change that so it is in the same folder as your program and the dlls.

Go to Menu->Project->Properties, go to the Build Targets tab, and change the runtime working directory to the same one where the program is built.

Don't change your system $PATH through the environment variables.

Bob Keane
Member #7,342
June 2006

Follow Edgar's advice first. IF that does not work, first delete my linker settings and enter the allegro-monolith library to compile with dynamic linking. Then recompile. It will crash when you select build and run under Code::Blocks, don't worry. Then add the folder with the executable and dll to the system $PATH variable. The folder has the executable and dll in it so it should run in DOS outside Code::Blocks. Then go to the command line, console screen or what we true geeks know is the dos prompt and type in the name of the executable. That should give us more information. I think I remember a thread from long ago in which an executable would run in dos but not Code::Blocks with a simple answer. Or you can double click the executable without changing the path from within the folder to see if it works.

By reading this sig, I, the reader, agree to render my soul to Bob Keane. I, the reader, understand this is a legally binding contract and freely render my soul.
"Love thy neighbor as much as you love yourself means be nice to the people next door. Everyone else can go to hell. Missy Cooper.
The advantage to learning something on your own is that there is no one there to tell you something can't be done.

BletchleyPark
Member #18,406
September 2020

{"name":"612648","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/5\/1\/5138e85838ffab162391e4f464154f13.png","w":680,"h":171,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/5\/1\/5138e85838ffab162391e4f464154f13"}612648
{"name":"612649","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/b\/9\/b987390392f2a6df1c25307a357b81e9.png","w":685,"h":584,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/b\/9\/b987390392f2a6df1c25307a357b81e9"}612649
{"name":"612650","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/a\/ea1f2a13e052170d51c87aa28bd412b7.png","w":390,"h":718,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/a\/ea1f2a13e052170d51c87aa28bd412b7"}612650
{"name":"612651","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/f\/8fc87be6c343752c4f5356d827d52904.png","w":600,"h":900,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/f\/8fc87be6c343752c4f5356d827d52904"}612651
{"name":"612652","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/6\/a\/6ab37a5a5ef0efd94d3f3ea608525dc7.png","w":600,"h":800,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/6\/a\/6ab37a5a5ef0efd94d3f3ea608525dc7"}612652
{"name":"612653","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/9\/e913aa6fcbfc40ad2a27b0f63dfbd49c.png","w":1155,"h":339,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/9\/e913aa6fcbfc40ad2a27b0f63dfbd49c"}612653

Wanting to preserve the settings in Mr. Reynaldo's sample project, I created a separate project to test static linking only using Mr. Keane's list. I was able to get it to the same state of failure as Mr. Reynaldo's, the only difference being that it was unable to find a different library. (libdumb, I believe.) Then I attempted to alter the window size in the code that I supplied to it, and the result is documented in the corresponding screenshot. I changed the setting that Mr. Reynaldo suggested. The error persists.

EDIT: I posted this before seeing Mr. Keane's advice, so haven't implemented it yet.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

You need to copy the dlls in the bin folder to the directory where your program is. Then you can run it properly.

The reason static linking isn't working is because you're compiling as a C program. On Windows, Allegro is C++. You need to use C++ on Windows because of Allegro's dependency on Direct3D, which was implemented in C++.

DanielH
Member #934
January 2001
avatar

The longer this takes, the more I shake my head. No wonder few people use Allegro. ;D;D

I've never use Dev C++ so can't be help much.

On the execution part:

Personally, I would set the path. Especially if you have multiple projects. Otherwise you need to copy the DLL to each project folder.

If you update Allegro, you need to update the DLL for each folder.

1. For Debugging, set the path
2. For Release, copy DLL to folder before packaging.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

You should never change your system path to find allegro dlls. Do it from a command line using set if you have to, or just copy the dlls.

Have you seen all the garbage that ends up on your $PATH due to installing programs? It's trash. Use 'set' to set the %PATH%.

Command line :

set path=path\to\dlls;%PATH%
cd path\to\game
game.exe

BletchleyPark
Member #18,406
September 2020

{"name":"612654","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/f\/8\/f8fa51bfc62d5dfaba00d397bfb7de34.png","w":326,"h":210,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/f\/8\/f8fa51bfc62d5dfaba00d397bfb7de34"}612654

This is the result with dynamic linking per Mr. Reynaldo's instructions when they were finally properly followed. I was only putting the monolith dll in the folder instead of all of them, because I misunderstood what "monolith" dlls do.

The project I intend for Allegro will be small enough that dynamic linking will offer no advantage over static. So I will get this Hello World program working with static linking next.

As far as Dev goes, the compiler that comes with it doesn't work with Allegro and is a bazillion years old to boot. I will jump on the CB bandwagon, which, given how slowly I learn, is sure to annoy many of you. ;D

Thank you all for your help and your patience.

EDIT: It is now working with static linking using Mr. Keane's static linking list and Mr. Reynaldo's insight about Allegro's reliance on C++ dependent libraries. I saved the source file in .cpp format before inserting it into the project and it worked right off the bat.

Peter Hull
Member #1,136
March 2001

Well Done B.P.!

DanielH said:

The longer this takes, the more I shake my head. No wonder few people use Allegro.

It would be good if someone could summarise the instructions for this somewhere on the website.

Bob Keane
Member #7,342
June 2006

{"name":"5138e85838ffab162391e4f464154f13.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/5\/1\/5138e85838ffab162391e4f464154f13.png","w":680,"h":171,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/5\/1\/5138e85838ffab162391e4f464154f13"}5138e85838ffab162391e4f464154f13.png

I remember banging my head against that for quite a while. Edgar is right about compiling as a C++ program as opposed to a C program. Of course if dynamic linking is better suited to your needs, don't worry about static linking. Just remember to include the dlls when you distribute your programs.

By reading this sig, I, the reader, agree to render my soul to Bob Keane. I, the reader, understand this is a legally binding contract and freely render my soul.
"Love thy neighbor as much as you love yourself means be nice to the people next door. Everyone else can go to hell. Missy Cooper.
The advantage to learning something on your own is that there is no one there to tell you something can't be done.

 1   2   3 


Go to: