Netbeans给出了PCRE函数的未定义引用

时间:2011-11-26 02:49:43

标签: c netbeans pcre

当我尝试构建我的程序时,链接器失败,告诉我我对PCRE函数有未定义的引用。 我已经链接了libpcre.a并将其所在的目录添加到搜索路径中,并将头文件添加到搜索路径中,甚至通过配置cmake重建PCRE几次,关闭PCRECPP以防万一,并运行在目录上制作。我似乎无法做任何事情来修复它,我相信存在配置问题。这可能是我做的傻事了!

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

1 个答案:

答案 0 :(得分:0)

由于某种原因,编译器期待动态库 - 一旦我在CMake中设置选项,它运行正常。 (虽然我仍然无法找到如何让它接受构建的静态库,尽管我可以通过命令行使用gcc来实现)