locked
Linking a library

    Question

  • I feel like an idiot just having to ask this, but I'm still new to C++.  Also, I come from a nice and cushy C# background, where everything is magically done for you.
    So, I have a library that I want to hook to my C++/DirectX "metro" game.  It's my own C++ library and it compiles fine.  But, apparently, liking two projects together is a much different story for C++ than it is for C#.  So, I've already learned that my project needs to be a dynamic library. (I had to study up on what DLLs were)
    And I set it as a DLL in the configurations properties.  But, after trying to reference the library through add reference, then trying to connect it through the linker's additional dependencies, I still find my "metro" game having linker errors because it can't find the library files.

    Any help. 

    Sunday, October 7, 2012 2:34 AM

All replies

  • Try using LoadPackagedLibrary function.

    LoadPackagedLibrary

    DLLs for Windows Store Apps

    Sunday, October 7, 2012 4:17 AM
  • I've read up and I'm wondering if I need to add __declspec(dllexport) to all of the methods and functions in my library, or is there a better approach?  Maybe I shouldn't even be using DLLs, maybe I should be making a static library.  Honestly, all I want to do is put my commonly used classes and functions into a library (included in the solution) so that I can reuse them in each game.

    Sunday, October 7, 2012 1:46 PM
  • To reference a standard DLL project from the same solution

      • Open the shortcut menu for the project that will use the DLL and then choose Properties. On the Common Properties page, choose the Add New Reference button.

      • In the left pane, select Solution, and then select the appropriate check box in the right pane.

      • In your source code files, add a #include statement for the DLL header file, as needed.

    This is what I've done, but I still get linker errors.

    Sunday, October 7, 2012 4:02 PM
  • Hi,

    Did you forget to create a Windows Store type DLL?
    Based on that document, we should create a Windows Store DLL from template, even though we want to migrate the old Win32 type DLL.

    Meanwhile, would you please show us the error message of link?
     
    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, October 10, 2012 7:24 AM
  • Unfortunately, I can't show you the error message any more, as I have grouped both projects into one.  I'm on quite a strict deadline, and I have decided I'll separate the library in the next project.

    But, I can tell you that it was a standard unresolved external error, as if it could not find the definition of the methods.
    An no, this is a Windows Store Library template, I've never really done any Win32 programming.  At least not any on a to-be-released project.  But I am at odds to whether I should create a DLL or a static library.

    Actually, the library started out as the Windows Store (Metro) Direct3D template.  But, then under the configurations I changed the output to DLL instead of EXE.  I tried creating a Windows Store library template for the library, but I found out that using the Direct3D template was easier.  I figured it would be the same as the DLL template.

    Wednesday, October 10, 2012 10:27 PM