惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Tor Project blog
Cloudbric
Cloudbric
S
Secure Thoughts
Google Online Security Blog
Google Online Security Blog
N
News | PayPal Newsroom
D
Darknet – Hacking Tools, Hacker News & Cyber Security
P
Privacy & Cybersecurity Law Blog
Simon Willison's Weblog
Simon Willison's Weblog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
博客园 - 三生石上(FineUI控件)
E
Exploit-DB.com RSS Feed
WordPress大学
WordPress大学
F
Fortinet All Blogs
O
OpenAI News
IT之家
IT之家
Vercel News
Vercel News
G
Google Developers Blog
Spread Privacy
Spread Privacy
T
The Blog of Author Tim Ferriss
T
The Exploit Database - CXSecurity.com
V
V2EX - 技术
I
Intezer
N
News and Events Feed by Topic
W
WeLiveSecurity
宝玉的分享
宝玉的分享
AWS News Blog
AWS News Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
P
Proofpoint News Feed
I
InfoQ
The GitHub Blog
The GitHub Blog
C
Check Point Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
L
LangChain Blog
月光博客
月光博客
Microsoft Security Blog
Microsoft Security Blog
C
CERT Recently Published Vulnerability Notes
Hugging Face - Blog
Hugging Face - Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
Comments on: Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Schneier on Security
Schneier on Security
T
Threat Research - Cisco Blogs
博客园 - 【当耐特】
C
Cybersecurity and Infrastructure Security Agency CISA
Recent Announcements
Recent Announcements
大猫的无限游戏
大猫的无限游戏
aimingoo的专栏
aimingoo的专栏
Cyberwarzone
Cyberwarzone
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
H
Hackread – Cybersecurity News, Data Breaches, AI and More

博客园 - 萝卜L

USB Device Tree Viewer & 设备管理器 - 通用串行总线控制器 树莓派 DT 西门子 PLC 1500 过程时间性能 树莓派5 GPIO 输出 PWM PD 协议 E-Marker芯片、私有协议,联想 ThinkPad 135W 电源 Slim方口 ThinkPlus电源 树莓派 RaspberryPi 5 硬件 设备(dev) 芯片(SoC) BCM 线路编号(line) GPIO 针脚 gpioinfo pinout Solid Edge 仿真 Dynamic Designer Motion (DDM) Solid Edge PMI 智能尺寸 尺寸平面 Solid_Edge,尺寸、测量,从动、驱动,同步、顺序建模,变量表 变量类型 Dim Var SolidWorks & Solid Edge 装配体 零件 部件 移动 通过批处理快捷方式参数化调用 Lua 脚本:完整方案与备选方式 Win10 隐藏的 占用空间的 大文件 组态王 7.5 西门子 驱动 各版本 严重 异常 PLC、上位(HMI)接口约定 Modbus RTU TCP 网关 拓扑 TIA SIM 授权 iup "creation only"的时刻 lua 5.3 glue srlua/wsrlua console/windows OCX(ActiveX COM) 控件测试容器(tstcon32) 失败 问题 解决 Lua IUP Plot 柱状图 示例 GitHub Desktop 连接 Gitee 失败 EPLAN P8 学习笔记 配图 20250114 TIA Portal V19 STEP 7 Professional WinCC - Setup 安装过程中出错 失败 笔记 配图 20250110 windows zeroBrane Studio(zbstudio/zbs)配置 iuplua V3 Lua 找不到指定模块 找不到指定的程序 V2 powershell 作服务端 响应网络(socket tcp)连接 提供文件夹大小查询服务 V1.1 网络 主机名 地址 解析 记戴尔/Dell U2913WM 显示器故障
CMake Luarocks
萝卜L · 2025-05-03 · via 博客园 - 萝卜L

Luarocks

Commands

可以通过luarocks help查看简短说明,通过luarocks help xxx查看详细说明

命令 简介 说明
build Build/compile a rock Build and install a rock, compiling its C parts if any.
If the sources contain a luarocks.lock file, uses it as an authoritative source for exact version of dependencies.
If no arguments are given, behaves as luarocks make.
install Install a rock
make Compile package in current directory using a rockspec Builds sources in the current directory, but unlike "build", it does not fetch sources, etc., assuming everything is available in the current directory. If no argument is given, it looks for a rockspec in the current directory and in "rockspec/" and "rockspecs/" subdirectories, picking the rockspec with newest version or without version name. If rockspecs for different rocks are found or there are several rockspecs without version, you must specify which to use, through the command-line.

