locked
C++ Library for Metro game

    Question

  • Still fairly new C++, I'm trying to create a simple "library" that I can use for my Windows Store games. It's a DirectX library to assist in creating games. After reading a previous thread, I learned that I need to make the project a Windows Runtime Component. So that's what I chose, when stating the project. Now, the library is built and runs successfully, and I need to use it in a game.

    I'm making a C++/DirectX game that needs to use this library, but I have no clue how to include it into the game. I went to the references of the game, and added it to the references. But, when I try to include any of the files into a game file, they're not there.

    Like I said, I'm new to this, so please be easy in your description of how to get this library working in a game.

    Thanks.

    Tuesday, January 29, 2013 5:05 PM

Answers

  • If your game is written entirely in C++/DirectX, then you really don't need to author a Windows Runtime Components. You can just stick with a standard C++ library as long as it is built using the Windows Store app API partition to ensure you don't use 'unsafe' APIs. The key value in authoring Windows Runtime Components is being able to consume them from JavaScript or C# easily.

    DirectXTK is a C++ static library for use in Windows Store apps (as well as Win32 desktop apps and Windows phone 8 apps). You can look at the instructions I have listed there for adding it to a project to help you work this out.

    Also, you may find this article informative.

    Tuesday, January 29, 2013 8:13 PM

All replies

  • If your game is written entirely in C++/DirectX, then you really don't need to author a Windows Runtime Components. You can just stick with a standard C++ library as long as it is built using the Windows Store app API partition to ensure you don't use 'unsafe' APIs. The key value in authoring Windows Runtime Components is being able to consume them from JavaScript or C# easily.

    DirectXTK is a C++ static library for use in Windows Store apps (as well as Win32 desktop apps and Windows phone 8 apps). You can look at the instructions I have listed there for adding it to a project to help you work this out.

    Also, you may find this article informative.

    Tuesday, January 29, 2013 8:13 PM
  • Is there any way for me to convert the Windows Runtime Component into a static library, because I have already made it. Thanks. 

    [url=http://catalog.create.msdn.com/en-US/GameDetails.aspx?catalogEntryId=5cbacba6-05c2-4c33-9005-6cc80c8d5753&type=1]Bible Trivia Avatar Edition[/url], currently in review.

    Tuesday, January 29, 2013 8:32 PM
  • Alright, I've converted the Windows Runtime Component to a static library and I added it as a reference. Also, I added it into the Additional includes of my project. I look into the external dependencies of my game and there's MyLibrary.winmd, so it looks like it's working.

    But, now what do I do? I'm trying to include some files from the library into a file for my game, and I see nothing.  What now?

    Thanks.


    [url=http://catalog.create.msdn.com/en-US/GameDetails.aspx?catalogEntryId=5cbacba6-05c2-4c33-9005-6cc80c8d5753&type=1]Bible Trivia Avatar Edition[/url], currently in review.


    Tuesday, January 29, 2013 9:47 PM
  • If you have converted it to a static library, then adding it as a reference is not what you want to do. Remove that reference. MyLibrary.winmd is still a RT component, not a static library. When you build the static library project, it will create a MyLibrary.lib file in .../solutionName/debug/projectName folder.

    Add the source file folder to the 'Additional Includes Directories' of the c++->General properties , add the folder that has the MyLibrary.lib to the 'Additional Library Directories' in the Linker->General properties. And add the name of the library (MyLibrary.lib) to the 'Additional Dependencies' section of the Linker->Input properties.  


    Unlock The *I don't use 3 angles in a Vector3 for rotations anymore* Achievement Here

    Wednesday, January 30, 2013 1:50 AM
  • I've got everything changed, except I'm getting linker errors now, I've added the folder with the library file to the additional include directories and I've added the .lib to the additional dependencies, but still, I get linker errors for anything I attempt to use in the game. I'm also pretty sure it's finding it, because at first I was just being told that my game couldn't open myLibrary.lib until I did what you suggested with the additional directories, now I'm no longer getting that error just the linker errors.


    [url=http://catalog.create.msdn.com/en-US/GameDetails.aspx?catalogEntryId=5cbacba6-05c2-4c33-9005-6cc80c8d5753&type=1]Bible Trivia Avatar Edition[/url], currently in review.

    Wednesday, January 30, 2013 4:55 AM
  • BTW, there is a simple DirectXTK Windows Store app sample that you might want to look at for the various settings....

    http://code.msdn.microsoft.com/DirectXTK-Simple-Sample-608bc274

    Wednesday, January 30, 2013 9:58 PM
  • Well, does anyone know why I'm still getting linker errors even after including the .lib file?

    [url=http://catalog.create.msdn.com/en-US/GameDetails.aspx?catalogEntryId=5cbacba6-05c2-4c33-9005-6cc80c8d5753&type=1]Bible Trivia Avatar Edition[/url], currently in review.

    Thursday, January 31, 2013 1:37 PM
  • I've got everything changed, except I'm getting linker errors now, I've added the folder with the library file to the additional include directories


    Add the folder with the source files (the *.h files) to the 'additional includes', not the folder with the library file. that goes in the linker section.


    Unlock The *I don't use 3 angles in a Vector3 for rotations anymore* Achievement Here


    • Edited by Shazen Thursday, January 31, 2013 9:55 PM
    Thursday, January 31, 2013 9:54 PM
  • Alright, I'm sorry:

    The "Additional includes" under C/C++ has the location of the .h files.

    The "Additional library Directories" has the path to the library file.

    The "Additional Dependencies" has MyLibrary.lib appended to the list.

    Despite all of this, I'm still getting linker errors.


    [url=http://catalog.create.msdn.com/en-US/GameDetails.aspx?catalogEntryId=5cbacba6-05c2-4c33-9005-6cc80c8d5753&type=1]Bible Trivia Avatar Edition[/url], currently in review.

    Thursday, January 31, 2013 10:31 PM
  • Thank you for everyone's help. The final problem, after learning from Chuck Walburn's first post, was that my project was not a static library. I thought I recreated it as a static library, but something must of went wrong.

    [url=http://catalog.create.msdn.com/en-US/GameDetails.aspx?catalogEntryId=5cbacba6-05c2-4c33-9005-6cc80c8d5753&type=1]Bible Trivia Avatar Edition[/url], currently in review.

    Saturday, February 2, 2013 5:48 AM