我刚刚开始使用Linux编程。 我正在尝试编译一个名为“spider”的程序来搜索某种类型的正则表达式。所需的库是PCRE,OpenSSL和libexpat。我安装了库,由于某些原因它们没有链接。
spider.c: In function ‘craft_csv_entry’:
spider.c:1261: warning: format ‘%lld’ expects type ‘long long int’, but argument 4 has type ‘__off_t’
spider.c:1261: warning: format ‘%lld’ expects type ‘long long int’, but argument 4 has type ‘__off_t’
spider.c: In function ‘read_maxgroups’:
spider.c:2218: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘XML_Size’
/tmp/ccZ2CUHF.o: In function `main':
spider.c:(.text+0xd2): undefined reference to `pcre_callout'
/tmp/ccZ2CUHF.o: In function `load_regexes':
spider.c:(.text+0x3db): undefined reference to `pcre_compile'
spider.c:(.text+0x440): undefined reference to `pcre_study'
/tmp/ccZ2CUHF.o: In function `compile_regexes':
spider.c:(.text+0x4d3): undefined reference to `pcre_compile'
spider.c:(.text+0x4f5): undefined reference to `pcre_study'
spider.c:(.text+0x52f): undefined reference to `pcre_compile'
spider.c:(.text+0x551): undefined reference to `pcre_study'
spider.c:(.text+0x58b): undefined reference to `pcre_compile'
spider.c:(.text+0x5ad): undefined reference to `pcre_study'
/tmp/ccZ2CUHF.o: In function `is_match':
spider.c:(.text+0xad2): undefined reference to `pcre_exec'
spider.c:(.text+0xb6e): undefined reference to `pcre_exec'
spider.c:(.text+0xc0a): undefined reference to `pcre_exec'
spider.c:(.text+0xcbc): undefined reference to `pcre_exec'
/tmp/ccZ2CUHF.o: In function `set_globals':
spider.c:(.text+0x1e95): undefined reference to `log'
spider.c:(.text+0x1ed1): undefined reference to `pow'
/tmp/ccZ2CUHF.o: In function `craft_csv_entry':
spider.c:(.text+0x21fa): undefined reference to `MD5_Init'
spider.c:(.text+0x225d): undefined reference to `MD5_Update'
spider.c:(.text+0x22b2): undefined reference to `MD5_Final'
/tmp/ccZ2CUHF.o: In function `read_maxgroups':
spider.c:(.text+0x4498): undefined reference to `XML_ParserCreateNS'
spider.c:(.text+0x4513): undefined reference to `XML_SetUserData'
spider.c:(.text+0x452e): undefined reference to `XML_SetElementHandler'
spider.c:(.text+0x4549): undefined reference to `XML_SetNamespaceDeclHandler'
spider.c:(.text+0x45b6): undefined reference to `XML_GetBuffer'
spider.c:(.text+0x466a): undefined reference to `XML_ParseBuffer'
spider.c:(.text+0x4679): undefined reference to `XML_GetErrorCode'
spider.c:(.text+0x4681): undefined reference to `XML_ErrorString'
spider.c:(.text+0x468e): undefined reference to `XML_GetCurrentLineNumber'
/tmp/ccZ2CUHF.o: In function `spider_encrypt':
spider.c:(.text+0x491c): undefined reference to `EVP_CIPHER_CTX_init'
spider.c:(.text+0x4921): undefined reference to `EVP_bf_cbc'
spider.c:(.text+0x4943): undefined reference to `EVP_EncryptInit'
spider.c:(.text+0x499d): undefined reference to `EVP_EncryptUpdate'
spider.c:(.text+0x4a2e): undefined reference to `EVP_EncryptFinal'
spider.c:(.text+0x4a81): undefined reference to `EVP_CIPHER_CTX_cleanup'
/tmp/ccZ2CUHF.o: In function `spider_decrypt':
spider.c:(.text+0x4b82): undefined reference to `EVP_CIPHER_CTX_init'
spider.c:(.text+0x4b87): undefined reference to `EVP_bf_cbc'
spider.c:(.text+0x4ba9): undefined reference to `EVP_DecryptInit'
spider.c:(.text+0x4be4): undefined reference to `EVP_DecryptUpdate'
spider.c:(.text+0x4c9d): undefined reference to `EVP_DecryptFinal'
spider.c:(.text+0x4d26): undefined reference to `EVP_CIPHER_CTX_cleanup'
collect2: ld returned 1 exit status
答案 0 :(得分:4)
试试这个:
gcc -o spider spider.c -I/usr/local/include -I/usr/include -L/usr/local/lib -L/usr/lib -lpcre -lssl -lcrypto -lexpat
答案 1 :(得分:2)
您需要明确链接到库。您可能需要添加-llibpcre -llibssl
和-llibexpat
,但这些名称可能不同(基于库的libnames - 这些名称应与您安装的软件包的名称相同,或者它们适用.a和.so文件)