Jump to content
  • Advertisement
Sign in to follow this  
ISDCaptain01

Having trouble using tiled with allegro 5

This topic is 2064 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I downloaded the header file from here
https://github.com/dradtke/allegro_tiled

this is my code, very short

#include <allegro5/allegro.h>
#include <allegro5/allegro_native_dialog.h>
#include <allegro5/allegro_image.h>
#include "allegro_tiled.h"
#include <iostream>
using namespace std;


#define WIDTH 800
#define HEIGHT 600
#define FPS 60
#define MAP_FOLDER "data/maps"

int main()
{
	al_init();
	if(!al_init())
	{
		al_show_native_message_box(NULL, NULL, NULL, "Tiled Test", NULL, NULL);
	}

	ALLEGRO_DISPLAY *display;
	al_set_new_display_flags(ALLEGRO_RESIZABLE | ALLEGRO_WINDOWED);
	display = al_create_display(WIDTH, HEIGHT);
	al_set_window_title(display, "Tiled Test");

	//Init all subsystem
	al_install_keyboard();
	ALLEGRO_KEYBOARD_STATE keyState;
	al_init_image_addon();

	//create timer
	ALLEGRO_TIMER *timer;
	timer = al_create_timer(1.0/FPS);

	//create event queue
	ALLEGRO_EVENT_QUEUE *event_queue;
	event_queue = al_create_event_queue();

	//Register the event queue
	al_register_event_source(event_queue, al_get_keyboard_event_source());
	al_register_event_source(event_queue, al_get_timer_event_source(timer));
	al_register_event_source(event_queue, al_get_display_event_source(display));

	//Load the map
	ALLEGRO_MAP *map = NULL;
	map = al_open_map(MAP_FOLDER, "zelda1.tmx");
	int map_total_width = al_get_map_width(map) * al_get_tile_width(map);
	int map_total_height = al_get_map_height(map) * al_get_tile_height(map);

	bool done= false;

	//start the timer
	al_start_timer(timer);

	while(!done)
	{
		ALLEGRO_EVENT events;
		al_wait_for_event(event_queue, &events);

		if(events.type == ALLEGRO_EVENT_DISPLAY_CLOSE)
		{
			done = true;
		}

		al_clear_to_color(al_map_rgb(0,0,0));
		al_draw_map(map, map_total_width, map_total_height, NULL);
		al_flip_display();
	}


	return 0;
}

:

I keep on getting these error:
1>------ Build started: Project: a5_tiledExample, Configuration: Debug Win32 ------
1>main.obj : error LNK2019: unresolved external symbol _al_draw_map referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _al_get_tile_height referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _al_get_map_height referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _al_get_tile_width referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _al_get_map_width referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _al_open_map referenced in function _main
1>c:\users\oomair\documents\visual studio 2010\Projects\a5_tiledExample\Debug\a5_tiledExample.exe : fatal error LNK1120: 6 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Edited by ISDCaptain01

Share this post


Link to post
Share on other sites
Advertisement

The errors mean that the functions aren't implemented anywhere, they're just declared.

 

Did you only download the header file? You'll most likely need to download the implementation as well -- which might be a lib or .cpp file or similar.

Can't access the link right now, but check if there's a tutorial or example project that shows what files are needed, etc.

Edited by CoreLactose

Share this post


Link to post
Share on other sites

Have you successfully compiled and built the library?

You should have used CMake to do it.

 

If you have not, read the Compiling section of the library's main github page.

 

You should also have the following files:

data.h
draw.h
map.h
parser.h
xml.h
zpipe.h

 

They should be under the /src folder. Try "#including" them.

Share this post


Link to post
Share on other sites
No I have not used cmake as I dont know how to. I thought if I use the .h file than why would I need to? Ill try adding the additional .h files when I get home and see if it works

Share this post


Link to post
Share on other sites
It is a library so if you did build it and got no errors, then it means you aren't linking to the library which in turn is making your compiler and linker have no clue about the library.

Just like Allegro 5, it is a library that you have to build and link against for the header file to be of any use. The readme file tells you how to build it and install it.

Also just thought, if you don't have the libxml2 library it may give new errors after building it. That is another issue we will address after the first one.

Share this post


Link to post
Share on other sites

You guys know how I can build this library? I have no experience doing this. Arent there any pre-built available? I know allegro 5 does.

Edited by ISDCaptain01

Share this post


Link to post
Share on other sites

I wish I could help you with this, but it looks like you use visual studio, and I only have experience with gcc.

 

But the general procedure is the one in here: https://github.com/dradtke/allegro_tiled#compiling

We use cmake to prepare the compilation and then we use make to get the library ready to use.

The problem is that I really don't know what is the MSVS procedure that would be equivalent to the make command (or if it has a make command that you can use directly).

 

Still, I can't help but to advise you to avoid using pre-compiled binaries for your libraries. Not because they are bad, but because you'll never learn how to compile a library if you always use them, and they aren't always available. Compiling with CMake and make is something every C++ game dev beginner should learn.

 

You should search the internet for "VisualStudio CMake" and try to find a generic tutorial. It shouldn't be too different than the one on the github page.

Edited by dejaime

Share this post


Link to post
Share on other sites

alright Ill look for a tutorial, but if anyone is kind enough to offer me a pre-compiled binary ill be very happy. If al else fails, its back to mappy :(

Share this post


Link to post
Share on other sites
Sadly, I don't think the A5 Tiled library has any binaries made. Usually when the allegro community members make an add on and post the code to git, they don't mess with binaries. I would recommend learning SDL or SFML, and if you are set on using Tiled and load with them then I'd say learn SDL and invest in getting SDL Game Development as it covers using Tiled to make the levels, how to save the map, and then how to load them. Unfortunately, I don't know how well it will work for you because I don't know if SDL and the required libraries come in binary form.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!