0

I want to use PCRE2 in my C program, but I haven't used C in a while and I can't get it to work. I'm using windows 11 and visual studio code.

I downloaded pcre2 from the mirror, and used the vsc cmake extension to configure and build it. I have these lines at the top of my C program that I want to use pcre2 in: #define PCRE2_CODE_UNIT_WIDTH 8 #include <pcre2.h> I figured I needed to link pcre2 somehow, so I tried this in my tasks.json file:

{
            "type": "cppbuild",
            "label": "C/C++: gcc.exe build active file",
            "command": "C:/msys64/mingw64/bin/gcc.exe",
            "args": [
                "-fdiagnostics-color=always",
                "-I$D:/(my filepath)/pcre2-10.37/build/pcre2.h",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "C:/msys64/mingw64/bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build",
            "detail": "compiler: C:/msys64/mingw64/bin/gcc.exe"
        }

I think this is where I'm going wrong, but I dont understand enough to fix it. I'm getting fatal error: pcre2.h: No such file or directory when I try and build my program. Either that or I configured/built pcre2 incorrectly. I've looked at a bunch of similar questions but I'm still struggling and would really appreciate some help.

disco
  • 1
  • 1
  • 1
    Since you're using MSYS2, you should download pcre2 from their package manager instead of building manually: `pacman -S mingw-w64-x86_64-pcre2`. Then remove your `-I`, and run `pkg-config --libs --cflags libpcre2-8`, which will tell you the right flags to use. – HolyBlackCat Jun 22 '23 at 13:33
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Jun 23 '23 at 17:11

0 Answers0