使用libssl和nmake

时间:2011-04-21 12:02:52

标签: openssl nmake

    LIBS =   ws2_32.lib winmm.lib advapi32.lib  crypt32.lib user32.lib gdi32.lib   libeay32.lib ssleay32.lib 

OSCOMPAT = /DWIN32 /D_WIN32_WINNT=0x0400
VSCOMPAT = /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE  
CFLAGS= -I . -I$C /MT /W3 $(OSCOMPAT) $(VSCOMPAT) -nologo $(EXTRACFLAGS)

test: $(CCLIENTLIB) test.obj oauth.obj hash.obj oauth_http.obj xmalloc.obj 
    LINK /NOLOGO mtest.obj oauth.obj hash.obj oauth_http.obj xmalloc.obj  $(LIBS) 


test.obj:test.c 
oauth.obj: oauth.c
hash.obj: hash.c
oauth_http.obj: oauth.h oauth_http.c
xmalloc.obj: xmalloc.c

我收到以下错误

    LINK /NOLOGO test.obj oauth.obj hash.obj oauth_http.obj xmalloc.obj    ws2_32.lib winmm.lib advapi32.lib  crypt32.lib user32.lib gdi32.lib   libeay32.lib ssleay32.lib
hash.obj : error LNK2019: unresolved external symbol HMAC referenced in function oauth_sign_hmac_sha1_raw
hash.obj : error LNK2019: unresolved external symbol EVP_sha1 referenced in function oauth_sign_hmac_sha1_raw
hash.obj : error LNK2019: unresolved external symbol EVP_PKEY_free referenced in function oauth_sign_rsa_sha1
hash.obj : error LNK2019: unresolved external symbol CRYPTO_free referenced in function oauth_sign_rsa_sha1
hash.obj : error LNK2019: unresolved external symbol EVP_SignFinal referenced in function oauth_sign_rsa_sha1
hash.obj : error LNK2019: unresolved external symbol EVP_DigestUpdate referenced in function oauth_sign_rsa_sha1
hash.obj : error LNK2019: unresolved external symbol EVP_DigestInit referenced in function oauth_sign_rsa_sha1
hash.obj : error LNK2019: unresolved external symbol EVP_PKEY_size referenced in function oauth_sign_rsa_sha1
hash.obj : error LNK2019: unresolved external symbol BIO_free referenced in function oauth_sign_rsa_sha1
hash.obj : error LNK2019: unresolved external symbol PEM_read_bio_PrivateKey referenced in function oauth_sign_rsa_sha1
hash.obj : error LNK2019: unresolved external symbol BIO_new_mem_buf referenced in function oauth_sign_rsa_sha1
hash.obj : error LNK2019: unresolved external symbol EVP_MD_CTX_cleanup referenced in function oauth_verify_rsa_sha1
hash.obj : error LNK2019: unresolved external symbol EVP_VerifyFinal referenced in function oauth_verify_rsa_sha1
hash.obj : error LNK2019: unresolved external symbol PEM_read_bio_PUBKEY referenced in function oauth_verify_rsa_sha1
hash.obj : error LNK2019: unresolved external symbol X509_free referenced in function oauth_verify_rsa_sha1
hash.obj : error LNK2019: unresolved external symbol X509_get_pubkey referenced in function oauth_verify_rsa_sha1
hash.obj : error LNK2019: unresolved external symbol PEM_read_bio_X509 referenced in function oauth_verify_rsa_sha1
hash.obj : error LNK2019: unresolved external symbol EVP_DigestFinal referenced in function oauth_body_hash_file
hash.obj : error LNK2019: unresolved external symbol EVP_MD_size referenced in function oauth_body_hash_file
hash.obj : error LNK2019: unresolved external symbol EVP_MD_CTX_init referenced in function oauth_body_hash_file
test.exe : fatal error LNK1120: 20 unresolved externals

make文件中有什么问题。 如何将libssl与我的应用相关联?

您可以从此处下载代码 https://rapidshare.com/files/458792519/test.rar (它包括来自liboauth的代码)

1 个答案:

答案 0 :(得分:1)

为了总结OP上的评论中的对话,我下载了示例代码并对其运行了nmake(makefile.nt)。我确实得到了链接器错误,但缺少的符号来自Win32库。我将user32.lib和gdi32.lib添加到makefile中的LIBS列表中,然后干净地链接(构建与VS2005,VS2008和VS2010一起使用)。

正如OP指出的那样,在添加这两个额外的库时它也会干净地链接。我不清楚这将如何帮助解决libeay32.lib中的那些符号。所以我怀疑是对make文件的更改导致了所有.obj文件的完全重建和编译。完全干净的构建使其工作。所以也许(我只是在猜测).obj文件最初编译不正确(编译器可能与链接器不兼容?)并且完全重建使一切都保持一致。