• 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
BurrickSlayer

How to organize a C++ project and its external libraries

7 posts in this topic

Perhaps consider putting external lib even higher up the chain, as you could have multiple project use the same external SFML library. 

 

something like:

 

./dev

./dev/external/sfml

./dev/external/box2d

./dev/projects/pong

./dev/projects/tetris

0

Share this post


Link to post
Share on other sites

Thank you both for your suggestions!

@nhatkthanh

This is similar to my current setup. All my external libraries are stored in D:\Libs\. In my project root directory I have a folder named paths, that contains symbolic links to the required external libraries.

It works for me, so I'll probably keep it that way if it turns out to be the best option.

@AllEightUp

Your tutorial project is very helpful, thanks. I use CMake, too (along with QT Creator). I'm not very adept in it, yet, so your CMake scripts are also interesting for me.

I'm not entirely sure what you mean with "avoiding modifications to the external libraries", though. Were you referring to how I split up SFML in separate directories for headers and platform- and compiler-specific bins and libs? I was inspired by way SFML handled external libraries, as the SFML repository contains DLLs and libs for OpenAL and libsndfile. They're added like this in /src/SFML/CMakeLists.txt:
 


# let CMake know about our additional libraries paths (on Windows and OS X)

if (WINDOWS)

    set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/headers")

    if(COMPILER_GCC)

        if(ARCH_32BITS)

            set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/libs-mingw/x86")

            set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/bin/x86")

        elseif(ARCH_64BITS)

            set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/libs-mingw/x64")

            set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/bin/x64")

        endif()

    elseif(COMPILER_MSVC)

        ...

    

I thought I could do it in a similar fashion.

 

Or should I rather use the script FindSFML.cmake instead? I just recently payed attention to this script.

 

0

Share this post


Link to post
Share on other sites


The external libraries I use (currently only SFML and pugixml) are not under version control yet though. I would like to change that, so that the repository contains everything that is needed to build the project. I also would like to keep it more platform and compiler independent than it currently is
Yeah I prefer to make an "external" directory, inside my project's directory, which contains all the dependencies, rather than having all my dependencies existing independently outside of my project directory.

The reason for this is simply configuration management and quality assurance. If you're relying on independent external libraries, then different people on your team (or different PC's of your own) might produce different results, due to those different people/PCs having different versions of the external libraries installed.

By bundling them into your own project, you ensure that it is always built the exact same way with the exact same code.

 

The layout I'd normally use would be leave the external libraries alone. My project files (CMake etc) will be a bit messy as each external library will use a different layout for it's own files, but it's easier to just leave their distro alone and deal with this slightly messy config on my end, rather than try to reorganize their files to the way I'd prefer every single time I update to a new version of their library...

project/msvc/...     compiler specific stuff (projects/workspaces/etc)
project/src/...      code that's internal to the library
project/include/...  code for users of the library
project/bin/...      where it's built to
project/external/... third party libraries required
e.g.
project/external/foo/... the foo distribution *untouched*
project/external/foo/include
project/external/foo/src
project/external/foo/lib/x86windows
project/external/bar/... the bar distribution *untouched*
project/external/bar/includes
project/external/bar/sources
project/external/bar/bin/win32
2

Share this post


Link to post
Share on other sites

@AllEightUp

Your tutorial project is very helpful, thanks. I use CMake, too (along with QT Creator). I'm not very adept in it, yet, so your CMake scripts are also interesting for me.

 

I'm not entirely sure what you mean with "avoiding modifications to the external libraries", though. Were you referring to how I split up SFML in separate directories for headers and platform- and compiler-specific bins and libs? I was inspired by way SFML handled external libraries, as the SFML repository contains DLLs and libs for OpenAL and libsndfile. They're added like this in /src/SFML/CMakeLists.txt:
 

I thought I could do it in a similar fashion.

 

Or should I rather use the script FindSFML.cmake instead? I just recently payed attention to this script.

 

In regards to SFML, it makes sense for that library to supply the includes/libs/dll's in a cleaned up manner as the point of SFML is easy use and distribution.  This is different than writing a game though where the focus is not on easy distribution so much as it is on getting the job done.  Let's say it takes a couple hours to build all the variations of SFML, make copies of the includes, put the binaries where you want them etc, that's a couple hours you could be coding on the game instead of fiddling with trivialities.  With the solution I use in the tutorials project, if I upgrade SFML I just drop it into the extern folder and point the listfile to the new location, delete the old version and keep working on my game.  5 minutes (ok, 10 if you count the extra build time for the new version :)) versus a couple hours.

 

As to making no modifications, I mean that it should be literally a matter of downloading the new source package, unzip to the extern directory and update the CMake list files to point at the new version.  Anything beyond that, or perhaps very trivial modifications, is just too much of a hassle generally.  The libraries which come with SFML are not exactly my favorite thing, but then again, building FreeType2 is a pain in the ass (on Windows at least) and SFML is coded against those versions so I have no problem using them, this is an exception to my normal rules though.

 

As to using FindSFML, as Hodgman says, I want a self contained project, so I build SFML as part of my solution.  Different library versions, compiler flags etc are too painful later, I want to basically have a directory I can zip and drop on another machine and it just "works" without the user having to do a bunch of nonsense.  At most, and only on Windows, I generally have to point folks at the VC redistributable to get that installed, other than that I want no other worries in distribution.  This is an experience thing, back in the bad days I released a game and we were debugging oddball startup failures, game crashes etc for almost a month because of different libraries installed on different machines and all the hassles that involves.  I wouldn't wish such an experience on anyone, especially the users.. :)

1

Share this post


Link to post
Share on other sites

@Hodgman,
@AllEightUp

Thank you for explaining and sharing your experiences. I can now understand why keeping the project self contained and not messing with the external libaries' layouts is beneficial in many ways. I'll put the SFML distro into my "external" directory as is and add it to my project's build process using CMake.

In order to do so I've already taken a deeper look into the tutorial project. Being the CMake beginner I am, I wasn't quite able to understand what was going on in the CMake scripts at first. After reading through the Cross Platform Test Driven Development Environment Using CMake articles, however, it was much easier. I haven't leveraged my newly acquired knowledge yet, but I'll do so in the next days, I hope. I'm looking forward to restructure other parts of my project with CMake for easier maintainability (e.g. making the framework a library to keep it separated from the gameplay stuff). smile.png

@Matt-D

Thanks! I have peeked into the book on Safari Books and put it on my ever growing list.

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