allegro file difficulty...

  • (2 Pages)
  • +
  • 1
  • 2

15 Replies - 1697 Views - Last Post: 29 June 2015 - 03:19 PM Rate Topic: -----

#1 Doctor Miyamoto   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 06-June 15

allegro file difficulty...

Posted 08 June 2015 - 02:24 PM

HELLO WORLD of programmers! You see I started another project just to test my skills, and It appears that I get these 15 errors which are No such file in directory, and, the files in these errors seem to start with lib and end in .a, such as libcomdlg32.a. I'm pretty sure that I have all of the necessary link libarys in my project build options. But you can still mention It, Therefore I will take any kind of solution. Again, any kind of help would be awesome even though I might solve the problem on my own!

Is This A Good Question/Topic? 0
  • +

Replies To: allegro file difficulty...

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14232
  • View blog
  • Posts: 57,095
  • Joined: 12-June 08

Re: allegro file difficulty...

Posted 08 June 2015 - 02:28 PM

Please copy/paste your errors in this thread, and your current code (use the 'code' button in the editor to apply code tags for readability).
Was This Post Helpful? 0
  • +
  • -

#3 Doctor Miyamoto   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 06-June 15

Re: allegro file difficulty...

Posted 08 June 2015 - 02:56 PM

Well It appears that I solved that problem already, but just one more problem I have to fix, here is the errors...
../../../../../MinGW/lib/dllcrt2.o multiple definition of 'atexit'
c:mingw/bin/../lib/gcc/mingw32/4.8.1/../../../crt2.o first defined here
../../../../../MinGW/lib/dllcrt2.o multiple definition of '_onexit'
c:mingw/bin/../lib/gcc/mingw32/4.8.1/../../../crt2.o first defined here

Its amazing that I get so much errors.... yeeeeeeeessshhh!

Here is also my code......


#define ALLEGRO_STATICLINK
#include<stdio.H>
#include<allegro5/allegro.h>
#include<allegro5/allegro_font.h>
#include<allegro5/allegro_ttf.h>

int main(int argc, char **argv){
   if(!al_init()){
     fprintf(stderr, "Failed to initialize Allegro./n");
    return -1;
   }
   al_init_font_addon();
   al_init_ttf_addon();
   ALLEGRO_DISPLAY *display = al_create_display(640,480);

   if(!display){
      fprintf(stderr, "Failed to create display./n");
   return -1;
   }
   ALLEGRO_FONT *font = al_load_ttf_font("CBM.ttf",72,0);
   if(!font){
        fprintf(stderr, "Could not load 'CBM.ttf'./n");
   return -1;
   }

   al_clear_to_color(al_map_rgb(40,20,60));
   al_draw_text(font, al_map_rgb(255,210, 100), 640/2, (480/4),ALLEGRO_ALIGN_CENTRE, "WOW! Your first Allegro program, cool!");

   al_flip_display();

   al_rest(10.0);

   al_destroy_display(display);

   return 0;

}


:code:

This post has been edited by modi123_1: 08 June 2015 - 02:57 PM
Reason for edit:: Please use the 'code' button in the editor to apply code tags for readability.

Was This Post Helpful? 0
  • +
  • -

#4 stayscrisp   User is offline

  • フカユ
  • member icon

Reputation: 1040
  • View blog
  • Posts: 4,325
  • Joined: 14-February 08

Re: allegro file difficulty...

Posted 09 June 2015 - 03:04 AM

I would imagine that allegro_ttf.h probably also #include's allegro_font.h and allegro.h. Just include allegro_ttf.h and give it a try.
Was This Post Helpful? 0
  • +
  • -

#5 Doctor Miyamoto   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 06-June 15

Re: allegro file difficulty...

Posted 09 June 2015 - 04:57 PM

Well, I was able to fix my other errors, but sadly i got one more, It is dllcrt2.o no such file or directory.
What do .o or object files have to do with making games with codeblocks and allegro? and here is my new code....

