How to use static library in c++ UWP application?












0















How to create a c++ static library for UWP app?

How to link the above library to UWP app?










share|improve this question





























    0















    How to create a c++ static library for UWP app?

    How to link the above library to UWP app?










    share|improve this question



























      0












      0








      0








      How to create a c++ static library for UWP app?

      How to link the above library to UWP app?










      share|improve this question
















      How to create a c++ static library for UWP app?

      How to link the above library to UWP app?







      c++ uwp static-libraries






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 21 '18 at 1:47







      BombShelley

















      asked Nov 21 '18 at 1:47









      BombShelleyBombShelley

      437




      437
























          1 Answer
          1






          active

          oldest

          votes


















          0















          How to create a c++ static library for UWP app?




          To Create a static library
          1.) Open Visual studio 2017 -> New -> Project... ->
          Visual C++ -> Windows Universal -> Static Library (Universal Windows)
          Your project need to contain two files. 1. yourLibrary.h, 2. yourLibrary.cpp
          (I'm not sure if Static Library that is not UWP static library will work with UWP)
          Example code for yourLibrary.h



          #pragma once
          int minus(int a, int b);
          int mul(int a, int b);


          Example code for yourLibrary.cpp



          #include "pch.h"
          #include "yourLibrary.h"
          int minus(int a, int b){return a-b}
          int mul(int a, int b){return a*b}


          2.) On Solution Explorer on the left. Right click your projrct name-> Properties->vC/C++-> General-> Consume Windows Runtime Extension-> Yes(/ZW)(Why?)

          3.) Build -> Build Solution

          Your Static library is now located at your solution folder(folder that contain .sln)-> Debug-> yourSolutionName

          You should have .lib .pdb .pri in this folder(.lib is your static library and I don't know what .pdb .pri is supposed to be)




          How to link the above library to UWP app?





          1.) Copy .h and .lib from your library project and place them some where under your project folder. e.g. TestApp(contain .sln)/TestApp(Contain .vcxproj)/Mylibrary
          2.) In Visual Studio, Right click your project name -> Add -> Existing Item... -> add .lib and .h
          3.) On pch.h, add this line #include "..MyLibraryyourLibrary.h"(I'm not sure if you can do this somewhere else)

          And now you can use function minus() and mul() in your app.

          I'm just geting into c++ and this is how I make it to work and I might did some unnecessary procedure above. So please correct me.






          share|improve this answer

























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53404207%2fhow-to-use-static-library-in-c-uwp-application%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0















            How to create a c++ static library for UWP app?




            To Create a static library
            1.) Open Visual studio 2017 -> New -> Project... ->
            Visual C++ -> Windows Universal -> Static Library (Universal Windows)
            Your project need to contain two files. 1. yourLibrary.h, 2. yourLibrary.cpp
            (I'm not sure if Static Library that is not UWP static library will work with UWP)
            Example code for yourLibrary.h



            #pragma once
            int minus(int a, int b);
            int mul(int a, int b);


            Example code for yourLibrary.cpp



            #include "pch.h"
            #include "yourLibrary.h"
            int minus(int a, int b){return a-b}
            int mul(int a, int b){return a*b}


            2.) On Solution Explorer on the left. Right click your projrct name-> Properties->vC/C++-> General-> Consume Windows Runtime Extension-> Yes(/ZW)(Why?)

            3.) Build -> Build Solution

            Your Static library is now located at your solution folder(folder that contain .sln)-> Debug-> yourSolutionName

            You should have .lib .pdb .pri in this folder(.lib is your static library and I don't know what .pdb .pri is supposed to be)




            How to link the above library to UWP app?





            1.) Copy .h and .lib from your library project and place them some where under your project folder. e.g. TestApp(contain .sln)/TestApp(Contain .vcxproj)/Mylibrary
            2.) In Visual Studio, Right click your project name -> Add -> Existing Item... -> add .lib and .h
            3.) On pch.h, add this line #include "..MyLibraryyourLibrary.h"(I'm not sure if you can do this somewhere else)

            And now you can use function minus() and mul() in your app.

            I'm just geting into c++ and this is how I make it to work and I might did some unnecessary procedure above. So please correct me.






            share|improve this answer






























              0















              How to create a c++ static library for UWP app?




              To Create a static library
              1.) Open Visual studio 2017 -> New -> Project... ->
              Visual C++ -> Windows Universal -> Static Library (Universal Windows)
              Your project need to contain two files. 1. yourLibrary.h, 2. yourLibrary.cpp
              (I'm not sure if Static Library that is not UWP static library will work with UWP)
              Example code for yourLibrary.h



              #pragma once
              int minus(int a, int b);
              int mul(int a, int b);


              Example code for yourLibrary.cpp



              #include "pch.h"
              #include "yourLibrary.h"
              int minus(int a, int b){return a-b}
              int mul(int a, int b){return a*b}


              2.) On Solution Explorer on the left. Right click your projrct name-> Properties->vC/C++-> General-> Consume Windows Runtime Extension-> Yes(/ZW)(Why?)

              3.) Build -> Build Solution

              Your Static library is now located at your solution folder(folder that contain .sln)-> Debug-> yourSolutionName

              You should have .lib .pdb .pri in this folder(.lib is your static library and I don't know what .pdb .pri is supposed to be)




              How to link the above library to UWP app?





              1.) Copy .h and .lib from your library project and place them some where under your project folder. e.g. TestApp(contain .sln)/TestApp(Contain .vcxproj)/Mylibrary
              2.) In Visual Studio, Right click your project name -> Add -> Existing Item... -> add .lib and .h
              3.) On pch.h, add this line #include "..MyLibraryyourLibrary.h"(I'm not sure if you can do this somewhere else)

              And now you can use function minus() and mul() in your app.

              I'm just geting into c++ and this is how I make it to work and I might did some unnecessary procedure above. So please correct me.






              share|improve this answer




























                0












                0








                0








                How to create a c++ static library for UWP app?




                To Create a static library
                1.) Open Visual studio 2017 -> New -> Project... ->
                Visual C++ -> Windows Universal -> Static Library (Universal Windows)
                Your project need to contain two files. 1. yourLibrary.h, 2. yourLibrary.cpp
                (I'm not sure if Static Library that is not UWP static library will work with UWP)
                Example code for yourLibrary.h



                #pragma once
                int minus(int a, int b);
                int mul(int a, int b);


                Example code for yourLibrary.cpp



                #include "pch.h"
                #include "yourLibrary.h"
                int minus(int a, int b){return a-b}
                int mul(int a, int b){return a*b}


                2.) On Solution Explorer on the left. Right click your projrct name-> Properties->vC/C++-> General-> Consume Windows Runtime Extension-> Yes(/ZW)(Why?)

                3.) Build -> Build Solution

                Your Static library is now located at your solution folder(folder that contain .sln)-> Debug-> yourSolutionName

                You should have .lib .pdb .pri in this folder(.lib is your static library and I don't know what .pdb .pri is supposed to be)




                How to link the above library to UWP app?





                1.) Copy .h and .lib from your library project and place them some where under your project folder. e.g. TestApp(contain .sln)/TestApp(Contain .vcxproj)/Mylibrary
                2.) In Visual Studio, Right click your project name -> Add -> Existing Item... -> add .lib and .h
                3.) On pch.h, add this line #include "..MyLibraryyourLibrary.h"(I'm not sure if you can do this somewhere else)

                And now you can use function minus() and mul() in your app.

                I'm just geting into c++ and this is how I make it to work and I might did some unnecessary procedure above. So please correct me.






                share|improve this answer
















                How to create a c++ static library for UWP app?




                To Create a static library
                1.) Open Visual studio 2017 -> New -> Project... ->
                Visual C++ -> Windows Universal -> Static Library (Universal Windows)
                Your project need to contain two files. 1. yourLibrary.h, 2. yourLibrary.cpp
                (I'm not sure if Static Library that is not UWP static library will work with UWP)
                Example code for yourLibrary.h



                #pragma once
                int minus(int a, int b);
                int mul(int a, int b);


                Example code for yourLibrary.cpp



                #include "pch.h"
                #include "yourLibrary.h"
                int minus(int a, int b){return a-b}
                int mul(int a, int b){return a*b}


                2.) On Solution Explorer on the left. Right click your projrct name-> Properties->vC/C++-> General-> Consume Windows Runtime Extension-> Yes(/ZW)(Why?)

                3.) Build -> Build Solution

                Your Static library is now located at your solution folder(folder that contain .sln)-> Debug-> yourSolutionName

                You should have .lib .pdb .pri in this folder(.lib is your static library and I don't know what .pdb .pri is supposed to be)




                How to link the above library to UWP app?





                1.) Copy .h and .lib from your library project and place them some where under your project folder. e.g. TestApp(contain .sln)/TestApp(Contain .vcxproj)/Mylibrary
                2.) In Visual Studio, Right click your project name -> Add -> Existing Item... -> add .lib and .h
                3.) On pch.h, add this line #include "..MyLibraryyourLibrary.h"(I'm not sure if you can do this somewhere else)

                And now you can use function minus() and mul() in your app.

                I'm just geting into c++ and this is how I make it to work and I might did some unnecessary procedure above. So please correct me.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 21 '18 at 2:17

























                answered Nov 21 '18 at 1:47









                BombShelleyBombShelley

                437




                437
































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53404207%2fhow-to-use-static-library-in-c-uwp-application%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    How to change which sound is reproduced for terminal bell?

                    Can I use Tabulator js library in my java Spring + Thymeleaf project?

                    Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents