使用MinGW在github上构建增强功能

如何解决使用MinGW在github上构建增强功能

我无法在github动作(在Windows最新版本)上安装boost。在这里,我下载.zip并运行引导程序(这毫无问题):

$uri = 'https://dl.bintray.com/boostorg/release/1.68.0/source/boost_1_68_0.zip'
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -Uri $uri -OutFile C:\boost.zip -UserAgent [Microsoft.PowerShell.Commands.PSUserAgent]::Chrome
cd C:\install\boost_1_68_0\tools\build
.\bootstrap.bat gcc (or mingw)

然后我安装了boost,但是失败了:

cd C:\install\boost_1_68_0\tools\build
.\b2 install --prefix="C:\boost-build" toolset=gcc
$env:Path += ";C:\boost-build\bin"

cd C:\install\boost_1_68_0
& C:\boost-build\bin\b2.exe --build-dir="C:\install\boost_1_68_0\build" --with-system --with-program_options --with-serialization --with-test --build-type=complete -j2 --prefix="C:\boost" toolset=gcc install

一些日志:

searching for -lmingwex
2020-08-21T15:50:37.6440591Z C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmingwex
2020-08-21T15:50:37.6460133Z C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/libmsvcrt.a when searching for -lmsvcrt
2020-08-21T15:50:37.6478829Z C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib\libmsvcrt.a when searching for -lmsvcrt
2020-08-21T15:50:37.6492262Z C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/libmsvcrt.a when searching for -lmsvcrt
2020-08-21T15:50:37.6493427Z C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmsvcrt
2020-08-21T15:50:37.6557648Z collect2.exe: error: ld returned 1 exit status
2020-08-21T15:50:37.6559763Z 
2020-08-21T15:50:37.6585411Z     "g++"   "-Wl,--out-implib,C:\install\boost_1_68_0\build\boost\bin.v2\libs\system\build\gcc-8.1.0\release\address-model-32\threading-multi\libboost_system-mgw81-mt-x32-1_68.dll.a" -o "C:\install\boost_1_68_0\build\boost\bin.v2\libs\system\build\gcc-8.1.0\release\address-model-32\threading-multi\libboost_system-mgw81-mt-x32-1_68.dll" -Wl,-h -Wl,libboost_system-mgw81-mt-x32-1_68.dll -shared -Wl,--start-group "C:\install\boost_1_68_0\build\boost\bin.v2\libs\system\build\gcc-8.1.0\release\address-model-32\threading-multi\error_code.o"  -Wl,-Bstatic  -Wl,-Bdynamic  -Wl,--end-group -m32 -mthreads -march=i686 
2020-08-21T15:50:39.0837098Z ...skipped <pC:\boost\lib>libboost_timer-mgw81-mt-x32-1_68.dll for lack of <pC:\install\boost_1_68_0\build\boost\bin.v2\libs\timer\build\gcc-8.1.0\release\address-model-32\threading-multi>libboost_timer-mgw81-mt-x32-1_68.dll...
2020-08-21T15:50:39.0851962Z gcc.compile.c++ C:\install\boost_1_68_0\build\boost\bin.v2\libs\test\build\gcc-8.1.0\release\address-model-32\threading-multi\execution_monitor.o
2020-08-21T15:50:39.8118085Z gcc.compile.c++ C:\install\boost_1_68_0\build\boost\bin.v2\libs\test\build\gcc-8.1.0\release\address-model-32\threading-multi\debug.o
2020-08-21T15:50:40.2338237Z ...skipped <pC:\install\boost_1_68_0\build\boost\bin.v2\libs\timer\build\gcc-8.1.0\release\address-model-32\threading-multi>libboost_timer-mgw81-mt-x32-1_68.dll.a for lack of <pC:\install\boost_1_68_0\build\boost\bin.v2\libs\chrono\build\gcc-8.1.0\release\address-model-32\threading-multi>libboost_chrono-mgw81-mt-x32-1_68.dll.a...
2020-08-21T15:50:40.2421141Z gcc.compile.c++ C:\install\boost_1_68_0\build\boost\bin.v2\libs\test\build\gcc-8.1.0\release\address-model-32\threading-multi\cpp_main.o
2020-08-21T15:50:42.3085102Z ...skipped <pC:\install\boost_1_68_0\build\boost\bin.v2\libs\test\build\gcc-8.1.0\release\address-model-32\threading-multi>libboost_prg_exec_monitor-mgw81-mt-x32-1_68.dll for lack of <pC:\install\boost_1_68_0\build\boost\bin.v2\libs\timer\build\gcc-8.1.0\release\address-model-32\threading-multi>libboost_timer-mgw81-mt-x32-1_68.dll.a...
2020-08-21T15:50:42.3390490Z ...skipped <pC:\boost\lib>libboost_prg_exec_monitor-mgw81-mt-x32-1_68.dll for lack of <pC:\install\boost_1_68_0\build\boost\bin.v2\libs\test\build\gcc-8.1.0\release\address-model-32\threading-multi>libboost_prg_exec_monitor-mgw81-mt-x32-1_68.dll...
2020-08-21T15:50:42.3444885Z gcc.compile.c++ C:\install\boost_1_68_0\build\boost\bin.v2\libs\test\build\gcc-8.1.0\release\address-model-32\threading-multi\decorator.o
2020-08-21T15:51:05.4241487Z gcc.compile.c++ C:\install\boost_1_68_0\build\boost\bin.v2\libs\test\build\gcc-8.1.0\release\address-model-32\threading-multi\unit_test_parameters.o
2020-08-21T15:51:05.4369569Z ...skipped <pC:\boost\lib>libboost_program_options-mgw81-mt-x32-1_68.dll.a for lack of <pC:\install\boost_1_68_0\build\boost\bin.v2\libs\program_options\build\gcc-8.1.0\release\address-model-32\threading-multi>libboost_program_options-mgw81-mt-x32-1_68.dll.a...
2020-08-21T15:51:05.4384074Z ...skipped <pC:\boost\lib>libboost_serialization-mgw81-mt-x32-1_68.dll.a for lack of <pC:\install\boost_1_68_0\build\boost\bin.v2\libs\serialization\build\gcc-8.1.0\release\address-model-32\threading-multi>libboost_serialization-mgw81-mt-x32-1_68.dll.a...
2020-08-21T15:51:05.4385413Z ...skipped <pC:\install\boost_1_68_0\build\boost\bin.v2\libs\serialization\build\gcc-8.1.0\release\address-model-32\threading-multi>libboost_wserialization-mgw81-mt-x32-1_68.dll.a for lack of <pC:\install\boost_1_68_0\build\boost\bin.v2\libs\serialization\build\gcc-8.1.0\release\address-model-32\threading-multi>libboost_serialization-mgw81-mt-x32-1_68.dll.a...
2020-08-21T15:51:05.4410211Z ...skipped <pC:\boost\lib>libboost_wserialization-mgw81-mt-x32-1_68.dll.a for lack of <pC:\install\boost_1_68_0\build\boost\bin.v2\libs\serialization\build\gcc-8.1.0\release\address-model-32\threading-multi>libboost_wserialization-mgw81-mt-x32-1_68.dll.a...
2020-08-21T15:51:05.4467097Z ...skipped <pC:\boost\lib>libboost_system-mgw81-mt-x32-1_68.dll.a for lack of <pC:\install\boost_1_68_0\build\boost\bin.v2\libs\system\build\gcc-8.1.0\release\address-model-32\threading-multi>libboost_system-mgw81-mt-x32-1_68.dll.a...
2020-08-21T15:51:05.4480197Z ...skipped <pC:\boost\lib>libboost_chrono-mgw81-mt-x32-1_68.dll.a for lack of <pC:\install\boost_1_68_0\build\boost\bin.v2\libs\chrono\build\gcc-8.1.0\release\address-model-32\threading-multi>libboost_chrono-mgw81-mt-x32-1_68.dll.a...
2020-08-21T15:51:05.4481308Z ...skipped <pC:\boost\lib>libboost_timer-mgw81-mt-x32-1_68.dll.a for lack of <pC:\install\boost_1_68_0\build\boost\bin.v2\libs\timer\build\gcc-8.1.0\release\address-model-32\threading-multi>libboost_timer-mgw81-mt-x32-1_68.dll.a...
2020-08-21T15:51:05.4482701Z ...skipped <pC:\install\boost_1_68_0\build\boost\bin.v2\libs\test\build\gcc-8.1.0\release\address-model-32\threading-multi>libboost_prg_exec_monitor-mgw81-mt-x32-1_68.dll.a for lack of <pC:\install\boost_1_68_0\build\boost\bin.v2\libs\timer\build\gcc-8.1.0\release\address-model-32\threading-multi>libboost_timer-mgw81-mt-x32-1_68.dll.a...
2020-08-21T15:51:05.4562400Z ...skipped <pC:\boost\lib>libboost_prg_exec_monitor-mgw81-mt-x32-1_68.dll.a for lack of <pC:\install\boost_1_68_0\build\boost\bin.v2\libs\test\build\gcc-8.1.0\release\address-model-32\threading-multi>libboost_prg_exec_monitor-mgw81-mt-x32-1_68.dll.a...
2020-08-21T15:51:05.4750061Z gcc.archive C:\install\boost_1_68_0\build\boost\bin.v2\libs\system\build\gcc-8.1.0\release\address-model-32\link-static\threading-multi\libboost_system-mgw81-mt-x32-1_68.a
2020-08-21T15:51:05.4894206Z common.copy C:\boost\lib\libboost_system-mgw81-mt-x32-1_68.a
2020-08-21T15:51:05.4911430Z C:\install\boost_1_68_0\build\boost\bin.v2\libs\system\build\gcc-8.1.0\release\address-model-32\link-static\threading-multi\libboost_system-mgw81-mt-x32-1_68.a
2020-08-21T15:51:05.4913574Z         1 file(s) copied.
2020-08-21T15:51:05.5448927Z gcc.archive C:\install\boost_1_68_0\build\boost\bin.v2\libs\chrono\build\gcc-8.1.0\release\address-model-32\link-static\threading-multi\libboost_chrono-mgw81-mt-x32-1_68.a
2020-08-21T15:51:05.5612874Z common.copy C:\boost\lib\libboost_chrono-mgw81-mt-x32-1_68.a
2020-08-21T15:51:05.5629482Z C:\install\boost_1_68_0\build\boost\bin.v2\libs\chrono\build\gcc-8.1.0\release\address-model-32\link-static\threading-multi\libboost_chrono-mgw81-mt-x32-1_68.a
2020-08-21T15:51:08.7562611Z gcc.archive C:\install\boost_1_68_0\build\boost\bin.v2\libs\test\build\gcc-8.1.0\debug\address-model-32\link-static\threading-multi\libboost_unit_test_framework-mgw81-mt-d-x32-1_68.a
2020-08-21T15:51:08.7845048Z common.copy C:\boost\lib\libboost_unit_test_framework-mgw81-mt-d-x32-1_68.a
2020-08-21T15:51:08.7845690Z C:\install\boost_1_68_0\build\boost\bin.v2\libs\test\build\gcc-8.1.0\debug\address-model-32\link-static\threading-multi\libboost_unit_test_framework-mgw81-mt-d-x32-1_68.a
2020-08-21T15:51:08.7846336Z         1 file(s) copied.
2020-08-21T15:51:09.2309726Z ...failed updating 12 targets...
2020-08-21T15:51:09.2312270Z ...skipped 52 targets...
2020-08-21T15:51:09.2312837Z ...updated 15703 targets...
2020-08-21T15:51:09.2509339Z C:\install\boost_1_68_0   
2020-08-21T15:51:09.2603988Z 
2020-08-21T15:51:09.2604408Z 
2020-08-21T15:51:09.2818352Z ##[error]Process completed with exit code 1.