#include "allegro_ttf.h"
#include "allegro_font.h"
#include "allegro.h"
#define ALLEGRO_STATICLINK
#include<stdio.H>
#include<allegro5/allegro.h>
#include<allegro5/allegro_font.h>
#include<allegro5/allegro_ttf.h>

int main(int argc, char **argv){
   if(!al_init()){
     fprintf(stderr, "Failed to initialize Allegro./n");
    return -1;
   }
   al_init_font_addon();
   al_init_ttf_addon();
   ALLEGRO_DISPLAY *display = al_create_display(640,480);

   if(!display){
      fprintf(stderr, "Failed to create display./n");
   return -1;
   }
   ALLEGRO_FONT *font = al_load_ttf_font("CBM.ttf",72,0);
   if(!font){
        fprintf(stderr, "Could not load 'CBM.ttf'./n");
   return -1;
   }

   al_clear_to_color(al_map_rgb(40,20,60));
   al_draw_text(font, al_map_rgb(255,210, 100), 640/2, (480/4),ALLEGRO_ALIGN_CENTRE, "WOW! Your first Allegro program, cool!");

   al_flip_display();

   al_rest(10.0);

   al_destroy_display(display);

   return 0;

}



Also, how can I get less errors? any good advice?

This post has been edited by stayscrisp: 10 June 2015 - 03:40 PM
Reason for edit:: CODE TAGS!!

Was This Post Helpful? 0
  • +
  • -

#6 stayscrisp   User is offline

  • フカユ
  • member icon

Reputation: 1040
  • View blog
  • Posts: 4,325
  • Joined: 14-February 08

Re: allegro file difficulty...

Posted 10 June 2015 - 03:43 PM

USE CODE TAGS!!

.o files are created by the compiler and then linked together to create your final executable, they are very important!

Seems like you don't have the library set up correctly, go to the documentation and follow the steps to create an allegro project.
Was This Post Helpful? 0
  • +
  • -

#7 Doctor Miyamoto   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 06-June 15

Re: allegro file difficulty...

Posted 11 June 2015 - 04:57 PM

Okay, Im pretty sure that the installation is right now, however, I need you to tell me how I can find enable code tags in code blocks. I looked in settings and editor and was not able to find it. sorry for the hassle, I have proggramed in c++ using some videos to teach me, but I guess im just a begginer when it comes to knowing how to fix errors. I will take any kind of help. Thanks.

Here is my code now....#include "allegro_ttf.h"
#define ALLEGRO_STATICLINK
#include<stdio.H>
#include<allegro5/allegro.h>
#include<allegro5/allegro_font.h>
#include<allegro5/allegro_ttf.h>

int main(int argc, char **argv){
   if(!al_init()){
     fprintf(stderr, "Failed to initialize Allegro./n");
    return -1;
   }
   al_init_font_addon();
   al_init_ttf_addon();
   ALLEGRO_DISPLAY *display = al_create_display(640,480);

   if(!display){
      fprintf(stderr, "Failed to create display./n");
   return -1;
   }
   ALLEGRO_FONT *font = al_load_ttf_font("CBM.ttf",72,0);
   if(!font){
        fprintf(stderr, "Could not load 'CBM.ttf'./n");
   return -1;
   }

   al_clear_to_color(al_map_rgb(40,20,60));
   al_draw_text(font, al_map_rgb(255,210, 100), 640/2, (480/4),ALLEGRO_ALIGN_CENTRE, "WOW! Your first Allegro program, cool!");

   al_flip_display();

   al_rest(10.0);

   al_destroy_display(display);

   return 0;

}


errors are....
||=== Build: Debug in my game 2 (compiler: GNU GCC Compiler) ===|
..\..\..\..\..\MinGW\lib\dllcrt2.o:dllcrt1.c|| multiple definition of `atexit'|
c:\mingw\bin\..\lib\gcc\mingw32\4.8.1\crt2.o|| first defined here|
..\..\..\..\..\MinGW\lib\dllcrt2.o:dllcrt1.c|| multiple definition of `_onexit'|
c:\mingw\bin\..\lib\gcc\mingw32\4.8.1\crt2.o|| first defined here|
||=== Build failed: 4 error(s), 0 warning(s) (0 minute(s), 5 second(s)) ===|

