Cygwin / Windowsを使用していて、node.jsのネイティブモジュールを構築しようとしています。OpenSSLライブラリを利用するつもりです。Cygwinパッケージマネージャーからopensslをインストールしました。
.ccファイルに次の行があります。
#include <openssl/dh.h>
と
DH* public_dh_key = DH_new();
しかし、とリンク/コンパイルしようとするとnode-waf configure build
、次のようになります。
undefined reference to _DH_new
編集:
ビルドスクリプトの一部:
def build(bld):
ppp= bld.new_task_gen('cxx', 'shlib', 'node_addon')
ppp.cxxflags = ["-g", "-D_FILE_OFFSET_BITS=64", "-D_LARGEFILE_SOURCE", "-Wall", "-L/usr/lib", "-lssl"]
...
(-lcryptoを追加しようとしましたが、それでも同じ結果が得られます。「-lssl32」、「-lssleay32」、「-llibeay32」のさまざまな組み合わせも試しました。)
編集
ビルドスクリプトの出力:
$ node-waf configure build
Checking for program g++ or c++ : /usr/bin/g++
Checking for program cpp : /usr/bin/cpp
Checking for program ar : /usr/bin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for g++ : ok
Checking for node path : not found
Checking for node prefix : ok /usr/local
'configure' finished successfully (0.330s)
Waf: Entering directory `/usr/src/build'
[1/2] cxx: ppp.cc -> build/default/ppp_1.o
[2/2] cxx_link: build/default/ppp_1.o -> build/default/ppp.node build/default/libppp.dll.a
Creating library file: default/libppp.dll.a
default/ppp_1.o:/usr/src/build/../ppp.cc:289: undefined reference to `_HMAC'
collect2: ld returned 1 exit status
Waf: Leaving directory `/usr/src/build'
Build failed: -> task failed (err #1):
{task: cxx_link ppp_1.o -> ppp.node,libppp.dll.a}
編集
usr / include/opensslにヘッダーファイルdh.hがあります
そして、/ usr / lib /に必要なファイル(libssl32.dll、libeay32.dll、ssleay32.dll)があります。
答え
jHackTheRipperはこれに答えてクレジットを獲得しましたが、最終的な答えは彼の答えの下のコメントに埋もれています。要約すると、wafのマントラは
obj.lib='crypto'