Linking error of _ntl_gbigint_body in using NTL

I use NTL on ArchLinux, and there is a struct _ntl_gbigint_body which is actually not defined (refer this post):

/*
 * This way of defining the bigint handle type is a bit non-standard,
 * but better for debugging.
 */

struct _ntl_gbigint_body;
typedef _ntl_gbigint_body *_ntl_gbigint;  

You should pay attention to functions who depend on this struct, such as:

void _ntl_gcopy(_ntl_gbigint a, _ntl_gbigint *bb)   

Because for old NTL library, the function prototype generated by compiler is _ntl_gcopy(void*, void**):

$ readelf -sW libntl.so | c++filt | grep ntl_gcopy
2511: 000000000012b750   184 FUNC    GLOBAL DEFAULT   12 _ntl_gcopy(void*, void**)

While for new one it is _ntl_gcopy(_ntl_gbigint_body*, _ntl_gbigint_body**):

$ readelf -sW libntl.so | c++filt | grep ntl_gcopy
615: 0000000000148500   202 FUNC    GLOBAL DEFAULT   11 _ntl_gcopy(_ntl_gbigint_body*, _ntl_gbigint_body**)

So if you meet linking error as following:

undefined reference to `_ntl_gcopy(void*, void**)'

It should be NTL header files and library mismatch. The header files are old, while library is new.

Notice the linking library position on Ubuntu

This week, I ported tcpbench from OpenBSD to Linux. The idiomatic method of OpenBSD is putting the linking library in front of generating final target:

cc -g -O2 -Wall -levent -o tcpbench tcpbench.c

However this doesn’t work in Ubuntu since its the linker uses --as-needed option. So I change the Makefile to put the library at the end:

cc -g -O2 -Wall -o tcpbench tcpbench.c -levent

Please refer this discussion if you are interested.

First installation of OpenBSD-current

I have an old laptop, and tried to install OpenBSD-current on it. Unfortunately, no matter from OpenBSD 6.3 to upgrade, or install it from scratch. the machine couldn’t boot successfully. It displayed:

>>OpenBSD/amd64 BOOT 3.39

Then it flashed one line (I couldn’t see that line clearly, and it should display loading something), and the system would reboot again.

At the end, I gave up, and install OpenBSD-current on a virtual machine.

 

Create only root partition during installing OpenBSD

The default partitions of installing OpenBSD is not appropriate for me:
3I need more space for /, since I want to build source code. So I just create one partition:

1 2

Please notice when creating partitions, there are some useful commands. Such as p, which displays current partition status:

4

? is for help:

5

Use z to delete all partitions:

6

Create the root partition and save it:

7 8

Reference:
Easy OpenBSD Partition Scheme.

Install and configure Automake on OpenBSD

Today, when I tried to compile a project, “make” complained following errors:

# make
CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/sh /root/project/missing aclocal-1.15
/root/project/missing[81]: aclocal-1.15: not found
WARNING: 'aclocal-1.15' is missing on your system.
         You should only need it if you modified 'acinclude.m4' or
         'configure.ac' or m4 files included by 'configure.ac'.
         The 'aclocal' program is part of the GNU Automake package:
         <http://www.gnu.org/software/automake>
         It also requires GNU Autoconf, GNU m4 and Perl in order to run:
         <http://www.gnu.org/software/autoconf>
         <http://www.gnu.org/software/m4/>
         <http://www.perl.org/>
*** Error 127 in /root/project(Makefile:330 './aclocal.m4')

To fix it, first install Automake:

# pkg_add automake
quirks-2.414 signed on 2018-03-28T14:24:37Z
Ambiguous: choose package for automake
a       0: <None>
        1: automake-1.10.3p8
        2: automake-1.11.6p2
        3: automake-1.12.6p1
        4: automake-1.13.4p1
        5: automake-1.14.1p0
        6: automake-1.15.1
        7: automake-1.4.6p5
        8: automake-1.8.5p9
        9: automake-1.9.6p12
Your choice: 6
automake-1.15.1:autoconf-2.69p2: ok
automake-1.15.1: ok

Then “make” prompted it needs “AUTOCONF_VERSION“:

# make
CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/sh /root/project/missing aclocal-1.15
Provide an AUTOCONF_VERSION environment variable, please
aclocal-1.15: error: echo failed with exit status: 127
WARNING: 'aclocal-1.15' is missing on your system.
         You should only need it if you modified 'acinclude.m4' or
         'configure.ac' or m4 files included by 'configure.ac'.
         The 'aclocal' program is part of the GNU Automake package:
         <http://www.gnu.org/software/automake>
         It also requires GNU Autoconf, GNU m4 and Perl in order to run:
         <http://www.gnu.org/software/autoconf>
         <http://www.gnu.org/software/m4/>
         <http://www.perl.org/>
*** Error 127 in /root/project/ (Makefile:330 './aclocal.m4')

Set AUTOCONF_VERSION environment variable:

# export AUTOCONF_VERSION=2.69

Run “autoreconf -f -i“:

# autoreconf -f -i
Provide an AUTOMAKE_VERSION environment variable, please
autoreconf-2.69: aclocal failed with exit status: 127

Set AUTOMAKE_VERSION:

# export AUTOMAKE_VERSION=1.15

This time, it worked:

# autoreconf -f -i
# make
/bin/sh ./config.status --recheck
......