This post has been edited by modi123_1: 12 June 2015 - 06:37 AM
Reason for edit:: Please use the 'code' button in the editor to apply code tags for readability.

Was This Post Helpful? 0
  • +
  • -

#8 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14232
  • View blog
  • Posts: 57,095
  • Joined: 12-June 08

Re: allegro file difficulty...

Posted 12 June 2015 - 06:36 AM

Quote

I need you to tell me how I can find enable code tags in code blocks.

The code tag being referred to was for this site. It helps format your code and add syntax highlighting.

You would highlight your text, in the post, that requires the code tag, and click the '[ code]' button in the editor. It would apply the tags.

Posted Image
Was This Post Helpful? 0
  • +
  • -

#9 stayscrisp   User is offline

  • フカユ
  • member icon

Reputation: 1040
  • View blog
  • Posts: 4,325
  • Joined: 14-February 08

Re: allegro file difficulty...

Posted 12 June 2015 - 04:36 PM

Again I am fairly certain that you are including too many headers, just include allegro_ttf.h as it has includes for allegro.h and allegro_font.h.
Was This Post Helpful? 0
  • +
  • -

#10 Doctor Miyamoto   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 06-June 15

Re: allegro file difficulty...

Posted 14 June 2015 - 01:08 PM

HY! ok, I fixed everything but when I run my program it will not open and it will bring the console window up and It will say this....
could not load 'CBM.ttf'./n
processed return -1 (0xFFFFFFFF) execution time : 0.359s
Press any key to continue

and again here is my code!
#include "allegro_ttf.h"
#include "allegro_font.h"
#include "allegro.h"
#include<stdio.H>
#include<allegro5/allegro.h>
#include<allegro5/allegro_font.h>
#include<allegro5/allegro_ttf.h>

int main(int argc, char **argv){
   if(!al_init()){
     fprintf(stderr, "Failed to initialize Allegro./n");
    return -1;
   }
   al_init_font_addon();
   al_init_ttf_addon();
   ALLEGRO_DISPLAY *display = al_create_display(640,480);

   if(!display){
      fprintf(stderr, "Failed to create display./n");
   return -1;
   }
   ALLEGRO_FONT *font = al_load_ttf_font("CBM.ttf",72,0);
   if(!font){
        fprintf(stderr, "Could not load 'CBM.ttf'./n");
   return -1;
   }

   al_clear_to_color(al_map_rgb(40,20,60));
   al_draw_text(font, al_map_rgb(255,210, 100), 640/2, (480/4),ALLEGRO_ALIGN_CENTRE, "WOW! Your first Allegro program, cool!");

   al_flip_display();

   al_rest(10.0);

   al_destroy_display(display);

   return 0;

}






So, I did try your advice about only including allegro_ttf.h that did not work, so I just adjusted my linker settings and that worked. As much as I want a solution I also would like all kinds of advice for becoming a games programmer, but the solution to my problem is most important. again, Im sorry if im wasting any ones time, after all, im a beginner and before c++ I was programing in QB64.

By the way I also have CBM.ttf file in the path of my .exe file.
Was This Post Helpful? 0
  • +
  • -

#11 stayscrisp   User is offline

  • フカユ
  • member icon

Reputation: 1040
  • View blog
  • Posts: 4,325
  • Joined: 14-February 08

Re: allegro file difficulty...

Posted 15 June 2015 - 03:45 AM

#include "allegro_ttf.h"
#include "allegro_font.h"
#include "allegro.h"
#include<stdio.H>
#include<allegro5/allegro.h>
#include<allegro5/allegro_font.h>
#include<allegro5/allegro_ttf.h>



Um...wut?
Was This Post Helpful? 0
  • +
  • -

#12 Doctor Miyamoto   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 06-June 15

Re: allegro file difficulty...

Posted 15 June 2015 - 01:26 PM

