gpt4 book ai didi

c++ - 字符串正则表达式替换需要 6 个参数但是..MinGW,CMake,w7

转载 作者:太空狗 更新时间:2023-10-29 20:41:32 27 4
gpt4 key购买 nike

我正在尝试在 w7 中构建一个我在 CentOS 6.5 上使用的应用程序,没有问题,但我需要为 Windows 32 位和 64 位编译。该程序使用 RTi 库,但 Win 库是为 VS2010 制作的,我正在尝试使用 MinGW Gcc 4.x.x、CMake 2.8.12 和 Maven 3.02 进行构建。我纠正了一些数据类型的不兼容性,但我认为 MinGW 和 Windows 7 之间的斜杠和正斜杠可能存在一些问题。基本程序已成功编译,现在是二进制文件的时候了。当我执行 cmake -G "MinGW Makefiles"expression 时,出现此错误。

CMake Error at C:/Workspace/trunk/IB/src/make/IB.Utils.cmake:43 (string):
string sub-command REGEX, mode REPLACE needs at least 6 arguments total to
command.
Call Stack (most recent call first):
C:/Workspace/trunk/IB/src/make/IB.Utils.cmake:116 (RemoveCXXComments)
C:/Workspace/trunk/IB/src/make/IB.DDS.cmake:12 (HasInterfaces)
C:/Workspace/trunk/IB/src/make/IB.DDS.cmake:59 (GetDDSGeneratedFiles)
CMakeLists.txt:6 (GenerateIDLLibrary)


CMake Error at C:/Workspace/trunk/IB/src/make/IB.Utils.cmake:43 (string):
string sub-command REGEX, mode REPLACE needs at least 6 arguments total to
command.
Call Stack (most recent call first):
C:/Workspace/trunk/IB/src/make/IB.Utils.cmake:65 (RemoveCXXComments)
C:/Workspace/trunk/IB/src/make/IB.DDS.cmake:74 (FindIncludes)
CMakeLists.txt:6 (GenerateIDLLibrary)


Includes for 'C:/MinGW/msys/1.0/home/blcoalla/trunk/Example/TestProfiles/TestPayload.idl' are
CMake Error at C:/Workspace/trunk/IB/src/make/IB.Utils.cmake:43 (string):
string sub-command REGEX, mode REPLACE needs at least 6 arguments total to
command.
Call Stack (most recent call first):
C:/Workspace/trunk/IB/src/make/IB.Utils.cmake:65 (RemoveCXXComments)
C:/Workspace/trunk/IB/src/make/IB.DDS.cmake:111 (FindIncludes)
CMakeLists.txt:6 (GenerateIDLLibrary)

这是 utils.cmake 的摘录:

Macro to get the content of a file

-----------------------------------------------------------------

宏(GetFileContent OutFile)

  #message("Called GetFileContent '${ARGN}'")
SET(cat_prog cat)
IF(WIN32)
IF(NOT UNIX)
SET(cat_prog type)
ELSE(NOT UNIX)
message (FATAL_ERROR "cannot determine the system to call to proper 'cat/type' method")
ENDIF(NOT UNIX)
ENDIF(WIN32)

set (Out)
set (tmp)

foreach(gfcfile ${ARGN})

if (NOT EXISTS ${gfcfile})
message(FATAL_ERROR "Cannot find file '${gfcfile}'")
endif(NOT EXISTS ${gfcfile})

EXECUTE_PROCESS(COMMAND ${cat_prog} ${gfcfile}
OUTPUT_VARIABLE tmp)
set (Out ${Out} ${tmp})

endforeach(gfcfile ${ARGN})

set(${OutFile} ${Out})
#message("Leaving GetFileContent")

endmacro(GetFileContent)
#-----------------------------------------------------------------

# Macro to get includes from an IDL file
#-----------------------------------------------------------------
macro (RemoveCXXComments Output Input)

#message("RemoveCXXComments Input: '${Input}'")
# Remove single line comments
string(REGEX REPLACE "(//[^\n]*\n)" "" ${Output} ${Input})
#message("RemoveCXXComments without single line: '${${Output}}'")

# Remove several line comments in file
string(REGEX REPLACE "(/\\*([^*]|[\r\n]|(\\*+([^*/]|[\r\n])))*\\*+/)" "" FileContent ${FileContent})
#message("RemoveCXXComments without multi line: '${${Output}}'")

endmacro (RemoveCXXComments)
#-----------------------------------------------------------------






from CMakeLists.txt6:
GenerateIDLLibrary(TestPayload TestPayload.idl)

from IB.DDS.cmake:59:
# Get expected generated files
GetDDSGeneratedFiles(DDSCXXGeneratedFiles DDSHGeneratedFiles ${IdlFile})
# message("CXX Files expected to be generated: '${DDSCXXGeneratedFiles}'")
#message("H Files expected to be generated: '${DDSHGeneratedFiles}'")

最佳答案

错误消息提示您的一个变量为空。您可以输出变量并检查哪个变量为空且不应为空。我猜想 Windows 出现问题并且未设置变量。如果变量为空或未设置,CMake 根本看不到您提供了参数。

如果你想强制你的正则表达式,你可以在参数周围加上引号。然后 CMake 知道您提供了正确数量的参数并且它不会提示“”作为参数。但这并不能解决你真正的问题,只能平息你当前的问题。我不建议你这样做,直到你真的知道它没问题。

关于c++ - 字符串正则表达式替换需要 6 个参数但是..MinGW,CMake,w7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21044665/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com