2012-06-21 76 views
0

編譯我編寫的C代碼時出現以下錯誤。我明白問題出在頭文件中。任何人都可以告訴我哪些頭文件需要定義這些函數。頭文件故障

sign.c: In function ‘main’: 
sign.c:78: warning: assignment makes pointer from integer without a cast 
/tmp/ccnsSeHy.o: In function `sign_data_evp': 
sign.c:(.text+0x68): undefined reference to `check_ssl_rv' 
sign.c:(.text+0xd5): undefined reference to `check_ssl_rv' 
sign.c:(.text+0x13e): undefined reference to `check_ssl_rv' 
/tmp/ccnsSeHy.o: In function `main': 
sign.c:(.text+0x1ca): undefined reference to `initialize' 
sign.c:(.text+0x1d6): undefined reference to `select_engine' 
sign.c:(.text+0x20a): undefined reference to `sign_data' 
sign.c:(.text+0x216): undefined reference to `clean_engine' 
sign.c:(.text+0x21b): undefined reference to `clean_up' 
collect2: ld returned 1 exit status 

,我已經使用至今的頭文件:

#include <stdio.h> 
#include <string.h> 
#include <errno.h> 
#include <netdb.h> 
#include <unistd.h> 
#ifdef __VMS 
#include <socket.h> 
#include <inet.h> 

#include <in.h> 
#else 
#include <sys/types.h> 
#include <sys/socket.h> 
#include <netinet/in.h> 
#include <arpa/inet.h> 
#endif 

#include <openssl/crypto.h> 
#include <openssl/ssl.h> 
#include <openssl/err.h> 

運行平臺:Linux的 在此先感謝。

回答

1

你明白錯了。它不會抱怨未知的函數原型,它在連接期間抱怨。所以你可能忘記了鏈接一些庫或一些目標文件。

+0

我嘗試使用編譯它'gcc的-o樣本-lssl -lcrypt sample.c' 我應該鏈接哪個其他庫來編譯這些函數? – binish

+0

@binish通常'-lssl'丟失,或者庫的路徑設置不正確。 –

+0

試試'gcc -o sample sample.c -lcrypto -lssl'。庫的順序和來源很重要。後者必須解析之前指定的模塊/庫的符號。反之亦然。 – mity

0

嘗試用這種 的gcc -o sslprogname.c sslprogname -Wl,-Bstatic -lssl輪候冊,-Bdynamic -lssl3 -lcrypto.It工作對我來說