• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
AniMerrill

Allegro and CMake: So close, but won't compile

3 posts in this topic

EDIT: So eventually figured out the problem, posted the answer down below.
 

So over the last week I've been pulling my hair out trying to figure out Ubuntu and how to compile using a terminal instead of an IDE and even somewhat taught myself how to use CMake so hopefully my game can be multiplatform. I successfully made and ran my first CMake file, but then when I went to "make" the file it created, it wouldn't compile.
 
The error it threw me was basically "allegro5/allegro.h" doesn't exist as a directory when it gets to my first cpp file. I'm sure this is either A) some error I made in the CMakeLists.txt file or B) some fundamental misunderstanding I have about Linux... or something. So sorry if this is a repost, I just don't have enough knowledge about either of these things to know what to search for on Google.
 
CMakeLists.txt:
 

cmake_minimum_required(VERSION 2.6)
project(game)
set(CMAKE_VERBOSE_MAKEFILE on)

#The version number
set(game_VERSION_MAJOR 0)
set(game_VERSION_MINOR 1)

set(game_SRCS SpriteSheet.cpp AnimationSet.cpp Map.cpp Character.cpp Main.cpp)

#Add the executable
add_executable(game ${game_SRCS})

#Include Allegro
include_directories(/home/username/Documents/allegro-5.0.9/build/include)
#===============
link_directories(/home/username/Documents/allegro-5.0.9/build/lib)
#===============
target_link_libraries(game liballegro.so)

 
 
The line that the error refers to is SpriteSheet.cpp where I've put #include <allegro5/allegro.h>.
 
I almost forgot to mention that this is the first time I've compiled an external library, like Allegro, from source... so I may have screwed something up there. I've never seen a .so file in my life, but I'm going to just assume its a Linux thing.
 
Also, if it matters at all, I'm on Ubuntu 12.10 and using Allegro 5.0.9.
 
Thanks in advanced for any help.

Edited by AniMerrill
1

Share this post


Link to post
Share on other sites

Some potentially "stupid" questions, but:

 

  • Do the paths "/home/username/Documents/allegro-5.0.9/build/include" and "/home/username/Documents/allegro-5.0.9/build/lib" exist? (I assume in your actual file "username" is replaced with your actual user name.)
  • Is there an "allegro5" subdirectory under "/home/username/Documents/allegro-5.0.9/build/include"?
  • Is liballegro.so in your "/home/username/Documents/allegro-5.0.9/build/lib" directory?
0

Share this post


Link to post
Share on other sites

Some potentially "stupid" questions, but:

 

  • Do the paths "/home/username/Documents/allegro-5.0.9/build/include" and "/home/username/Documents/allegro-5.0.9/build/lib" exist? (I assume in your actual file "username" is replaced with your actual user name.)
  • Is there an "allegro5" subdirectory under "/home/username/Documents/allegro-5.0.9/build/include"?
  • Is liballegro.so in your "/home/username/Documents/allegro-5.0.9/build/lib" directory?

 

No not stupid questions at all, since these are things I could have probably overlooked if you hadn't pointed them out.

 

1) Yes "username" is my username, not just username. Unless the Ubuntu file system works in a weird way I don't know, those two folders should be exactly correct. I can direct the terminal from the root folder using that address anyway. Also "build/include" and "build/lib" are the build folders for when I ran CMake on the Allegro 5 library.

 

2) There is an "allegro5" folder in that include directory, um... but I just realized that there is no "allegro.h" in it even though it exists in the "/home/username/Documents/allegro-5.0.9/include/allegro5" directory. I can only assume I either broke the CMake run or the make compilation for the library then... I was just following along what little tutorials I could find on the subject and hadn't really thought to check.

 

3) Yes, "liballegro.so" exists in that lib directory.

 

Um, I notice under the build lib directory where "liballegro.so" is there's a folder called "Headers" which pretty much looks exactly like the pre-build include folder. Is it possible I have to link to this or is there just something fundamental I'm not understanding here?

 

I know when you do straight command line compilation, this tutorial says you only need to do this:

 

$ g++ [source file(s)] -o [output] `pkg-config --libs allegro-5.0`. 

 

But a) I don't completely understand this either (at least the `pkg-config --libs allegro-5.0`. which doesn't seem to point to any real file) and b) I don't know how to convert this into a CMake command.

Edited by AniMerrill
0

Share this post


Link to post
Share on other sites
Well I eventually figured it out, so I'm going to post it up here for any noobies of the future that make a similar mistake. Here's the makefile that I ended up with to get my program to compile successfully on Ubuntu 12.10.
cmake_minimum_required(VERSION 2.6)
project(game)
set(CMAKE_VERBOSE_MAKEFILE on)

#The version number
set(game_VERSION_MAJOR 0)
set(game_VERSION_MINOR 1)

set(game_SRCS SpriteSheet.cpp AnimationSet.cpp Map.cpp Character.cpp Main.cpp)

#Add the executable
add_executable(game ${game_SRCS})

#Include Allegro
include_directories(/home/username/Documents/allegro-5.0.9/build/include)
include_directories(/home/username/Documents/allegro-5.0.9/build/lib/Headers)
link_directories(/home/username/Documents/allegro-5.0.9/build/lib)
#connect all the libraries you need
set(game_LIBS liballegro.so liballegro_dialog.so liballegro_image.so)
target_link_libraries(game ${game_LIBS})
Note: I transferred this project over from Visual Studio so currently I only NEEDED the base allegro, native dialog, and image libraries because that's all the code used so far.

So first mistake I made: the reason I was getting that error about <allegro5/allegro.h> is because apparently filenames work with \ not /. So simply changing all my <allegro5/whatever.h> to <allegro5\whatever.h> fixed that problem.

The next problem is that I needed to either include_directories() where the "Headers" was. Which is odd, because that's not how it works when working with Microsoft development. From what I saw, the build include folder only has configuration files in it while the Headers file in the build lib folder has what's in a normal windows include folder. I can only assume the other work around would be to alter all my #include statements inside my code to "Headers/allegro5/allegro_whatever.h" but that seems to wordy for what I wanted.
 
Idk, anyone else who wants to toss two cents in can but for now I'm just happy I got this stupid thing to compile.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0