Ошибка соединения LNK1104 при использовании CMake и vc142 с надстройкой - PullRequest
0 голосов
/ 11 октября 2019

Что я пропустил?

Я не могу создать простой проект с использованием CMake + vc142 + boost 1.71.1 на хосте Windows. Что забавно, этот проект, удаленно построенный на WSL, скомпилирован и работает правильно. Ускоренная установка корректна, новый Vcproj с дополнительными включениями и библиотеками, связанными с ENV{BOOST_ROOT} и ENV{BOOST_INCLUDEDIR} dirs, создает и работает правильно.

[Редактировать] Добавление набора (Boost_USE_STATIC_LIBS ON) в cmake работает, как @vreсказал. Но использование этого stackoverflow.com/questions/28887680/… заканчивается: соединение успешно, но во время выполнения оно заканчивается: «Процесс завершен с кодом выхода -1073741515 (0xC0000135)» *

[Edit2] Использование встроенного бустаиз: https://sourceforge.net/projects/boost/files/boost-binaries/1.71.0/ дает те же результаты;

[Edit3] Эффект на Debian WSL, с set (Boost_USE_STATIC_LIBS OFF CACHE BOOL "use static libraries from Boost"):

/tmp/tmp.75syfbaPik/cmake-build-debug-wsl-debian/untitled
Hello, World!=D
terminate called after throwing an instance of 'boost::filesystem::filesystem_error'
  what():  boost::filesystem::file_size: No such file or directory: "c:\boost_1_71_0.7z"

Process finished with exit code 134

[РЕШЕНИЕ] Добавить Boost "... / stage / lib" (например, C: \ boost_1_71_0 \ stage| lib) в Env PATH;

Статическое связывание с использованием ускорения:

set(Boost_USE_STATIC_LIBS ON)

Динамическое связывание с использованием ускорения:

if (WIN32)
    # disable autolinking in boost
    add_definitions( -DBOOST_ALL_NO_LIB )

    # force all boost libraries to dynamic link (we already disabled
    # autolinking, so I don't know why we need this, but we do!)
    add_definitions( -DBOOST_ALL_DYN_LINK )
endif()
set (Boost_USE_STATIC_LIBS OFF CACHE BOOL "use static libraries from Boost")

Helpfull

CMake:

cmake_minimum_required(VERSION 3.13)
project(untitled
        VERSION 0.0.0
        LANGUAGES CXX
        )
set(CMAKE_CXX_STANDARD 17)

set(Boost_DEBUG 1)
find_package(Boost 1.71.0 REQUIRED COMPONENTS filesystem)

add_executable(untitled main.cpp)
target_link_libraries(untitled Boost::filesystem)

main.cpp:

#include <iostream>
#include <boost/filesystem.hpp>
using namespace boost::filesystem;

int main() {
    std::cout << "Hello, World!=D" << std::endl;
    std::cout << "c:\\boost_1_71_0.7z" << " " << file_size("c:\\boost_1_71_0.7z") << '\n';
    return 0;
}

CMake log от Clion:

