Cannot link to Boost library with MSVC: Cannot open file *.lib












0















I'm using CLion and CMake to link with Boost and as toolchain I chose the MSVC compiler:



My architecture is configured as amd64 since I'm running a 64-bit system (the default of x86 only tries to find the 32-bit versions of Boost which I don't want).



Furthermore I compiled the 64-bit libraries using this guide. I setup my CMake file respectively:



set(BOOST_ROOT "C:/local/boost_1_69_0_b1_rc3")
set(BOOST_LIBRARYDIR "C:/local/boost_1_69_0_b1_rc3/stage/x64/lib")
set(BOOST_INCLUDEDIR "C:/local/boost_1_69_0_b1_rc3/boost")


My main.cpp compiles just fine but I'm getting a linker error:



====================[ Build | BoostTesting | Debug ]============================
C:UsersUserAppDataLocalJetBrainsToolboxappsCLionch-0183.4284.104bincmakewinbincmake.exe --build D:CppBoostTestingcmake-build-debug --target BoostTesting --
[ 50%] Linking CXX executable BoostTesting.exe
LINK Pass 1: command "C:PROGRA~2MICROS~32017ENTERP~1VCToolsMSVC1415~1.267binHostx64x64link.exe /nologo @CMakeFilesBoostTesting.dirobjects1.rsp /out:BoostTesting.exe /implib:BoostTesting.lib /pdb:D:CppBoostTestingcmake-build-debugBoostTesting.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console C:localboost_1_69_0_b1_rc3stagex64liblibboost_filesystem-vc141-mt-gd-x64-1_69.lib C:localboost_1_69_0_b1_rc3stagex64liblibboost_system-vc141-mt-x64-1_69.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFilesBoostTesting.dir/intermediate.manifest CMakeFilesBoostTesting.dir/manifest.res" failed (exit code 1104) with the following output:
LINK : fatal error LNK1104: cannot open file 'libboost_iostreams-vc141-mt-gd-x64-1_69.lib'
NMAKE : fatal error U1077: 'C:UsersUserAppDataLocalJetBrainsToolboxappsCLionch-0183.4284.104bincmakewinbincmake.exe' : return code '0xffffffff'
Stop.
NMAKE : fatal error U1077: '"C:Program Files (x86)Microsoft Visual Studio2017EnterpriseVCToolsMSVC14.15.26726binHostX64x64nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:Program Files (x86)Microsoft Visual Studio2017EnterpriseVCToolsMSVC14.15.26726binHostX64x64nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:Program Files (x86)Microsoft Visual Studio2017EnterpriseVCToolsMSVC14.15.26726binHostX64x64nmake.exe"' : return code '0x2'
Stop.


When using x86_amd64 as architecture it also fails to link. The other architectures don't make sense for my PC:



Using the pre-compiled binaries from here also fails to link. How to fix this linking problem?