Link to actions of my repo with full logs/code

您有什么建议或建议吗?

解决方法

我面临的主要问题是,库的名称中带有-x64(或x32),因此find_package无法找到所需的库(确实有用,它设置为-DBoost_DEBUG = ON)。

Could NOT find Boost (missing: system) (found version "1.68.0")

将Boost_ARCHITECTURE设置为“ -x64”,即可完成工作

set(Boost_ARCHITECTURE "-x64")

对于Github Action,我也需要使用

continue-on-error: true # to prevent failing workflow when step exit with errors (when installing boost)
if: success() || failure() # to run following steps even if previous step failed 

所以,如果您有类似的问题

  1. 使用gcc安装boost
  2. 通过检查BOOST_ROOT,BOOST_LIBRARIES,确保cmake有所助益
  3. 如果发生任何错误,请仔细查看错误消息并使用Boost_DEBUG

这是我的代码:

name: build and run tests

on:
  push:
    branches: [ server ]
  pull_request:
    branches: [ server ]
    
jobs:
  build-windows:
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v2
      - name: Install PostgreSQL
        run: |
          Start-Process powershell -Verb runAs
          choco install -y postgresql12
      - name: Download Boost
        shell: powershell
        run: |
          $uri = 'https://dl.bintray.com/boostorg/release/1.68.0/source/boost_1_68_0.zip'
          [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
          Invoke-WebRequest -Uri $uri -OutFile C:\boost.zip -UserAgent [Microsoft.PowerShell.Commands.PSUserAgent]::Chrome
      - name: Unzip boost
        run: Expand-Archive -LiteralPath 'C:\boost.zip' -DestinationPath C:\install\
      - name: Run bootstrap
        shell: powershell
        run: |
          cd C:\install\boost_1_68_0\tools\build\
          .\bootstrap.bat gcc
      - name: Install Boost
        continue-on-error: true
        shell: powershell
        run: |
          cd C:\install\boost_1_68_0\tools\build\
          .\b2 --with-system --with-program_options --with-serialization --with-test --build-type=complete -j2 --prefix="C:\boost-build" toolset=gcc install
          $env:Path += ";C:\boost-build\bin"
          cd C:\install\boost_1_68_0
          C:\boost-build\bin\b2.exe --with-system --with-program_options --with-serialization --with-test --build-type=complete -j2 --build-dir="C:\install\boost_1_68_0\build" --build-type=complete --prefix="C:\boost" toolset=gcc install
      - name: Check libs names
        if: success() || failure()
        run: |
          cd c:\boost\lib
          Get-ChildItem
      - name: Running cmake
        if: success() || failure()
        run: |
          $env:BOOST_INCLUDEDIR = 'C:\boost\include'
          $env:BOOST_LIBRARYDIR = 'C:\boost\lib'
          $env:BOOST_ROOT = 'C:\boost'
          mkdir build
          cd build
          cmake -DBOOST_ROOT=c:/boost -DBoost_DEBUG=ON -G "MinGW Makefiles" ..
      - name: Running make (MinGW Makefiles)
        if: success() || failure()
        run: |
          cd build
          make
set(CMAKE_POLICY_DEFAULT_CMP0074 NEW)
cmake_minimum_required(VERSION 3.1)
project(Server VERSION 0.0.0)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static")

...

if (WIN32)
    # Here i'm setting boost paths based on BOOST_ROOT,you can skip this
    set(Boost_NO_SYSTEM_PATHS TRUE)
    if (Boost_NO_SYSTEM_PATHS)
      set(BOOST_ROOT "${BOOST_ROOT}")
      message("  > ${BOOST_ROOT}")
      set(BOOST_INCLUDEDIR "${BOOST_ROOT}/include")
      message("  > ${BOOST_INCLUDEDIR}")
      set(BOOST_LIBRARYDIR "${BOOST_ROOT}/lib")
      message("  > ${BOOST_LIBRARYDIR}")
    endif (Boost_NO_SYSTEM_PATHS)
    
    set(Boost_USE_STATIC_LIBS   ON)
    set(Boost_ARCHITECTURE "-x64")
endif (WIN32)

find_package(Boost 1.60.0 COMPONENTS REQUIRED program_options serialization system)

include_directories(${Boost_INCLUDE_DIR})

add_executable(Server ${FILES})

target_link_libraries(Server ${Boost_LIBRARIES} pthread)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-