"C:\Program Files\JetBrains\CLion 2019.2.3\bin\cmake\win\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - NMake Makefiles" D:\untitled
-- [ C:/Program Files/JetBrains/CLion 2019.2.3/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:1446 ] _boost_TEST_VERSIONS = "1.71.0;1.71"
-- [ C:/Program Files/JetBrains/CLion 2019.2.3/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:1447 ] Boost_USE_MULTITHREADED = "TRUE"
-- [ C:/Program Files/JetBrains/CLion 2019.2.3/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:1448 ] Boost_USE_STATIC_LIBS = <unset>
-- [ C:/Program Files/JetBrains/CLion 2019.2.3/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:1449 ] Boost_USE_STATIC_RUNTIME = <unset>
-- [ C:/Program Files/JetBrains/CLion 2019.2.3/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:1450 ] Boost_ADDITIONAL_VERSIONS = <unset>
-- [ C:/Program Files/JetBrains/CLion 2019.2.3/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:1451 ] Boost_NO_SYSTEM_PATHS = <unset>
-- [ C:/Program Files/JetBrains/CLion 2019.2.3/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:1520 ] BOOST_ROOT = <unset>
-- [ C:/Program Files/JetBrains/CLion 2019.2.3/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:1521 ] ENV{BOOST_ROOT} = "C:\boost_1_71_0"
-- [ C:/Program Files/JetBrains/CLion 2019.2.3/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:1522 ] BOOST_INCLUDEDIR = <unset>
-- [ C:/Program Files/JetBrains/CLion 2019.2.3/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:1523 ] ENV{BOOST_INCLUDEDIR} = "C:\boost_1_71_0"
-- [ C:/Program Files/JetBrains/CLion 2019.2.3/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:1524 ] BOOST_LIBRARYDIR = <unset>
-- [ C:/Program Files/JetBrains/CLion 2019.2.3/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:1525 ] ENV{BOOST_LIBRARYDIR} = "C:\boost_1_71_0\stage\lib"
-- [ C:/Program Files/JetBrains/CLion 2019.2.3/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:1613 ] location of version.hpp: C:/boost_1_71_0/boost/version.hpp
-- [ C:/Program Files/JetBrains/CLion 2019.2.3/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:1653 ] Boost_VERSION = "107100"
-- [ C:/Program Files/JetBrains/CLion 2019.2.3/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:1654 ] Boost_VERSION_STRING = "1.71.0"
-- [ C:/Program Files/JetBrains/CLion 2019.2.3/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:1655 ] Boost_VERSION_MACRO = "107100"
-- [ C:/Program Files/JetBrains/CLion 2019.2.3/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:1656 ] Boost_VERSION_MAJOR = "1"
-- [ C:/Program Files/JetBrains/CLion 2019.2.3/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:1657 ] Boost_VERSION_MINOR = "71"
-- [ C:/Program Files/JetBrains/CLion 2019.2.3/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:1658 ] Boost_VERSION_PATCH = "0"
-- [ C:/Program Files/JetBrains/CLion 2019.2.3/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:1659 ] Boost_VERSION_COUNT = "3"
-- [ C:/Program Files/JetBrains/CLion 2019.2.3/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:1676 ] Boost_LIB_PREFIX = ""
-- [ C:/Program Files/JetBrains/CLion 2019.2.3/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:1677 ] Boost_NAMESPACE = "boost"
-- [ C:/Program Files/JetBrains/CLion 2019.2.3/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:787 ] _boost_COMPILER = "-vc142;-vc141;-vc140" (guessed)
-- [ C:/Program Files/JetBrains/CLion 2019.2.3/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:1713 ] _boost_MULTITHREADED = "-mt"
-- [ C:/Program Files/JetBrains/CLion 2019.2.3/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:1790 ] _boost_ARCHITECTURE_TAG = "-x32" (detected)
-- [ C:/Program Files/JetBrains/CLion 2019.2.3/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:1794 ] _boost_RELEASE_ABI_TAG = "-"
-- [ C:/Program Files/JetBrains/CLion 2019.2.3/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:1795 ] _boost_DEBUG_ABI_TAG = "-gd"
-- [ C:/Program Files/JetBrains/CLion 2019.2.3/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:1855 ] _boost_LIBRARY_SEARCH_DIRS_RELEASE = "C:/boost_1_71_0/stage/lib;NO_DEFAULT_PATH;NO_CMAKE_FIND_ROOT_PATH"
-- [ C:/Program Files/JetBrains/CLion 2019.2.3/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:1856 ] _boost_LIBRARY_SEARCH_DIRS_DEBUG = "C:/boost_1_71_0/stage/lib;NO_DEFAULT_PATH;NO_CMAKE_FIND_ROOT_PATH"
-- [ C:/Program Files/JetBrains/CLion 2019.2.3/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:2040 ] Searching for FILESYSTEM_LIBRARY_RELEASE: boost_filesystem-vc142-mt-x32-1_71;boost_filesystem-vc142-mt-x32;boost_filesystem-vc142-mt;boost_filesystem-vc141-mt-x32-1_71;boost_filesystem-vc141-mt-x32;boost_filesystem-vc141-mt;boost_filesystem-vc140-mt-x32-1_71;boost_filesystem-vc140-mt-x32;boost_filesystem-vc140-mt;boost_filesystem-mt-x32-1_71;boost_filesystem-mt-x32;boost_filesystem-mt;boost_filesystem-mt;boost_filesystem
-- [ C:/Program Files/JetBrains/CLion 2019.2.3/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:646 ] Boost_LIBRARY_DIR_RELEASE = "C:/boost_1_71_0/stage/lib"
-- [ C:/Program Files/JetBrains/CLion 2019.2.3/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:648 ] _boost_LIBRARY_SEARCH_DIRS_RELEASE = "C:/boost_1_71_0/stage/lib;NO_DEFAULT_PATH;NO_CMAKE_FIND_ROOT_PATH"
-- [ C:/Program Files/JetBrains/CLion 2019.2.3/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:2095 ] Searching for FILESYSTEM_LIBRARY_DEBUG: boost_filesystem-vc142-mt-gd-x32-1_71;boost_filesystem-vc142-mt-gd-x32;boost_filesystem-vc142-mt-gd;boost_filesystem-vc141-mt-gd-x32-1_71;boost_filesystem-vc141-mt-gd-x32;boost_filesystem-vc141-mt-gd;boost_filesystem-vc140-mt-gd-x32-1_71;boost_filesystem-vc140-mt-gd-x32;boost_filesystem-vc140-mt-gd;boost_filesystem-mt-gd-x32-1_71;boost_filesystem-mt-gd-x32;boost_filesystem-mt-gd;boost_filesystem-mt;boost_filesystem
-- [ C:/Program Files/JetBrains/CLion 2019.2.3/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:646 ] Boost_LIBRARY_DIR_DEBUG = "C:/boost_1_71_0/stage/lib"
-- [ C:/Program Files/JetBrains/CLion 2019.2.3/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:648 ] _boost_LIBRARY_SEARCH_DIRS_DEBUG = "C:/boost_1_71_0/stage/lib;NO_DEFAULT_PATH;NO_CMAKE_FIND_ROOT_PATH"
-- Configuring done
-- Generating done
-- Build files have been written to: D:/untitled/cmake-build-debug