share|improve this question



























    0















    I'm using CLion and CMake to link with Boost and as toolchain I chose the MSVC compiler:



    My architecture is configured as amd64 since I'm running a 64-bit system (the default of x86 only tries to find the 32-bit versions of Boost which I don't want).



    Furthermore I compiled the 64-bit libraries using this guide. I setup my CMake file respectively:



    set(BOOST_ROOT "C:/local/boost_1_69_0_b1_rc3")
    set(BOOST_LIBRARYDIR "C:/local/boost_1_69_0_b1_rc3/stage/x64/lib")
    set(BOOST_INCLUDEDIR "C:/local/boost_1_69_0_b1_rc3/boost")


    My main.cpp compiles just fine but I'm getting a linker error:



    ====================[ Build | BoostTesting | Debug ]============================
    C:UsersUserAppDataLocalJetBrainsToolboxappsCLionch-0183.4284.104bincmakewinbincmake.exe --build D:CppBoostTestingcmake-build-debug --target BoostTesting --
    [ 50%] Linking CXX executable BoostTesting.exe
    LINK Pass 1: command "C:PROGRA~2MICROS~32017ENTERP~1VCToolsMSVC1415~1.267binHostx64x64link.exe /nologo @CMakeFilesBoostTesting.dirobjects1.rsp /out:BoostTesting.exe /implib:BoostTesting.lib /pdb:D:CppBoostTestingcmake-build-debugBoostTesting.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console C:localboost_1_69_0_b1_rc3stagex64liblibboost_filesystem-vc141-mt-gd-x64-1_69.lib C:localboost_1_69_0_b1_rc3stagex64liblibboost_system-vc141-mt-x64-1_69.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFilesBoostTesting.dir/intermediate.manifest CMakeFilesBoostTesting.dir/manifest.res" failed (exit code 1104) with the following output:
    LINK : fatal error LNK1104: cannot open file 'libboost_iostreams-vc141-mt-gd-x64-1_69.lib'
    NMAKE : fatal error U1077: 'C:UsersUserAppDataLocalJetBrainsToolboxappsCLionch-0183.4284.104bincmakewinbincmake.exe' : return code '0xffffffff'
    Stop.
    NMAKE : fatal error U1077: '"C:Program Files (x86)Microsoft Visual Studio2017EnterpriseVCToolsMSVC14.15.26726binHostX64x64nmake.exe"' : return code '0x2'
    Stop.
    NMAKE : fatal error U1077: '"C:Program Files (x86)Microsoft Visual Studio2017EnterpriseVCToolsMSVC14.15.26726binHostX64x64nmake.exe"' : return code '0x2'
    Stop.
    NMAKE : fatal error U1077: '"C:Program Files (x86)Microsoft Visual Studio2017EnterpriseVCToolsMSVC14.15.26726binHostX64x64nmake.exe"' : return code '0x2'
    Stop.


    When using x86_amd64 as architecture it also fails to link. The other architectures don't make sense for my PC:



    Using the pre-compiled binaries from here also fails to link. How to fix this linking problem?










    share|improve this question

























      0












      0








      0








      I'm using CLion and CMake to link with Boost and as toolchain I chose the MSVC compiler:



      My architecture is configured as amd64 since I'm running a 64-bit system (the default of x86 only tries to find the 32-bit versions of Boost which I don't want).



      Furthermore I compiled the 64-bit libraries using this guide. I setup my CMake file respectively:



      set(BOOST_ROOT "C:/local/boost_1_69_0_b1_rc3")
      set(BOOST_LIBRARYDIR "C:/local/boost_1_69_0_b1_rc3/stage/x64/lib")
      set(BOOST_INCLUDEDIR "C:/local/boost_1_69_0_b1_rc3/boost")


      My main.cpp compiles just fine but I'm getting a linker error:



      ====================[ Build | BoostTesting | Debug ]============================
      C:UsersUserAppDataLocalJetBrainsToolboxappsCLionch-0183.4284.104bincmakewinbincmake.exe --build D:CppBoostTestingcmake-build-debug --target BoostTesting --
      [ 50%] Linking CXX executable BoostTesting.exe
      LINK Pass 1: command "C:PROGRA~2MICROS~32017ENTERP~1VCToolsMSVC1415~1.267binHostx64x64link.exe /nologo @CMakeFilesBoostTesting.dirobjects1.rsp /out:BoostTesting.exe /implib:BoostTesting.lib /pdb:D:CppBoostTestingcmake-build-debugBoostTesting.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console C:localboost_1_69_0_b1_rc3stagex64liblibboost_filesystem-vc141-mt-gd-x64-1_69.lib C:localboost_1_69_0_b1_rc3stagex64liblibboost_system-vc141-mt-x64-1_69.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFilesBoostTesting.dir/intermediate.manifest CMakeFilesBoostTesting.dir/manifest.res" failed (exit code 1104) with the following output:
      LINK : fatal error LNK1104: cannot open file 'libboost_iostreams-vc141-mt-gd-x64-1_69.lib'
      NMAKE : fatal error U1077: 'C:UsersUserAppDataLocalJetBrainsToolboxappsCLionch-0183.4284.104bincmakewinbincmake.exe' : return code '0xffffffff'
      Stop.
      NMAKE : fatal error U1077: '"C:Program Files (x86)Microsoft Visual Studio2017EnterpriseVCToolsMSVC14.15.26726binHostX64x64nmake.exe"' : return code '0x2'
      Stop.
      NMAKE : fatal error U1077: '"C:Program Files (x86)Microsoft Visual Studio2017EnterpriseVCToolsMSVC14.15.26726binHostX64x64nmake.exe"' : return code '0x2'
      Stop.
      NMAKE : fatal error U1077: '"C:Program Files (x86)Microsoft Visual Studio2017EnterpriseVCToolsMSVC14.15.26726binHostX64x64nmake.exe"' : return code '0x2'
      Stop.


      When using x86_amd64 as architecture it also fails to link. The other architectures don't make sense for my PC:



      Using the pre-compiled binaries from here also fails to link. How to fix this linking problem?










      share|improve this question














      I'm using CLion and CMake to link with Boost and as toolchain I chose the MSVC compiler:



      My architecture is configured as amd64 since I'm running a 64-bit system (the default of x86 only tries to find the 32-bit versions of Boost which I don't want).



      Furthermore I compiled the 64-bit libraries using this guide. I setup my CMake file respectively:



      set(BOOST_ROOT "C:/local/boost_1_69_0_b1_rc3")
      set(BOOST_LIBRARYDIR "C:/local/boost_1_69_0_b1_rc3/stage/x64/lib")
      set(BOOST_INCLUDEDIR "C:/local/boost_1_69_0_b1_rc3/boost")


      My main.cpp compiles just fine but I'm getting a linker error:



      ====================[ Build | BoostTesting | Debug ]============================
      C:UsersUserAppDataLocalJetBrainsToolboxappsCLionch-0183.4284.104bincmakewinbincmake.exe --build D:CppBoostTestingcmake-build-debug --target BoostTesting --
      [ 50%] Linking CXX executable BoostTesting.exe
      LINK Pass 1: command "C:PROGRA~2MICROS~32017ENTERP~1VCToolsMSVC1415~1.267binHostx64x64link.exe /nologo @CMakeFilesBoostTesting.dirobjects1.rsp /out:BoostTesting.exe /implib:BoostTesting.lib /pdb:D:CppBoostTestingcmake-build-debugBoostTesting.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console C:localboost_1_69_0_b1_rc3stagex64liblibboost_filesystem-vc141-mt-gd-x64-1_69.lib C:localboost_1_69_0_b1_rc3stagex64liblibboost_system-vc141-mt-x64-1_69.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFilesBoostTesting.dir/intermediate.manifest CMakeFilesBoostTesting.dir/manifest.res" failed (exit code 1104) with the following output:
      LINK : fatal error LNK1104: cannot open file 'libboost_iostreams-vc141-mt-gd-x64-1_69.lib'
      NMAKE : fatal error U1077: 'C:UsersUserAppDataLocalJetBrainsToolboxappsCLionch-0183.4284.104bincmakewinbincmake.exe' : return code '0xffffffff'
      Stop.
      NMAKE : fatal error U1077: '"C:Program Files (x86)Microsoft Visual Studio2017EnterpriseVCToolsMSVC14.15.26726binHostX64x64nmake.exe"' : return code '0x2'
      Stop.
      NMAKE : fatal error U1077: '"C:Program Files (x86)Microsoft Visual Studio2017EnterpriseVCToolsMSVC14.15.26726binHostX64x64nmake.exe"' : return code '0x2'
      Stop.
      NMAKE : fatal error U1077: '"C:Program Files (x86)Microsoft Visual Studio2017EnterpriseVCToolsMSVC14.15.26726binHostX64x64nmake.exe"' : return code '0x2'
      Stop.


      When using x86_amd64 as architecture it also fails to link. The other architectures don't make sense for my PC:



      Using the pre-compiled binaries from here also fails to link. How to fix this linking problem?







      c++ windows visual-c++ boost






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 22 '18 at 20:30









      BullyWiiPlazaBullyWiiPlaza

      6,06334660




      6,06334660
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Just setting BOOST_ROOT in CMakeLists.txt



          set(BOOST_ROOT "C:/local/boost_1_69_0_b1_rc3")


          and using amd64 as the architecture surprisingly did the trick now. Using MSVC with CMake is better supported with Visual Studio (quite obviously) and linking to Boost was no issue anymore. Now the build also works from CLion but Visual Studio should be preferred until CLion maybe gets better MSVC integration.






          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%2f53437667%2fcannot-link-to-boost-library-with-msvc-cannot-open-file-lib%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














            Just setting BOOST_ROOT in CMakeLists.txt



            set(BOOST_ROOT "C:/local/boost_1_69_0_b1_rc3")


            and using amd64 as the architecture surprisingly did the trick now. Using MSVC with CMake is better supported with Visual Studio (quite obviously) and linking to Boost was no issue anymore. Now the build also works from CLion but Visual Studio should be preferred until CLion maybe gets better MSVC integration.






            share|improve this answer




























              0














              Just setting BOOST_ROOT in CMakeLists.txt



              set(BOOST_ROOT "C:/local/boost_1_69_0_b1_rc3")


              and using amd64 as the architecture surprisingly did the trick now. Using MSVC with CMake is better supported with Visual Studio (quite obviously) and linking to Boost was no issue anymore. Now the build also works from CLion but Visual Studio should be preferred until CLion maybe gets better MSVC integration.






              share|improve this answer


























                0












                0








                0







                Just setting BOOST_ROOT in CMakeLists.txt



                set(BOOST_ROOT "C:/local/boost_1_69_0_b1_rc3")


                and using amd64 as the architecture surprisingly did the trick now. Using MSVC with CMake is better supported with Visual Studio (quite obviously) and linking to Boost was no issue anymore. Now the build also works from CLion but Visual Studio should be preferred until CLion maybe gets better MSVC integration.






                share|improve this answer













                Just setting BOOST_ROOT in CMakeLists.txt



                set(BOOST_ROOT "C:/local/boost_1_69_0_b1_rc3")


                and using amd64 as the architecture surprisingly did the trick now. Using MSVC with CMake is better supported with Visual Studio (quite obviously) and linking to Boost was no issue anymore. Now the build also works from CLion but Visual Studio should be preferred until CLion maybe gets better MSVC integration.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Dec 9 '18 at 12:44









                BullyWiiPlazaBullyWiiPlaza

                6,06334660




                6,06334660






























                    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%2f53437667%2fcannot-link-to-boost-library-with-msvc-cannot-open-file-lib%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

                    404 Error Contact Form 7 ajax form submitting

                    How to know if a Active Directory user can login interactively

                    TypeError: fit_transform() missing 1 required positional argument: 'X'