[AD] allegro_dev_c++ + USB port conflict

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


 

Hi, I need DEEPLY HELP:


I have a problem using Allegro and DEV C++ 4 9 8 0.

I m developing a freeware for light management in theatre, with a hardware on USB port to send DMX512 signal. I m under windows 2000 professionnal. Since I am on Allegro , and have configured Dev_C++ ( see after what was done with options on Dev-C++), when I run compilation I have this message in windows box:


Adress at « 0x000000000000 » employ the adress « 0x000000000000 » memory can not be « read »

(bad translated from French)


My prog is using a dll and when I go under Debug mode, it works fine! But exe is also doing same trouble.

I have already developped a first version under dos mode with same hardware and Dll and version of Dev-c++; and it was working fine, so I m sure conflict is beetween allegro and something to see with usb port and dev-c++/Mingw32.

Seems to have some troubles with afxwin.h; and wingdi.h when I used

#define ALLEGRO_AND_MFC ( see down sample talking about that from allegro 4 tutorial)


Please, help is needed as I choose to code under allegro for portability questions ( i want to compile after this application under MAC and Linux, as lighting computer tool for theatre and danse is rare and especially as freeware open source).

But as I m light designer and not at all informatician, I think that I need help from guys specialized in pre_comilator options, that can help me by PRECISE suggestions...


I had to add winalleg.h to have access in my code to the extern « C » procedures (hModule ect...).




Thanks to reply!

Sincerely yours,

Christoph Guillermet



Here is a part of the code ( all procedure are working fine when not under allegro):


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


#include "allegro.h"

#include "string.h"

#include "winalleg.h"

#include "_DasHard.h"

char message_dmx[256];


///////////////////////////////////////////////////////////////////////////////

///////////////////////IMPORTATION DLL/////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////



extern "C"

{

typedef int (CALLBACK *LP_DASHARDCOMMAND) (int command, int param, unsigned char *bloc );

}


HMODULE hLib = NULL;

// pointeur de la fonction

LP_DASHARDCOMMAND lp_DasHardCommand = NULL;


int LoadLib()

{

hLib = LoadLibrary("DASHARD.DLL");

if (hLib == NULL)

{

//sprintf(message_dmx,"Unable to load Dashard dll " );


}

lp_DasHardCommand = (LP_DASHARDCOMMAND) GetProcAddress(hLib, "DasHardCommand");

if (lp_DasHardCommand == NULL)

{

// sprintf(message_dmx,"Unable to load Dashard Commands " );

}

}

// ouverture du port à mettre dans une fonction


int OpenInterface()

{

if (lp_DasHardCommand != NULL)

{

int iRet = lp_DasHardCommand(1,0,0);

if (iRet != 11)

{

// sprintf(message_dmx,"Unable to Open interface " );

}

}

}

// close du port à mettre dans une fonction

int CloseInterface()

{

if (lp_DasHardCommand != NULL)

{ lp_DasHardCommand(DHC_CLOSE,0,0);

}

}


// décharger la Dll à la fin

int DeloadDll()

{

if (hLib != NULL)

{ FreeLibrary(hLib);

hLib = NULL;

}

}




//envoi de data a l interface

int SendData()

{


int count=0;

for (count=0;count<120;count++)

{DmxBlock[count]=BufferSaisie[(count+1)];}


//rootDimmerLaw();


lp_DasHardCommand(DHC_DMXOUT,120,DmxBlock);


return(0);

}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


Installing Allegro for Dev-C++

Dev-C++ is an excellent choice for developing Allegro games on a Microsoft Windows platform. While not quite as robust as Microsoft's Visual Studio, it is free and easy to use.


Requirements
Before you Start
These instructions are for Dev-C++ 4.00 and 4.01. They may or may not apply to other versions.

If you happen to have Mingw, DJGPP or any other version of GCC installed, then uninstall them. Dev-C++ will replace them from now on.

This step is required for getting Allegro to compile - we don't want your DJGPP installation to conflict with Dev-C++'s. Don't worry, you'll still have a fully functional gcc for Windows, and you can always reinstall the other compilers if you don't need to compile Allegro for Dev-C++.
Step by Step
  1. Download the complete Dev-C++ development package. Unzip it in a temporary directory (such as C:\temp), and run setup.exe from there. Select Typical install. Install it in a directory of your choice, but make sure do not use '+' in the name. (Recommended: c:\Dev-Cpp) This step is required for getting the command line utils to work properly. If you are running under Windows NT or 2000, you will need administritive priviliges to complete the installation. Also download Allegro 4.0 (Source), and unzip it in a directory of your choice. (Recommended: C:\Dev-Cpp\allegro)
  2. Dev-C++ is based off the Mingw32 compiler, so to get Allegro working, you'll need to update a few packages of Dev-C++. Following this procedure will update the whole compiler to the latest version of gcc (as of this writting). Download the following packages:
