Note that there are some explanatory texts on larger screens.

plurals
  1. POCompiling native C++ module for Node.js, linking to openSSL/libcrypto fails
    primarykey
    data
    text
    <p>I'm using Cygwin/Windows and I'm trying to build a native module for node.js. I intend to make use of the OpenSSL Library. I have installed openssl from the Cygwin package manager.</p> <p>I have the following lines in my .cc file:</p> <pre><code>#include &lt;openssl/dh.h&gt; </code></pre> <p>and</p> <pre><code> DH* public_dh_key = DH_new(); </code></pre> <p>But when I try to link/compile it with <code>node-waf configure build</code>, I get:</p> <pre><code>undefined reference to _DH_new </code></pre> <p><strong>Edit:</strong></p> <p>Part of the build script:</p> <pre><code>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"] ... </code></pre> <p>(I have tried adding -lcrypto but still get the same result. I have also tried various combinations of "-lssl32","-lssleay32","-llibeay32".)</p> <p><strong>Edit</strong></p> <p>Output of the build script:</p> <pre><code>$ 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 -&gt; build/default/ppp_1.o [2/2] cxx_link: build/default/ppp_1.o -&gt; 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: -&gt; task failed (err #1): {task: cxx_link ppp_1.o -&gt; ppp.node,libppp.dll.a} </code></pre> <p><strong>Edit</strong></p> <p>I have the header file dh.h in usr/include/openssl </p> <p>And I have the required files (libssl32.dll, libeay32.dll and ssleay32.dll) in /usr/lib/</p> <p><strong>The answer</strong></p> <p>jHackTheRipper answered this and got the credit for it, but the final answer is buried in the comments beneath his answer. So to summarise, the waf mantra is</p> <pre><code>obj.lib='crypto' </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload