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

Problem consuming DLL in VS 2012 (native C++)

5 posts in this topic

My little "adventure" of refreshing my C++ skills with C++11 has been pretty fun, but I keep running into odd issues lol...

I'm having yet another one! I started a solution which contains a DLL project and a Win32 console application. The DLL is going to implement a small native code framework for Windows/DirectX development and the console app is just a testing application to test code and aid in debugging. But for some reason I cannot actually use/consume my DLL in my console app! :-/

In Visual Studio Pro 2008 I remember it being extremely easy... all I had to do was open the application project properties, go to "Common Properties" and click "Add new reference". Then it would show any DLL projects in the solution and I could "reference" them. Voila, it would work... just as easy as adding a reference to a C# project. But this doesn't seem to be the case with VS 2012... Doing this does NOT work. And I can't even change the reference properties like "copy local"; if I do, it just reverses any changes I make back to the default when I click "Apply"...

So I cannot seem to figure out any way to reference/consume my native DLL in my Win32 console app... what gives?! I've tried tweaking around some more project properties but to no avail. I'm not sure what's going on here and why this won't work like it used to in 2008...

Thanks,

--ATC--
0

Share this post


Link to post
Share on other sites
Under certain conditions I get this linker error:

[i][b]Error 1 error LNK1104:[/b] cannot open file 'C:\Users\ATC\Documents\Visual Studio 2012\Projects\ATCWARE\bin\Debug\Win32\ATCFLib.lib' C:\Users\ATC\Documents\Visual Studio 2012\Projects\ATCWARE\src\ConsoleTest\LINK ConsoleTest[/i]

Not sure wth this is about because I'm not even outputting a LIB file, but rather a DLL... And, of course, if I remove the "reference" under "Common Properties" it tells me I have unresolved externals for any function implemented in the DLL... Edited by ATC
0

Share this post


Link to post
Share on other sites
Geez, sometimes I can be a major idiot lol...

It was all because I forgot to use C-linkage and add my custom _DLLEXPORT modifier to things. So the problem is now solved...

If anyone else ever has this problem, here's what you need to do:

[b]1)[/b] Go to Configuration Manager and set the proper project dependencies (in my case "ConsoleTest" depends on "ATCFramework")
[b]2) [/b]Under your project properties of your consuming application, go to "Common Properties" and click "Add Reference"; then reference your DLL
[b]3)[/b] Specify C-type linkage and export your classes, structures and functions like so:

[source lang="cpp"]
extern "C"
{
typedef struct __declspec(dllexport) MY_STRUCT
{
int X, Y; // whatever
} MyStruct, *MyStructPTR;
};
[/source]

You only need to do this in your header files... not in your .c or .cpp implementation files. It's as simple as that! :-)

Have fun,

--ATC--

[b]EDIT: [/b]

Note: Forcing C-linkage is not absolutely [i]necessary [/i]for C++, but you are required to do so to consume something from C code. Otherwise you will get some name mangling and C code won't know what to do. So it's just good practice imo to force C-linkage in these situations. I also think it helps if you ever want to debug at the assembly/machine code level.

As an added note I don't think a function with C-linkage can return a C++ class instance. So watch what you're doing or you'll get weird linker errors that may or may not make any sense. Edited by ATC
2

Share this post


Link to post
Share on other sites
So this thread doesn't get "wasted" though, can anyone tell me how to make my DLL get copied to the output directory of the application when I build my project? If I try to change ANY options under "Common Properties" where I reference my DLL clicking "Apply" just reverses any changes I make back to the defaults. So I can't choose "Copy Local" for example... Edited by ATC
0

Share this post


Link to post
Share on other sites
Fixed... For some reason I couldn't get the xcopy command to work on my post-build event using VS macros... I just had to put the FULL, absolute paths in there and it works, but I'll have to reconfigure if I want to compile on another machine...
0

Share this post


Link to post
Share on other sites
I noticed you have spaces in your path (from the linker error). In your post-build event, did you forget to put "" around the path ("$(ProjectDir)Some\Path")?
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