OK THEN... So I did not know what you mean by your "Um...wut?" comment, however, from looking at the image I figured you wanted me to just include allegro_ttf.h in my code, and keep in mind I left a #include "stdio.h" because if I did not then I would get a lot of errors. So, I still get only the console window up and the build log always says process terminated, and the console says the same thing as before , again, here is my code, any solution would be awesome, and other such advice. Is it possible that allegro does not accept .ttf files? I read it but i dont know if its true. :)/>
#include "allegro_ttf.h"
#include "stdio.h"

int main(int argc, char **argv){
   if(!al_init()){
     fprintf(stderr, "Failed to initialize Allegro./n");
    return -1;
   }
   al_init_font_addon();
   al_init_ttf_addon();
   ALLEGRO_DISPLAY *display = al_create_display(640,480);

   if(!display){
      fprintf(stderr, "Failed to create display./n");
   return -1;
   }
   ALLEGRO_FONT *font = al_load_ttf_font("CBM.ttf",72,0);
   if(!font){
        fprintf(stderr, "Could not load 'CBM.ttf'./n");
   return -1;
   }

   al_clear_to_color(al_map_rgb(40,20,60));
   al_draw_text(font, al_map_rgb(255,210, 100), 640/2, (480/4),ALLEGRO_ALIGN_CENTRE, "WOW! Your first Allegro program, cool!");

   al_flip_display();

   al_rest(10.0);

   al_destroy_display(display);

    return 0;

}





Again, im in a learning process and I do try to find the answers on google to.

This post has been edited by stayscrisp: 17 June 2015 - 06:05 AM

Was This Post Helpful? 0
  • +
  • -

#13 stayscrisp   User is offline

  • フカユ
  • member icon

Reputation: 1040
  • View blog
  • Posts: 4,325
  • Joined: 14-February 08

Re: allegro file difficulty...

Posted 17 June 2015 - 06:09 AM

I was confused as to why you were including the same header files more than once?

Also your code has no way to continue executing, it just loads the font does one display and then exits.

You need to wrap what you want to continue executing in a loop:

if(!gameFinished)
{
   // continue executing game code
}

// game finished - destroy anything you created
return 0;


Was This Post Helpful? 0
  • +
  • -

#14 Doctor Miyamoto   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 06-June 15

Re: allegro file difficulty...

Posted 21 June 2015 - 03:28 PM

Hy! Sorry, I was on vacation... anyway I still got errors, Should I just stop this and get more regular programing experience or do some other kind of solutions? Anyway, I really truly do want to make my own games, so here are my code and errors, and any advice from such a holy saint would be the best. Thanks.
#include "allegro_ttf.h"
#include "stdio.h"

