When I try to build my program the linker fails, telling me that I have undefined references to the PCRE functions.
I have linked libpcre.a and added the directory it is in to the search paths, as well as adding the header files to the search paths, and even rebuilt PCRE a few times by configuring cmake, turning off PCRECPP just in case, and running make on the directory. It seems I can’t do anything to fix it, and I believe that there is a configuration issue. Its probably something silly I did on my part though!
mkdir -p build/Debug/MinGW-Windows
rm -f build/Debug/MinGW-Windows/main.o.d
gcc.exe -c -g -Wall -I/C/Users/One/Documents/Programming/C/Libraries/pcre-8.12 -MMD -MP -MF build/Debug/MinGW-Windows/main.o.d -o build/Debug/MinGW-Windows/main.o main.c
main.c: In function 'main':
main.c:278:5: warning: passing argument 3 of 'pcre_compile' from incompatible pointer type [enabled by default]
c:/Users/One/Documents/Programming/C/Libraries/pcre-8.12/pcre.h:282:21: note: expected 'const char **' but argument is of type 'char **'
main.c:282:5: warning: passing argument 3 of 'pcre_compile' from incompatible pointer type [enabled by default]
c:/Users/One/Documents/Programming/C/Libraries/pcre-8.12/pcre.h:282:21: note: expected 'const char **' but argument is of type 'char **'
main.c: In function 'getFileList':
main.c:231:1: warning: control reaches end of non-void function [-Wreturn-type]
main.c: In function 'getFileServer':
main.c:205:1: warning: control reaches end of non-void function [-Wreturn-type]
mkdir -p dist/Debug/MinGW-Windows
gcc.exe -o dist/Debug/MinGW-Windows/project1 build/Debug/MinGW-Windows/main.o -L/C/Users/One/Documents/Programming/C/Libraries/pcre-8.12/lib -lpcre
build/Debug/MinGW-Windows/main.o: In function `runRegex':
C:\Users\One\Documents\Programming\C\Projects\project1/main.c:174: undefined reference to `_imp__pcre_exec'
build/Debug/MinGW-Windows/main.o: In function `main':
C:\Users\One\Documents\Programming\C\Projects\project1/main.c:278: undefined reference to `_imp__pcre_compile'
C:\Users\One\Documents\Programming\C\Projects\project1/main.c:282: undefined reference to `_imp__pcre_compile'
collect2: ld returned 1 exit status
For some reason, the compiler was expecting a dynamic library- Once I set the option in CMake, it worked fine. (Though I still couldn’t find out how to make it accept the static library that was built, though I can do so with gcc through the command line)