How to Fix Ruby Installation error: EC_GROUP_new_curve_GF2m undeclared (first use in this function)?

Updated on September 2, 2017

Question: I was compiling Ruby version 1.9.3 on a CentOS machine and landed up with the below error message while executing make command.

EC_GROUP_new_curve_GF2m undeclared (first use in this function)

The error occurred while compiling ossl_pkey_ec.c file.

Here’s the snapshot of the complete error:

# ./configure
 ossl_pkey_ec.c: In function âossl_ec_group_initializeâ:
 ossl_pkey_ec.c:761:17: warning: implicit declaration of function âEC_GF2m_simple method [-Wimplicit-function-declaration]
 method = EC_GF2m_simple_method();
 ossl_pkey_ec.c:761:24: warning: assignment makes pointer from integer without a cast [enabled by default] method = EC_GF2m_simple_method();
 ossl_pkey_ec.c:816:29: error: âEC_GROUP_new_curve_GF2mâ undeclared (first use in this function) new_curve = EC_GROUP_new_curve_GF2m;
 ossl_pkey_ec.c:816:29: note: each undeclared identifier is reported only once for each function it appears in
 make[2]: *** [ossl_pkey_ec.o] Error 1
 make[2]: Leaving directory `/root/ruby-1.9.3-p374/ext/openssl'
 make[1]: *** [ext/openssl/all] Error 2
 make[1]: Leaving directory `/root/ruby-1.9.3-p374'
 make: *** [build-ext] Error 2

Help me to solve the error.

ossl_pkey_ec.c error


A simple Google search on the error message EC_GROUP_new_curve_GF2m undeclared (first use in this function) hinted that it’s a known bug in Ruby with OpenSSL build. Fortunately, the developers had fixed the issue with a patch.

Follow the below steps to run the patch before building (make) Ruby:

Step 1: I assume that your present working directory is the Ruby source directory.

Step 2: Download the patch as shown below:

# wget
# ls out.patch

Step 3: Find out the file that you need to patch. From the above error message, it’s clear that the bug is present in ‘ossl_pkey_ec.c’ file.

# find . -name ossl_pkey_ec.c

Step 4: Run the downloaded patch

# patch ./ext/openssl/ossl_pkey_ec.c < out.patch
patching file ./ext/openssl/ossl_pkey_ec.c
Hunk #1 succeeded at 757 (offset -5 lines).
Hunk #2 succeeded at 814 (offset -5 lines).
patching file ./ext/openssl/ossl_pkey_ec.c
Hunk #1 FAILED at 7.
1 out of 1 hunk FAILED -- saving rejects to file ./ext/openssl/ossl_pkey_ec.c.rej

Now the patch is done. Try building Ruby again.

[Ruby_source_directory] # make

Hope it helps.

Was this article helpful?

Related Articles

Comments Leave a Comment

Leave a Comment