You may need to get a program to read the .gz and .bz2 files. Power Archiver is recommended for this task. WinRAR or WinZip will not work properly.
  1. You should uncompress all of them in your Dev-C++ directory, overwriting the older files.
  2. Now is the time to set up your path.
    • Windows 95 or Windows 98 - Open notepad and edit your c:\autoexec.bat. Add these lines at the end of the file:
      SET PATH=C:\Dev-Cpp\bin;%path%
      SET MINGDIR=C:\Dev-Cpp
      Make sure you write the exact path of where you installed Dev-C++ in Step 1, and add \bin at the end of it. Reboot your computer for the change to take effect.
    • Windows ME - You'll need to select "Run" off the start menu, then type in "msconfig". Select the environment tab, then make the changes as noted above. Reboot your computer for the changes to take effect.
    • Windows NT, 2000, XP - Open Control Panel (in XP, use the 'Classic View'), then the "System" applet, then the "Advanced" tab, and finally the "Environment" button. Select the PATH= entry, and add "C:\Dev-Cpp\bin" to it (without the quotes, and assuming you installed Dev-C++ in C:\Dev-Cpp). Create a new environment variable called MINGDIR and set it equal to "C:\Dev-Cpp" (again, without the quotes). You will need to log off and log back in for the changes to take effect.
Note: If at any stage, you get an "Out of Environment space" message, then please see the Allegro FAQ for how to fix this.
  1. Open a DOS prompt. Click Start. Choose Run and type "command.com" for Windows 95/98 or "cmd.exe" for Windows NT/2K/ME/XP. You can create a shortcut to it on your desktop or start menu if you like. Find your way to wherever you installed Allegro. Now's the time to test your installation. Type "gcc -v" (without the quotes) at the command prompt, followed by the <enter> key. You should see something like this:
G:\Dev-Cpp\allegro>gcc -v     
Reading specs from g:/dev-cpp/bin/../lib/gcc-lib/mingw32/2.95.3-6/specs     
gcc version 2.95.3-6 (mingw special)   
We're done setting up Dev-C++, and now will set up Allegro. (Don't worry, the hard part is already done!)
  1. At the DOS prompt you were in from step 5, type fix mingw32, then type make and watch Allegro compile. This may take a few minutes. Once Allegro is compiled, you'll need to install it.
  2. Now, to installing Allegro: type make install at the command prompt. Note that some poeple seem to have trouble at this step. Make sure your MINGDIR has been set. You can manually do it by typing SET MINGDIR=C:\Dev-Cpp before running make install.

    Ok, now that Allegro is properly set up and installed, we can create our first Allegro program (yay!)
  3. Launch Dev-C++ and create a new project (File/New Project). Select "Windows Application", then click on the "Ok" button. Name your project and give associate it to a new file. You should now see a sample code in a window. Close that window since you won't be needing it (Allegro is much simpler to use than this). Create a new file (File/New Source File), then write a small Allegro program. You can inspire yourself by the Allegro examples if you wish. Here's a small program you can type to see if everything worked until now:
#include "allegro.h"     
int main() {         
        allegro_init();         
        allegro_message("Hello World!");         
        return 0;     
}     
END_OF_MAIN();
  1. You now need to tell Dev-C++ that you'd like to make a program that uses Allegro. For that, go in the Project Options screen (Project/Project Options menu), then click on "Load Object Files". You need to select the file called liballeg.a (of liballd.a for the debug mode); the file should be in C:\Dev-Cpp\lib. Notice it's a .a file, and not a .o file, so you'll need to get the file dialog to show all files.
  2. Compile your project! Simply click on the green check mark on your Dev-C++ toolbar. Correct any syntax errors in your code, then click on "Execute" to run the program. If all worked you will see a message box pop up with "Hello World" inside of it. And we're done!

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Allegro Tutorial 4


36 Windows specifics

A Windows program that uses the Allegro library is only required to include one or more

header files from the include/allegro tree, or allegro.h; however, if it also needs to directly

call non portable Win32 API functions, it must include the Windows-specific header file

winalleg.h after the Allegro headers, and before any Win32 API header file. By default

winalleg.h includes the main Win32 C API header file windows.h. If instead you want to

use the C++ interface to the Win32 API (a.k.a. the Microsoft Foundation Classes), define

the preprocessor symbol ALLEGRO AND MFC before including any Allegro header so

that afxwin.h will be included. Note that, in this latter case, the Allegro debugging macros

ASSERT() and TRACE() are renamed AL ASSERT() and AL TRACE() respectively.

Windows GUI applications start with a WinMain() entry point, rather than the standard

main() entry point. Allegro is configured to build GUI applications by default and to do

some magic in order to make a regular main() work with them, but you have to help it out

a bit by writing END OF MAIN() right after your main() function. If you don?t want to do

that, you can just include winalleg.h and write a WinMain() function. Note that this magic

may bring about conflicts with a few programs using direct calls to Win32 API functions;

for these programs, the regular WinMain() is required and the magic must be disabled by

defining the preprocessor symbol ALLEGRO NO MAGIC MAIN before including Allegro

headers.




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/