undefined reference to 'regcomp' 的错误
在 main.c 中,我用 #include <regex.h> 并调用了 regcomp 和 regexec。但在构建输出中,我收到了 undefined reference to 'regcomp' 的错误。这是链接器阶段的错误吗?我需要更改哪些链接器设置?MCU GCC 链接器选项如下:-mcpu=cortex-m3 -T"C:\Users\ssz\STM32CubeIDE\temp\edmr2\STM32F103VETX_FLASH.ld" --specs=nosys.specs -Wl,-Map="${BuildArtifactFileBaseName}.map" -Wl,--gc-sections -Wl,--verbose -static --specs=nano.specs -mfloat-abi=soft -mthumb -Wl,--start-group -lc -lm -Wl,--end-group工具链是 GNU Tools for STM32 (9-2020-q2-update)。regex.h 位于:C:\ST\STM32CubeIDE_1.5.1\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_2.0.0.202105311346\tools\arm-none-eabi\include
嵌入式工具链默认不提供 POSIX 正则表达式实现。 避免在 MCU 上使用 regex.h,改用轻量级替代方案。 不要在 MCU 上使用 POSIX 正则表达式,改用轻量级的字符串匹配方案。 试试链接 Newlib 的完整 POSIX 支持或者手动实现 regcomp/regexec。 用 C++ 的 <regex>,如果工具链支持。 嵌入式 GCC 工具链默认不包含regex库 尽量少用这些非正规的内核
页:
[1]