借助luarocks --verbose查看详细过程。

自定义

  • 可以使用luarocks -DXX=xx传入参数XX=xx给CMAKE。
  • 可以修改"rockspec",在"variables"下添加XX=xx
  • 设置环境变量?set XX=xx
  • 不支持luarocks config variables.CMAKE="cmake .."形式传入参数'..'。

以上貌似仅影响Configure|配置阶段(不影响构建|Build阶段)

luarocks config中找到相关配置

  • arch = "win32-x86"
  • processor = "x86"
  • target_cpu = "x86"
    未解决([[#错误-解决1]])问题。

过程

本质为'CMake'的过程,见下。

  • CMake -H. -Bbuild.luarocks -DCMAKE_INSTALL_PREFIX="K:\Users\rober\AppData\Roaming\luarocks\lib\luarocks\rocks-5.3\lua-s7iso\scm-1" -DCMAKE_BUILD_TYPE="Release"
  • CMake --build build.luarocks --config Release
    详见[[#CMake#Commands]]。

CMake

平台|platform

CMake -A <platform-name>,"Specify platform name if supported by generator"。

  • Win32
    "build.luarocks\Win32"文件夹
  • x64
    "build.luarocks\x64"文件夹

对应[[#cmake-gui]]-"Optional platform for generator"。

build directory

CMake -B <path-to-build>,"Explicitly specify a build directory"。
"build directory"对应Luarocks \ "build.luarocks"文件夹。"CMake"可以手动指定文件夹名,"luarocks"预设文件夹名为"build.luarocks"。

过程会缓存到此文件夹,其中包含"CMakeCache.txt"。
若此文件夹存在,则下次会跳过过程。可先手动删除此文件夹,再刷新。
刷新为增量刷新——"update and display new value in red"。

cmake-gui

功能:

  • 含:配置。
    • 输入:
      手动输入某些项,会自动生成另一些项。(比如指定"x64"->得到"CMAKE_EXE_LINKER_FLAGS:STRING=/machine:x64"等)
      • "Where is the source code"(源代码目录);
      • "Preset";
      • "Where to build the binaries" | "Browse Build..."(构建目录),
        (对应"build.luarocks");
      • Entry("Add Cache Entry")(包含:Name、Type、Value);
      • Environment("Environment Editor" - "Add Environment Variable")(包含:Name、Value)。
      • "CMakeSetup":
        • "Specify the generator for this project",
          "Visual Studio 17 2022";
        • "Optional platform for generator",
          "Win32"、"x64";
        • "Optional toolset to use"。
    • 输出|生成:
      • "CMakeCache.txt"(即最终配置)。
      • 基于平台(上文的"generator")的项目(如".sln"("Microsoft Visual Studio Solution"))。下一步为基于项目的构建。
    • 步骤:
      1. Configure;
      2. Generate;
  • 不含:构建|build。
    • 步骤:
      3. "Open Project"。
      等于直接打开文件".sln"(打开文件类型".vcxproj"亦是此对话框)(可以用"msbuild"(命令行)打开,参见下面Commands-构建)。
      选择应用程序 .sln Microsoft Visual Studio Solution

Commands

  1. 配置
    (对应上面的"Configure"+"Generate")
    • 形参:
      • -H.,貌似没作用,没副作用
      • -A <platform-name> = Specify platform name if supported by generator.
        貌似对应cmake-gui \ CMakeSetup 对话框 \ "Optional platform for generator(if empty, generator uses: x64)"。
        必要,即便使用"x86 Native Tools Command Prompt for VS 2022",若不指定|若缺省,仍会使用"Hostx64/x64"。
        当使用-AWin32时,在Win 64-bit OS默认使用的"Hostx64/x86"(模式也可使用"Hostx86/x86")。
      • -B <path-to-build> = Explicitly specify a build directory.
      • -D <var>[:<type>]=<value> = Create or update a cmake cache entry.
    • 实参:CMake -H. -Bbuild.luarocks -DCMAKE_BUILD_TYPE="Release" -DCMAKE_INSTALL_PREFIX="K:\Users\rober\AppData\Roaming\luarocks\lib\luarocks\rocks-5.3\lua-s7iso\scm-1"
  2. 构建|build
    • 形参:cmake --build <dir> [options] [-- [native-options]]
      • <dir>:"Project binary directory to be built"
      • --config <cfg> = For multi-configuration tools, choose <cfg>.
    • 实参:CMake --build build.luarocks --config Release
    • 在当前平台,本质为调用msbuild lua-s7iso.sln /p:Configuration=Release /p:Platform="Win32"

过程

基于

  • x86 Native Tools Command Prompt for VS 2022
  • x64_x86 Cross Tools Command Prompt for VS 2022
    (cmake-gui使用"bin/Hostx64/x86/"(,而非"bin/Hostx86/x86/"))。
  1. CMake -AWin32 -Bbuild.luarocks -DCMAKE_BUILD_TYPE="Release"
-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.20348.0 to target Windows 10.0.19045.
-- The C compiler identification is MSVC 19.43.34810.0
-- The CXX compiler identification is MSVC 19.43.34810.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: K:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.43.34808/bin/Hostx64/x86/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: K:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.43.34808/bin/Hostx64/x86/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Lua: K:/ProgramFiles/Lua/lua53.lib (found version "5.3.6")
-- Using Lua from K:/ProgramFiles/Lua/include
-- Configuring done (17.2s)
-- Generating done (0.1s)
-- Build files have been written to: D:/GitHub/lua-s7iso/build.luarocks
  1. CMake --build build.luarocks --config Release
适用于 .NET Framework MSBuild 版本 17.13.19+0d9f5a35a

  1>Checking Build System
  Building Custom Rule D:/GitHub/lua-s7iso/external/snap7/CMakeLists.txt
  s7_client.cpp
  s7_isotcp.cpp
  s7_micro_client.cpp
  s7_partner.cpp
  s7_peer.cpp
  s7_server.cpp
  s7_text.cpp
  snap_msgsock.cpp
  snap_sysutils.cpp
  snap_tcpsrvr.cpp
  snap_threads.cpp
  snap7_libmain.cpp
  snap7.cpp
  正在生成代码...
  Snap7.vcxproj -> D:\GitHub\lua-s7iso\build.luarocks\external\snap7\Release\Snap7.lib
  Building Custom Rule D:/GitHub/lua-s7iso/module/CMakeLists.txt
  lua_s7iso.cpp
  module_enums.cpp
  module_types.cpp
  module_client.cpp
  正在生成代码...
    正在创建库 D:/GitHub/lua-s7iso/build.luarocks/module/Release/lua-s7iso.lib 和对象 D:/GitHub/lua-s7iso/build.luarocks/module
  /Release/lua-s7iso.exp
  lua-s7iso.vcxproj -> D:\GitHub\lua-s7iso\build.luarocks\module\Release\lua-s7iso.dll
  Building Custom Rule D:/GitHub/lua-s7iso/CMakeLists.txt

CMake添加"-v"参数|option后可输出粗细阶段(msbuild默认输出):

1. 节点 1 上的项目“D:\GitHub\lua-s7iso\build.luarocks\ALL_BUILD.vcxproj”(默认目标)。
   项目“D:\GitHub\lua-s7iso\build.luarocks\ALL_BUILD.vcxproj”(1)正在节点 1 上生成“D:\GitHub\lua-s7iso\build.luarocks\ZERO_CHECK.vcxproj”(2) (默认目标)。
	1. PrepareForBuild
	2. InitializeBuildStatus
	3. CustomBuild
	4. FinalizeBuildStatus
	5. 已完成生成项目“D:\GitHub\lua-s7iso\build.luarocks\ZERO_CHECK.vcxproj”(默认目标)的操作。
2. 项目“D:\GitHub\lua-s7iso\build.luarocks\ALL_BUILD.vcxproj”(1)正在节点 1 上生成“D:\GitHub\lua-s7iso\build.luarocks\module\lua-s7iso.vcxproj”(3) (默认目标)。
   项目“D:\GitHub\lua-s7iso\build.luarocks\module\lua-s7iso.vcxproj”(3)正在节点 1 上生成“D:\GitHub\lua-s7iso\build.luarocks\external\snap7\Snap7.vcxproj”(4) (默认目标)。
	1. PrepareForBuild
	2. InitializeBuildStatus
	3. CustomBuild
	4. ClCompile
	5. Lib
	   obj
	   > Snap7.vcxproj -> D:\GitHub\lua-s7iso\build.luarocks\external\snap7\Release\Snap7.lib
	6. FinalizeBuildStatus
	7. 已完成生成项目“D:\GitHub\lua-s7iso\build.luarocks\external\snap7\Snap7.vcxproj”(默认目标)的操作。
3. 匿名
	 1. PrepareForBuild
	 2. InitializeBuildStatus
	 3. CustomBuild
	 4. ClCompile
	 5. Link
	    若平台不匹配:
	    - 目标计算机类型(如"x64")
	    - 库计算机类型(如"x86")
	      对应"lua53.lib"(32-bit)
	    则报错:"库计算机类型“x86”与目标计算机类型“x64”冲突"。
	 6. FinalizeBuildStatus
	    此步已经得到"lua-s7iso.dll"
	 7. 已完成生成项目“D:\GitHub\lua-s7iso\build.luarocks\module\lua-s7iso.vcxproj”(默认目标)的操作。
 4. 匿名
	 1. PrepareForBuild
	 2. InitializeBuildStatus
	 3. CustomBuild
	    > Building Custom Rule D:/GitHub/lua-s7iso/CMakeLists.txt
	 4. FinalizeBuildStatus
	 5. 已完成生成项目“D:\GitHub\lua-s7iso\build.luarocks\ALL_BUILD.vcxproj”(默认目标)的操作。

其他

文件名

链接|link过程中使用".lib",与lua bin中的文件名

  • "lua53.lib"
  • "lua53.dll"
    无关(无需手动命名为"lua.lib"、"lua.dll")。

错误-解决1

报错:

K:\ProgramFiles\Lua\lua53.lib : warning LNK4272: 库计算机类型“x86”与目标计算机类型“x64”冲突(library machine type 'x86' conflicts with target machine type 'x64') [K:\Users\rober\AppData\Local\Temp\luarocks_lua-s7iso-0.1-1-7765853\lua-s7iso\build.luarocks\module\lua-s7iso.vcxproj]

xxx.obj : error LNK2019: 无法解析的外部符号 lua_xxx

因为lua53.lib为32位('库计算机类型"x86"'),而build配置为64位('与目标计算机类型"x64"冲突')。
需确定期望的架构,调整配置、构建|build参数,或,准备匹配的lib。

错误-解决2

-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Detecting C compiler ABI info - failed
-- Detecting CXX compiler ABI info - failed

warning MSB8003: 未定义 WindowsSDKDir 属性。可能找不到某些生成工具。
warning MSB8029: 中间目录或输出目录无法驻留在临时目录下,因为这可能会导致增量生成出现问题。
error C1083: 无法打开包括文件: “time.h”: No such file or directory
Error: Build error: Failed building.

或者
Cmake: The C compiler “xxx”is not able to compile a simple test program – OpenMind
链接推荐方解决法为,禁用编译器检查:

  • 在最前面set(CMAKE_C_COMPILER_WORKS 1)set(CMAKE_CXX_COMPILER_WORKS 1)
  • set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
    实际解决方法如下。

解决:
安装操作系统对应的SDK。(使用MSVC)

Detecting C compiler ABI info - done
Check for working C compiler: K:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.43.34808/bin/Hostx64/x86/cl.exe - skipped
Detecting C compile features - done
Detecting CXX compiler ABI info - done
Check for working CXX compiler: K:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.43.34808/bin/Hostx64/x86/cl.exe - skipped
Detecting CXX compile features - done

编译器 工具链

安装

手动安装

版本

  • "x86 Native Tools"
  • "x64 Native Tools"
  • "x64_x86 Cross Tools"
  • "x86_x64 Cross Tools"
    有对应的'Command Prompt'。

核心

  • cl.exe
    涉及版本(位于不同路径)
  • link.exe
    涉及版本?(位于不同路径?)
  • cmake.exe
    不涉及版本,单一路径

以上多版本,路径未在PATH环境变量中,需使用"Command Prompt"|"vcvars32.bat"等切换。

构建工具

跨平台构建工具:CMAKE、MAKE、"bscmake"、"xdcmake"

CMake 管理员权限

无需。

除非[[#CMake#build directory]]所在文件夹需要权限。

CMake Error: Unable to (re)create the private pkgRedirects directory:
K:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/bin/CMakeFiles/pkgRedirects
This may be caused by not having read/write access to the build directory.
Try specifying a location with read/write access like:
cmake -B build
If using a CMake presets file, ensure that preset parameter
'binaryDir' expands to a writable directory.

路径报错

Syntax error in cmake code at ..
when parsing string
Invalid character escape '\P'.

问题在于(字符串)路径中使用了\,应该用/