cancel
Showing results for 
Search instead for 
Did you mean: 

In main.c I have #include <regex.h> and calls to regcomp and regexec. In the build output, I receive undefined reference to `regcomp'. Is it an error in the linker stage? What linker setting I should change?

MrSzymonello
Associate II

MCU GCC Linker options are

-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

toolchain is GNU Tools for STM32 (9-2020-q2-update)

regex.h is in 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

4 REPLIES 4
Cartu38 OpenDev
Lead II

#include <sys/types.h>

#include <regex.h>

https://devel.rtems.org/ticket/3631

MrSzymonello
Associate II

Yes, I also had a problem with off_t and solved it as you suggest. This however does not solve undefined reference to `regcomp'.

MrSzymonello
Associate II

@Cartu38 OpenDev​ do you have working code with regex.h available? Could you show your MCU GCC Linker options? If you use CubeIDE go to project Properties -> C/C++ Build -> Settings -> Tool Settings -> MCU GCC Linker.

Not functional neither. I guess answer is here: https://answers.launchpad.net/gcc-arm-embedded/+question/208555

I've got a look to all .a provided file as part of toolchain, none of them is promoting 'regcomp' implementation.

Maybe https://github.com/kokke/tiny-regex-c is good solution