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

Visual Studio: Selectively include header (external APIs, ...) to project

10 posts in this topic

Hello,

 

I want the following: To include an external project with both headers, libs and possibly DLLs to my engine, but have it included so that in case that project is not installed on the users PC, building will not fail for him. E.g. the FBX model SDK, I don't want to require ever user to install this on his PC if he is not using the FBX file format. In case FBX is missing, the project should still compile, and simply disable the FBX-conversion-routines. Is any such thing possible in MSVC (using 2013 Ultime)?

0

Share this post


Link to post
Share on other sites
There are two basic choices here. The simple and easy choice is to ship your program with all of the DLLs it requires, and this is usually preferable.

If you want to support running without a particular DLL, you need to late-bind it. The typical tools for this are LoadLibrary and GetProcAddress. See MSDN for details.
2

Share this post


Link to post
Share on other sites


There are two basic choices here. The simple and easy choice is to ship your program with all of the DLLs it requires, and this is usually preferable.

If you want to support running without a particular DLL, you need to late-bind it. The typical tools for this are LoadLibrary and GetProcAddress. See MSDN for details.

 

The problem is not only in the DLLs, but rather in the source too. Is it common in larger projects to ship with all the required external headers too? I assume the second method you mentioned still requires eigther the headers or really load all the functions using GetProcAddress and using them through those address pointers, which appears dissappealing at first sight :/

0

Share this post


Link to post
Share on other sites

If your code is dependent on other code, then yes, anyone else trying to compile it needs both your code and the other code.

 

There are ways around this, though. You could wrap the external code in a DLL of your own, and use that as a minimal interface to the external code instead of trying to GetProcAddress all the stuff in the other DLL. This is also good insulation against ABI differences (note that if you try to pass C++ objects, throw exceptions, or allocate/free memory across DLL boundaries, you're in for nasty bugs).

 

Another option is to build your code in such a way that it has to be generated before it can be compiled, and the generation step includes detecting missing dependencies and excising code that relies on them. A lot of open-source projects do this.

2

Share this post


Link to post
Share on other sites


If your code is dependent on other code, then yes, anyone else trying to compile it needs both your code and the other code.

 

I was kind of hoping there was a magical visul-studio-setting to avoid that, but seems I'm out of luck :(

 


Another option is to build your code in such a way that it has to be generated before it can be compiled, and the generation step includes detecting missing dependencies and excising code that relies on them. A lot of open-source projects do this.

 

That sounds interesting, how is it practically realized? Any links/tutorials/explanations you can give me?

0

Share this post


Link to post
Share on other sites
A common solution I see is just to wrap all your FBX/etc code in something like
#ifdef MYSDK_ENABLE_FBX
And then the client can choose whether to define that token for your project or not.
2

Share this post


Link to post
Share on other sites


A common solution I see is just to wrap all your FBX/etc code in something like
#ifdef MYSDK_ENABLE_FBX
And then the client can choose whether to define that token for your project or not.

 

That would be acceptable, undefining all the non-used code would be no problem. I would prefer some automated way though - really no way to e.g. read out if a certain system variable like from FBX is set in the preprocessor, and then #define MYSDK_ENABLE_FBX? :D Also, am I not going to also get problems with missing .lib-files etc?

0

Share this post


Link to post
Share on other sites

Another option would be to have separate configurations (i.e. Debug, Release, DebugNoFBX, ReleaseNoFBX) and then set the FBX specific files in your project not to compile under that configuration.

 

Be aware that this can easily get out of hand if you have more than one combination you want to support, so I'm really only mentioning it for the sake of completeness.

 

Another possible route would be just to put the optional functionality in a separate lib that the user can make use of if they want to.

0

Share this post


Link to post
Share on other sites

Also, am I not going to also get problems with missing .lib-files etc?

You can specify the lib files to be linked using pragmas if you like (inside ifdefs)
e.g.
#pragma comment( lib, "foo.lib" )
 

eally no way to e.g. read out if a certain system variable like from FBX is set in the preprocessor, and then #define MYSDK_ENABLE_FBX?

There probably is!...but I've not had experience with it. On every project I've worked on, there's no part of the build process that could possibly vary based on the user's system/environment. They've always deliberately killed off such features to ensure that no matter which team member performs a build, the results will be the same. Doing professional QA is almost impossible otherwise wink.png
I can see that this feature would be very cute though when you're not working under such restrictions biggrin.png

0

Share this post


Link to post
Share on other sites

That would be acceptable, undefining all the non-used code would be no problem. I would prefer some automated way though - really no way to e.g. read out if a certain system variable like from FBX is set in the preprocessor, and then #define MYSDK_ENABLE_FBX? biggrin.png Also, am I not going to also get problems with missing .lib-files etc?

 

There is a way, but it requires some work on your part.

I've done something similar, which is extendable enough to work for what you want.

VS has an option where you can set up a prebuild event. In the prebuild event, call a script file (i use Lua).

In that script file, query the environment variables if a certain variable exists, and if so, generate a file (for instance, when you install the directx sdk, it generates the env. var DXSDK_DIR or some such).

If no env. variables can be queried, then you can manually search the hard drive within the script and find if the installation exists. Whether or not searching a users hard drive is nice/morally ok, i don't know. You decide.

The general idea is that you can generate a header file that you include, and if you find what you want, generate a #define statement with your MACRO of choice that indicates that something exists.

0

Share this post


Link to post
Share on other sites

That would be acceptable, undefining all the non-used code would be no problem. I would prefer some automated way though - really no way to e.g. read out if a certain system variable like from FBX is set in the preprocessor, and then #define MYSDK_ENABLE_FBX? biggrin.png Also, am I not going to also get problems with missing .lib-files etc?

You could use a build system like CMake. I use a CMake script to determine whether the FBX SDK (and some other SDKs) are available on the computer. If the SDK is found, the include paths and libraries are added to the project files as well as a preprocessor flag.

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