[Finished]

Сборка журнала:

====================[ Build | all | Debug ]=====================================
"C:\Program Files\JetBrains\CLion 2019.2.3\bin\cmake\win\bin\cmake.exe" --build D:\untitled\cmake-build-debug --target all --
[ 50%] Linking CXX executable untitled.exe
LINK Pass 1: command "C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1423~1.281\bin\Hostx86\x86\link.exe /nologo @CMakeFiles\untitled.dir\objects1.rsp /out:untitled.exe /implib:untitled.lib /pdb:D:\untitled\cmake-build-debug\untitled.pdb /version:0.0 /machine:X86 /debug /INCREMENTAL /subsystem:console C:\boost_1_71_0\stage\lib\boost_filesystem-vc142-mt-gd-x32-1_71.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles\untitled.dir/intermediate.manifest CMakeFiles\untitled.dir/manifest.res" failed (exit code 1104) with the following output:
LINK : fatal error LNK1104: cannot open file 'libboost_filesystem-vc142-mt-gd-x32-1_71.lib'
NMAKE : fatal error U1077: '"C:\Program Files\JetBrains\CLion 2019.2.3\bin\cmake\win\bin\cmake.exe"' : return code '0xffffffff'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\bin\HostX86\x86\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\bin\HostX86\x86\nmake.exe"' : return code '0x2'
Stop.

Скриншот Lib существует

В lib dir существует boost_filesystem-vc142-mt-gd-x32-1_71

...