int main(int argc, char **argv){
   if(!al_init()){
     fprintf(stderr, "Failed to initialize Allegro./n");
    return -1;
   }
   al_init_font_addon();
   al_init_ttf_addon();
   ALLEGRO_DISPLAY *display = al_create_display(640,480);

   if(!display){
      fprintf(stderr, "Failed to create display./n");
   return -1;
   }
   ALLEGRO_FONT *font = al_load_ttf_font("CBM.ttf",72,0);
   if(!font){
        fprintf(stderr, "Could not load 'CBM.ttf'./n");
   return -1;
   }

   al_clear_to_color(al_map_rgb(40,20,60));
   al_draw_text(font, al_map_rgb(255,210, 100), 640/2, (480/4),ALLEGRO_ALIGN_CENTRE, "WOW! Your first Allegro program, cool!");

   al_flip_display();

   al_rest(10.0);

   al_destroy_display(display);
if(!gameFinished)
{
    continue
}

    game finished
return 0;




||=== Build: Debug in my game 2 (compiler: GNU GCC Compiler) ===|
C:\Documents and Settings\DELL\Desktop\allegro 2 project\my game 2\main.cpp||In function 'int main(int, char**)':|
C:\Documents and Settings\DELL\Desktop\allegro 2 project\my game 2\main.cpp|31|error: 'gameFinished' was not declared in this scope|
C:\Documents and Settings\DELL\Desktop\allegro 2 project\my game 2\main.cpp|33|error: continue statement not within a loop|
C:\Documents and Settings\DELL\Desktop\allegro 2 project\my game 2\main.cpp|34|error: expected ';' before '}' token|
C:\Documents and Settings\DELL\Desktop\allegro 2 project\my game 2\main.cpp|36|error: 'game' was not declared in this scope|
C:\Documents and Settings\DELL\Desktop\allegro 2 project\my game 2\main.cpp|36|error: 'finished' was not declared in this scope|
C:\Documents and Settings\DELL\Desktop\allegro 2 project\my game 2\main.cpp|37|error: 'lreturn' was not declared in this scope|
C:\Documents and Settings\DELL\Desktop\allegro 2 project\my game 2\main.cpp|37|error: expected ';' before numeric constant|
C:\Documents and Settings\DELL\Desktop\allegro 2 project\my game 2\main.cpp|37|error: expected '}' at end of input|
||=== Build failed: 8 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
||=== Run: Debug in my game 2 (compiler: GNU GCC Compiler) ===|
Was This Post Helpful? 0
  • +
  • -

#15 stayscrisp   User is offline

  • フカユ
  • member icon

Reputation: 1040
  • View blog
  • Posts: 4,325
  • Joined: 14-February 08

Re: allegro file difficulty...

Posted 22 June 2015 - 08:13 AM

Yes, you definitely need to go back to basics here. I'll give you a starting point with this code you have, but before you go any further I suggest that you look at some absolute beginners tutorials.

I say this because you don't seem to even recognise comments, this is pretty much stage 0 of programming and shouldn't pose any effort to you at all if you expect to attempt even the most basic console program.

But everyone has to start somewhere so don't feel too disheartened.

Here is an untested version of your code for you to peruse (with comments) and fix and get ideas of how to lay out your code.

#include <iostream>
#include "allegro_ttf.h"

using namespace std;

// declare some functions to do initialisation & display
bool init_allegro();
void update_display();
void cleanup();

// global variables are usually a bad idea, but fine for a simple program like this

// bool variable to keep the game running
bool gameRunning = false;

// a pointer to an allegro display object
ALLEGRO_DISPLAY *pDisplay = null;

// a pointer to an allegro font object
ALLEGRO_FONT *pFont = null;

int gameWidth = 640;
int gameHeight = 480;

const char* textToDisplay = "WOW! Your first Allegro program, cool!";

const char* fontFilename = "CBM.ttf";
int fontSize = 72;
int fontFlags = 0;


int main(int argc, char **argv)
{
	// attempt initialisation
	if(init_allegro())
	{
		// if success
		gameRunning = true;
	}
	
	while(gameRunning)
	{
		update_display();
	}
	
	cleanup();
	return 0;
}

// define the functions
bool init_allegro()
{
	if(!al_init() || !al_init_font_addon() || !al_init_ttf_addon())
	{
		allegro_message("Failed to init game! : " + allegro_error);
		return false;
	}
	   
	pDisplay = al_create_display(gameWidth, gameHeight);

	if(pDisplay == null)
	{
		allegro_message("Failed to create display! : " + allegro_error);
		return false;
	}
	   
	pFont = al_load_ttf_font(fontFilename, fontSize, fontFlags);
	if(pFont == null)
	{
		allegro_message("Failed to create font! : " + allegro_error);
		return false;
	}
	
	return true;
}

void update_display()
{
	// clear to chosen colour
	al_clear_to_color(al_map_rgb(40,20,60));
	
	// draw some text
	al_draw_text(font, al_map_rgb(255,210, 100), 640/2, (480/4),ALLEGRO_ALIGN_CENTRE,textToDisplay);

	// show the text
	al_flip_display();

	// rest 10 seconds
	al_rest(10.0);
}

void cleanup()
{
	// destroy anything we created
	if(pDisplay != null)
	{
		al_destroy_display(pDisplay);
	}
	
	if(pFont != null)
	{
		al_destroy_font(pFont);
	}
}



This will of course run forever and will probably need a force quit. I'll leave that for you to create a more elegant implementation ;)/>

This post has been edited by stayscrisp: 22 June 2015 - 08:26 AM

Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2