System crashed during glibc compile, refuses to compile again even after remaking build directory - linux

I am chrooted into the temporary system (/tools). During the compile of glibc (step 6.9 of LFS), my computer unexpectedly shut down. After booting back up, remaking the build directory, running configure and make, it fails. Here is the log:
root:/sources/glibc-2.24/build# make
make -r PARALLELMFLAGS="" -C .. objdir=`pwd` all
make[1]: Entering directory '/sources/glibc-2.24'
make subdir=csu -C csu ..=../ subdir_lib
make[2]: Entering directory '/sources/glibc-2.24/csu'
gawk -f ../scripts/gen-as-const.awk ../sysdeps/x86_64/nptl/tcb-offsets.sym \
| gcc -S -o /sources/glibc-2.24/build/tcb-offsets.hT3 -std=gnu11 -fgnu89-inline -O2 -Wall -Werror -Wundef -Wwrite-strings -fmerge-all-constants -frounding-math -g -Wstrict-prototypes -Wold-style-definition -ftls-model=initial-exec -I../include -I/sources/glibc-2.24/build/csu -I/sources/glibc-2.24/build -I../sysdeps/unix/sysv/linux/x86_64/64 -I../sysdeps/unix/sysv/linux/x86_64 -I../sysdeps/unix/sysv/linux/x86 -I../sysdeps/unix/sysv/linux/wordsize-64 -I../sysdeps/x86_64/nptl -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux -I../sysdeps/nptl -I../sysdeps/pthread -I../sysdeps/gnu -I../sysdeps/unix/inet -I../sysdeps/unix/sysv -I../sysdeps/unix/x86_64 -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/x86_64/64 -I../sysdeps/x86_64/fpu/multiarch -I../sysdeps/x86_64/fpu -I../sysdeps/x86/fpu/include -I../sysdeps/x86/fpu -I../sysdeps/x86_64/multiarch -I../sysdeps/x86_64 -I../sysdeps/x86 -I../sysdeps/ieee754/ldbl-96 -I../sysdeps/ieee754/dbl-64/wordsize-64 -I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754/flt-32 -I../sysdeps/wordsize-64 -I../sysdeps/ieee754 -I../sysdeps/generic -I.. -I../libio -I. -D_LIBC_REENTRANT -include /sources/glibc-2.24/build/libc-modules.h -DMODULE_NAME=libc -include ../include/libc-symbols.h -x c - \
-MD -MP -MF /sources/glibc-2.24/build/tcb-offsets.h.dT -MT '/sources/glibc-2.24/build/tcb-offsets.h.d /sources/glibc-2.24/build/tcb-offsets.h'
In file included from ../sysdeps/generic/hp-timing-common.h:42:0,
from ../sysdeps/x86_64/hp-timing.h:38,
from ../include/libc-internal.h:7,
from ../sysdeps/x86_64/nptl/tls.h:29,
from ../sysdeps/unix/sysv/linux/x86_64/sysdep.h:24,
from <stdin>:1:
../sysdeps/generic/_itoa.h:32:25: error: "LONG_MAX" is not defined [-Werror=undef]
# define _ITOA_NEEDED (LONG_MAX != LLONG_MAX)
^
../sysdeps/generic/_itoa.h:97:6: note: in expansion of macro '_ITOA_NEEDED'
#if !_ITOA_NEEDED
^~~~~~~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [../Makerules:224: /sources/glibc-2.24/build/tcb-offsets.h] Error 1
make[2]: Leaving directory '/sources/glibc-2.24/csu'
make[1]: *** [Makefile:214: csu/subdir_lib] Error 2
make[1]: Leaving directory '/sources/glibc-2.24'
make: *** [Makefile:9: all] Error 2
root:/sources/glibc-2.24/build#
It seems like limits.h doesn't exist, but I checked, and it does indeed exist.
root:/usr/include/linux# ls | grep "limits.h"
limits.h
EDIT: I catted limits.h and noticed that LONG_MAX indeed was not included in the file. Here is the file:
#ifndef _LINUX_LIMITS_H
#define _LINUX_LIMITS_H
#define NR_OPEN 1024
#define NGROUPS_MAX 65536 /* supplemental group IDs are available */
#define ARG_MAX 131072 /* # bytes of args + environ for exec() */
#define LINK_MAX 127 /* # links a file may have */
#define MAX_CANON 255 /* size of the canonical input queue */
#define MAX_INPUT 255 /* size of the type-ahead buffer */
#define NAME_MAX 255 /* # chars in a file name */
#define PATH_MAX 4096 /* # chars in a path name including nul */
#define PIPE_BUF 4096 /* # bytes in atomic write to a pipe */
#define XATTR_NAME_MAX 255 /* # chars in an extended attribute name */
#define XATTR_SIZE_MAX 65536 /* size of an extended attribute value (64k) */
#define XATTR_LIST_MAX 65536 /* size of extended attribute namelist (64k) */
#define RTSIG_MAX 32
#endif
root:/usr/include/linux# ls | grep "limits.h"
limits.h
root:/usr/include/linux# cat limits.h
#ifndef _LINUX_LIMITS_H
#define _LINUX_LIMITS_H
#define NR_OPEN 1024
#define NGROUPS_MAX 65536 /* supplemental group IDs are available */
#define ARG_MAX 131072 /* # bytes of args + environ for exec() */
#define LINK_MAX 127 /* # links a file may have */
#define MAX_CANON 255 /* size of the canonical input queue */
#define MAX_INPUT 255 /* size of the type-ahead buffer */
#define NAME_MAX 255 /* # chars in a file name */
#define PATH_MAX 4096 /* # chars in a path name including nul */
#define PIPE_BUF 4096 /* # bytes in atomic write to a pipe */
#define XATTR_NAME_MAX 255 /* # chars in an extended attribute name */
#define XATTR_SIZE_MAX 65536 /* size of an extended attribute value (64k) */
#define XATTR_LIST_MAX 65536 /* size of extended attribute namelist (64k) */
#define RTSIG_MAX 32
#endif

#ifndef _LINUX_LIMITS_H
This is include/linux/limits.h. The LONG_MAX is supposed to come from include/limits.h, which is a different file.
It's likely that your sources got corrupted after unclean shutdown. You should restore them from a pristine copy.

Related

application using lttng compile errors with aarch64-xilinx-linux-g++

I am trying to porting lttng on xilinx mpsoc with linux OS, I have write a demo as same as lttng "Record user application events", it runs on Ubuntu perfectly
g++ -c -I. hello-tp.c
g++ -c hello.c
g++ -o hello hello-tp.o hello.o -llttng-ust -ldl
but when I compile it on arm linux platform I got errors:
aarch64-xilinx-linux-g++ -mcpu=cortex-a72.cortex-a53 -march=armv8-a+crc -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/david/project/zcu102/images/linux/sdk/sysroots/cortexa72-cortexa53-xilinx-linux -O2 -pipe -g -feliminate-unused-debug-types -c -I. hello-tp.c
In file included from hello-tp.c:4:
hello-tp.h:16:27: error: expected constructor, destructor, or type conversion before ‘(’ token
16 | LTTNG_UST_TRACEPOINT_EVENT(hello_world, my_first_tracepoint, LTTNG_ARGS, LTTNG_FIELDS)
| ^
make: *** [Makefile:14: hello-tp.o] Error 1
here is the code
hello-tp.h:
#undef LTTNG_UST_TRACEPOINT_PROVIDER
#define LTTNG_UST_TRACEPOINT_PROVIDER hello_world
#undef LTTNG_UST_TRACEPOINT_INCLUDE
#define LTTNG_UST_TRACEPOINT_INCLUDE "./hello-tp.h"
#if !defined(_HELLO_TP_H) || defined(LTTNG_UST_TRACEPOINT_HEADER_MULTI_READ)
#define _HELLO_TP_H
#include <lttng/tracepoint.h>
#define LTTNG_ARGS LTTNG_UST_TP_ARGS(int, my_integer_arg, char *, my_string_arg)
#define LTTNG_FIELDS LTTNG_UST_TP_FIELDS(lttng_ust_field_string(my_string_field, my_string_arg) lttng_ust_field_integer(int, my_integer_field, my_integer_arg))
LTTNG_UST_TRACEPOINT_EVENT(hello_world, my_first_tracepoint, LTTNG_ARGS, LTTNG_FIELDS)
#endif /* _HELLO_TP_H */
#include <lttng/tracepoint-event.h>
hello-tp.c
#define LTTNG_UST_TRACEPOINT_CREATE_PROBES
#define LTTNG_UST_TRACEPOINT_DEFINE
#include "hello-tp.h"
hello.c
#include <stdio.h>
#include "hello-tp.h"
int main(int argc, char *argv[])
{
unsigned int i;
puts("Hello, World!\nPress Enter to continue...");
/*
* The following getchar() call only exists for the purpose of this
* demonstration, to pause the application in order for you to have
* time to list its tracepoints. You don't need it otherwise.
*/
getchar();
/*
* An lttng_ust_tracepoint() call.
*
* Arguments, as defined in `hello-tp.h`:
*
* 1. Tracepoint provider name (required)
* 2. Tracepoint name (required)
* 3. `my_integer_arg` (first user-defined argument)
* 4. `my_string_arg` (second user-defined argument)
*
* Notice the tracepoint provider and tracepoint names are
* C identifiers, NOT strings: they're in fact parts of variables
* that the macros in `hello-tp.h` create.
*/
lttng_ust_tracepoint(hello_world, my_first_tracepoint, 23,
"hi there!");
for (i = 0; i < argc; i++) {
lttng_ust_tracepoint(hello_world, my_first_tracepoint,
i, argv[i]);
}
puts("Quitting now!");
lttng_ust_tracepoint(hello_world, my_first_tracepoint,
i * i, "i^2");
return 0;
}
Makefile
APP = hello
# Add any other object files to this list below
APP_OBJS = hello-tp.o hello.o
all: build
build: $(APP)
$(APP): $(APP_OBJS)
$(CXX) -o $# $(APP_OBJS) $(LDFLAGS) -llttng -ldl
hello-tp.o : hello-tp.c hello-tp.h
$(CXX) $(CXXFLAGS) -c -I. $<
hello.o : hello.c
$(CXX) $(CXXFLAGS) -c $<
clean:
rm -f $(APP) *.o
Is there anyone met such issue? I guess the problem is caused by complier but I don't find any clue...
I just ran into this problem. Check your LTTNG version. The 2.13 release (current) uses LTTNG_UST_TRACEPOINT_PROVIDER. However, older releases uses TRACEPOINT_PROVIDER. The prefix LTTNG_UST has been added all over the place. See https://lttng.org/man/3/lttng-ust/v2.13/#doc-_compatibility_with_previous_apis

How to force g++ to respect #define _POSIX_C_SOURCE 200809L

I need to use strerror_r to translate error numbers into human readable messages compiled with g++ on Linux Debian Bullseye. The man page notes:
int strerror_r(int errnum, char *buf, size_t buflen);
/* XSI-compliant */
char *strerror_r(int errnum, char *buf, size_t buflen);
/* GNU-specific */
strerror_r():
The XSI-compliant version is provided if:
(_POSIX_C_SOURCE >= 200112L) && ! _GNU_SOURCE
Otherwise, the GNU-specific version is provided.
We have two different types of the return value: int or char* depending on the version defined by _POSIX_C_SOURCE. I have this small test program:
~$ cat strerror_r.c
#include <string.h>
#include <stdio.h>
// #define _POSIX_C_SOURCE 200112L
// #undef _GNU_SOURCE
#define ERROR_BUFFER_LEN (size_t)256
int main(int argc, char **argv)
{
#if _POSIX_C_SOURCE < 200112L
char* ret;
#else
int ret;
#endif
char errorBuffer[ERROR_BUFFER_LEN];
int errno;
errno = 0;
ret = strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
fprintf(stderr, "Error message by pointer = '%s'\n", ret);
fprintf(stderr, "Content of errorBuffer = '%s'\n", errorBuffer);
return 0;
}
If I compile it with gcc everything is as expected:
$ gcc strerror_r.c && ./a.out; rm a.out
Error message by pointer = '(null)'
Content of errorBuffer = 'Success'
If I compile it with g++ I get this:
$ g++ strerror_r.c && ./a.out; rm a.out
strerror_r.c: In function ‘int main(int, char**)’:
strerror_r.c:24:21: error: invalid conversion from ‘char*’ to ‘int’ [-fpermissive]
24 | ret = strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| char*
rm: cannot remove 'a.out': No such file or directory
If I try to force the needed version by uncommenting
#define _POSIX_C_SOURCE 200112L
#undef _GNU_SOURCE
I get:
$ g++ strerror_r.c && ./a.out; rm a.out
strerror_r.c:7: warning: "_POSIX_C_SOURCE" redefined
7 | #define _POSIX_C_SOURCE 200112L
|
In file included from /usr/include/x86_64-linux-gnu/bits/libc-header-start.h:33,
from /usr/include/string.h:26,
from strerror_r.c:3:
/usr/include/features.h:281: note: this is the location of the previous definition
281 | # define _POSIX_C_SOURCE 200809L
|
strerror_r.c: In function ‘int main(int, char**)’:
strerror_r.c:24:21: error: invalid conversion from ‘char*’ to ‘int’ [-fpermissive]
24 | ret = strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| char*
rm: cannot remove 'a.out': No such file or directory
What I'm missing here? Why g++ does not compile the default thread save version of strerror_r? I need that version. How can I fix it?
Reference
Feature Test Macros
You need to specify the #define and #undef directives before you include any header files, so the first few lines should look like this:
#define _POSIX_C_SOURCE 200112L
#undef _GNU_SOURCE
#include <string.h>
#include <stdio.h>
That's because those header files or internal header files they include need those values defined to choose the proper variant. If you define them after including the headers, the headers don't see the right values and they don't include the version you want.
Often people specify these values on the command like with the -D and -U arguments so they are always specified before header files are included.

Where is the serial port flag CRTSXOFF on Linux?

I'm trying to port some Solaris serial port code to Linux, however the XOn / XOff symbol typically found in termios.h seems to be missing.
// ...
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <termios.h>
// ...
int config_port(int fd, int timeout)
{
struct termios options; /* Holds the port option flags */
int status; /* Holds return value of system calls */
int min_chars; /* Holds the minimum number of characters to read
* before returning. */
// ...
options.c_cflag &= ~( CRTSXOFF | CRTSCTS ); // <<-- HERE
Of course, Linux GCC doesn't know CRTSXOFF:
# gcc -c -g serial.c
serial.c: In function ‘config_port’:
serial.c:125:25: error: ‘CRTSXOFF’ undeclared (first use in this function)
125 | options.c_cflag &= ~( CRTSXOFF | CRTSCTS );
On Solaris, this symbol is certainly defined in termios.h:
# find /usr/include -iname \*.h -exec grep CRTSXOFF {} /dev/null \;
/usr/include/sys/termios.h:#define CRTSXOFF 010000000000
But on Linux the same command finds me nothing.
Is this symbol called something else on Linux?
Found it: under Linux CRTSXOFF is implemented as IXOFF.

Package xtables was not found in the pkg-config search path

I have downloaded iproute2. When I make ./configure && make && make install I get these errors.
TC schedulers
ATM no
IPT Package xtables was not found in the pkg-config search path.
Perhaps you should add the directory containing `xtables.pc'
to the PKG_CONFIG_PATH environment variable
No package 'xtables' found
using iptables
IPSET yes
iptables modules directory: /lib/xtables
libc has setns: yes
SELinux support: no
ELF support: no
libmnl support: no
Berkeley DB: no
docs: latex: no
WARNING: no docs can be built from LaTeX files
sgml2html: no
WARNING: no HTML docs can be built from SGML
make[1]: Entering directory `/home/mininet/iproute2-4.6.0/lib'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/mininet/iproute2-4.6.0/lib'
make[1]: Entering directory `/home/mininet/iproute2-4.6.0/ip'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/mininet/iproute2-4.6.0/ip'
make[1]: Entering directory `/home/mininet/iproute2-4.6.0/tc'
gcc -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wformat=2 -O2 -I../include -DRESOLVE_HOSTNAMES -DLIBDIR=\"/usr/lib\" -DCONFDIR=\"/etc/iproute2\" -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -DHAVE_SETNS -DCONFIG_GACT -DCONFIG_GACT_PROB -DIPT_LIB_DIR=\"/lib/xtables\" -DYY_NO_INPUT -c -o m_ipt.o m_ipt.c
In file included from m_ipt.c:17:0:
../include/linux/if.h:106:19: error: redeclaration of enumerator ‘IFF_UP’
#define IFF_UP IFF_UP
^
../include/linux/if.h:79:2: note: previous definition of ‘IFF_UP’ was here
IFF_UP = 1<<0, /* sysfs */
^
../include/linux/if.h:107:25: error: redeclaration of enumerator ‘IFF_BROADCAST’
#define IFF_BROADCAST IFF_BROADCAST
^
../include/linux/if.h:80:2: note: previous definition of ‘IFF_BROADCAST’ was here
IFF_BROADCAST = 1<<1, /* __volatile__ */
^
../include/linux/if.h:108:21: error: redeclaration of enumerator ‘IFF_DEBUG’
#define IFF_DEBUG IFF_DEBUG
^
../include/linux/if.h:81:2: note: previous definition of ‘IFF_DEBUG’ was here
IFF_DEBUG = 1<<2, /* sysfs */
^
../include/linux/if.h:109:24: error: redeclaration of enumerator ‘IFF_LOOPBACK’
#define IFF_LOOPBACK IFF_LOOPBACK
^
../include/linux/if.h:82:2: note: previous definition of ‘IFF_LOOPBACK’ was here
IFF_LOOPBACK = 1<<3, /* __volatile__ */
^
../include/linux/if.h:110:27: error: redeclaration of enumerator ‘IFF_POINTOPOINT’
#define IFF_POINTOPOINT IFF_POINTOPOINT
^
../include/linux/if.h:83:2: note: previous definition of ‘IFF_POINTOPOINT’ was here
IFF_POINTOPOINT = 1<<4, /* __volatile__ */
^
../include/linux/if.h:111:26: error: redeclaration of enumerator ‘IFF_NOTRAILERS’
#define IFF_NOTRAILERS IFF_NOTRAILERS
^
../include/linux/if.h:84:2: note: previous definition of ‘IFF_NOTRAILERS’ was here
IFF_NOTRAILERS = 1<<5, /* sysfs */
^
../include/linux/if.h:112:23: error: redeclaration of enumerator ‘IFF_RUNNING’
#define IFF_RUNNING IFF_RUNNING
^
../include/linux/if.h:85:2: note: previous definition of ‘IFF_RUNNING’ was here
IFF_RUNNING = 1<<6, /* __volatile__ */
^
../include/linux/if.h:113:21: error: redeclaration of enumerator ‘IFF_NOARP’
#define IFF_NOARP IFF_NOARP
^
../include/linux/if.h:86:2: note: previous definition of ‘IFF_NOARP’ was here
IFF_NOARP = 1<<7, /* sysfs */
^
../include/linux/if.h:114:23: error: redeclaration of enumerator ‘IFF_PROMISC’
#define IFF_PROMISC IFF_PROMISC
^
../include/linux/if.h:87:2: note: previous definition of ‘IFF_PROMISC’ was here
IFF_PROMISC = 1<<8, /* sysfs */
^
../include/linux/if.h:115:24: error: redeclaration of enumerator ‘IFF_ALLMULTI’
#define IFF_ALLMULTI IFF_ALLMULTI
^
../include/linux/if.h:88:2: note: previous definition of ‘IFF_ALLMULTI’ was here
IFF_ALLMULTI = 1<<9, /* sysfs */
^
../include/linux/if.h:116:22: error: redeclaration of enumerator ‘IFF_MASTER’
#define IFF_MASTER IFF_MASTER
^
../include/linux/if.h:89:2: note: previous definition of ‘IFF_MASTER’ was here
IFF_MASTER = 1<<10, /* __volatile__ */
^
../include/linux/if.h:117:21: error: redeclaration of enumerator ‘IFF_SLAVE’
#define IFF_SLAVE IFF_SLAVE
^
../include/linux/if.h:90:2: note: previous definition of ‘IFF_SLAVE’ was here
IFF_SLAVE = 1<<11, /* __volatile__ */
^
../include/linux/if.h:118:25: error: redeclaration of enumerator ‘IFF_MULTICAST’
#define IFF_MULTICAST IFF_MULTICAST
^
../include/linux/if.h:91:2: note: previous definition of ‘IFF_MULTICAST’ was here
IFF_MULTICAST = 1<<12, /* sysfs */
^
../include/linux/if.h:119:23: error: redeclaration of enumerator ‘IFF_PORTSEL’
#define IFF_PORTSEL IFF_PORTSEL
^
../include/linux/if.h:92:2: note: previous definition of ‘IFF_PORTSEL’ was here
IFF_PORTSEL = 1<<13, /* sysfs */
^
../include/linux/if.h:120:25: error: redeclaration of enumerator ‘IFF_AUTOMEDIA’
#define IFF_AUTOMEDIA IFF_AUTOMEDIA
^
../include/linux/if.h:93:2: note: previous definition of ‘IFF_AUTOMEDIA’ was here
IFF_AUTOMEDIA = 1<<14, /* sysfs */
^
../include/linux/if.h:121:23: error: redeclaration of enumerator ‘IFF_DYNAMIC’
#define IFF_DYNAMIC IFF_DYNAMIC
^
../include/linux/if.h:94:2: note: previous definition of ‘IFF_DYNAMIC’ was here
IFF_DYNAMIC = 1<<15, /* sysfs */
^
In file included from ../include/xtables.h:16:0,
from ../include/iptables.h:5,
from m_ipt.c:18:
/usr/include/net/if.h:111:8: error: redefinition of ‘struct ifmap’
struct ifmap
^
In file included from m_ipt.c:17:0:
../include/linux/if.h:189:8: note: originally defined here
struct ifmap {
^
In file included from ../include/xtables.h:16:0,
from ../include/iptables.h:5,
from m_ipt.c:18:
/usr/include/net/if.h:126:8: error: redefinition of ‘struct ifreq’
struct ifreq
^
In file included from m_ipt.c:17:0:
../include/linux/if.h:226:8: note: originally defined here
struct ifreq {
^
In file included from ../include/xtables.h:16:0,
from ../include/iptables.h:5,
from m_ipt.c:18:
/usr/include/net/if.h:176:8: error: redefinition of ‘struct ifconf’
struct ifconf
^
In file included from m_ipt.c:17:0:
../include/linux/if.h:278:8: note: originally defined here
struct ifconf {
^
In file included from ../include/iptables.h:5:0,
from m_ipt.c:18:
../include/xtables.h:34:29: fatal error: xtables-version.h: No such file or directory
#include <xtables-version.h>
^
compilation terminated.
make[1]: *** [m_ipt.o] Error 1
make[1]: Leaving directory `/home/mininet/iproute2-4.6.0/tc'
make: *** [all] Error 2
please help
UPDATE
I ended up updating the kernel and it work!
TC schedulers
ATM no
IPT Package xtables was not found in the pkg-config search path.
Install libxtables-dev on Ubuntu. I can't find a similar package from Fedora. On Fedora you may need to build from sources.
Ubuntu:
$ apt-cache search xtables
libip4tc-dev - Development files for libiptc
libip4tc0 - netfilter libi4pt library
libip6tc-dev - Development files for libiptc
libip6tc0 - netfilter libipt library
libiptc-dev - Development files for libiptc
libiptc0 - netfilter libipt library
libxtables-dev - netfilter xtables library
libxtables11 - netfilter xtables library
Fedora:
$ dnf search xtables
No matches found.
$ dnf search libxtables
No matches found.
Perhaps you should add the directory containing `xtables.pc'
to the PKG_CONFIG_PATH environment variable
If you install into /usr/local/lib on Ubuntu (or /usr/local/lib64 on Fedora`), then you will see something like this:
$ ls -Al /usr/local/lib/pkgconfig/
total 88
-rw-r--r-- 1 root root 228 Oct 22 08:15 expat.pc
-rw-r--r-- 1 root root 726 Oct 19 23:56 gnutls-dane.pc
-rw-r--r-- 1 root root 911 Oct 19 23:56 gnutls.pc
-rw-r--r-- 1 root root 1199 Oct 22 08:53 guile-2.2.pc
-rw-r--r-- 1 root root 563 Oct 22 08:13 hogweed.pc
-rw-r--r-- 1 root root 315 Oct 16 06:56 libcrypto.pc
-rw-r--r-- 1 root root 1678 Oct 16 06:58 libcurl.pc
-rw-r--r-- 1 root root 860 Oct 16 06:52 libidn.pc
...
When you configure you can you can do something like:
INSTALL_PREFIX="/usr/local"
INSTALL_LIBDIR="$INSTALL_PREFIX/lib"
OPT_PKGCONFIG=("$INSTALL_LIBDIR/pkgconfig")
OPT_CPPFLAGS=("-I$INSTALL_PREFIX/include" "-DNDEBUG")
OPT_CFLAGS=("$SH_MARCH" "$SH_NATIVE")
OPT_CXXFLAGS=("$SH_MARCH" "$SH_NATIVE")
OPT_LDFLAGS=("$SH_MARCH" "-Wl,-rpath,$INSTALL_LIBDIR" "-L$INSTALL_LIBDIR")
OPT_LIBS=("-ldl" "-lpthread")
...
PKG_CONFIG_PATH="${OPT_PKGCONFIG[*]}" \
CPPFLAGS="${OPT_CPPFLAGS[*]}" \
CFLAGS="${OPT_CFLAGS[*]}" CXXFLAGS="${OPT_CXXFLAGS[*]}" \
LDFLAGS="${OPT_LDFLAGS[*]}" LIBS="${OPT_LIBS[*]}" \
./configure --enable-shared --prefix="$INSTALL_PREFIX" --libdir="$INSTALL_LIBDIR"
<other config options>

build tshark 1.10.7 fails on luaL_openlibs

I want to build a stripped down version of tshark 1.10.7 x86 with lua support.
The options i currently use are those:
/configure --disable-wireshark --disable-packet-editor --disable-editcap --disable-mergecap --disable-reordercap --disable-text2pcap --disable-dftest --disable-randpkt --disable-airpcap --disable-dumpcap --disable-rawshark --disable-ipv6 --with-gnutls=no --with-gcrypt=no --disable-glibtest --with-lua=/usr/local/lib/
different approaches tested:
--with-lua=/usr/local
--with-lua=/usr/local/src/lua-5.2.3
--disable-usr-local (just in case i did miss some lua header file somewhere)
When i set '--with-lua=no' it builds fine and was previously used that way.
Here are the error logs from above command:
checking whether to use liblua for the Lua scripting plugin... yes
checking Lua version... Lua 5.2
checking lua.h usability... yes
checking lua.h presence... yes
checking for lua.h... yes
checking lualib.h usability... yes
checking lualib.h presence... yes
checking for lualib.h... yes
checking lauxlib.h usability... yes
checking lauxlib.h presence... yes
checking for lauxlib.h... yes
checking for luaL_openlibs in -llua... no
checking for luaL_openlibs in -llua5.2... no
configure: error: Linking with liblua failed.
i did install lua 5.2.3 from sorce lua.org
As slackware seems to need readline linked again libncurses i have done the same with lua 5.2.3 to have it compile correctly.
make linux MYLIBS=-lncurses
Lua seems to at least point out the correct version:
# lua -v
Lua 5.2.3 Copyright (C) 1994-2013 Lua.org, PUC-Rio
here are my lua files locations:
bash-4.1# find /usr/local/include/ -iname "lu*"
/usr/local/include/lualib.h
/usr/local/include/lua.hpp
/usr/local/include/lua.h
/usr/local/include/luaconf.h
bash-4.1# find /usr/local/bin/ -iname "lu*"
/usr/local/bin/luac
/usr/local/bin/lua
bash-4.1# ls /usr/local/lib/liblua*
/usr/local/lib/liblua.a
The installation itself was done from /usr/local/src/lua-5.2.3/
I tried different includedirs where i checked the header files are in, removing lua again, reinstalling slackware 13.37, but it seems to somehow still fail on the same value.
Google did only show me a few links which did not match my issue.
The possible relevant link to ask.wireshark lua
did not solve the issue as it might be a build bug.
Different search strings mostly seem to link to issues with a missing header file, lua missing, or readline issues, which i think i have ruled out already.
Based on the comments i did some further reason (which is not yet finished)
The output of the config.log clearly shows the lualib.h lua.h are there.
Here is the in my opinion relevant part:
configure:31529: checking for luaL_openlibs in -llua
configure:31554: gcc -o conftest -g -O2 -Wall -W -Wextra -Wdeclaration-after-statement -Wendif-labels -Wpointer-arith -Wno-pointer-sign -Warray-bounds -Wcast-align -Wformat-security -Wold-style-definition -Wstrict-prototypes -Wjump-misses-init -Wvla -Waddress -Warray-bounds -Wattributes -Wdiv-by-zero -Wignored-qualifiers -Wpragmas -Wno-overlength-strings -Wwrite-strings -Wno-long-long -Wc++-compat -Wshadow -Wlogical-op -fexcess-precision=fast -fvisibility=hidden -pthread -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -DG_DISABLE_SINGLE_INCLUDES -D_FORTIFY_SOURCE=0 -I/usr/local/include -I/usr/include -I/usr/local/lib//include -Wl,--as-needed -L/usr/local/lib -L/usr/local/lib//lib conftest.c -llua -lz -L/usr/local/lib//lib -llua -lm -lm >&5
conftest.c:63:1: warning: function declaration isn't a prototype
conftest.c:65:1: warning: function declaration isn't a prototype
conftest.c: In function 'main':
conftest.c:65:1: warning: old-style function definition
/usr/local/lib/liblua.a(loadlib.o): In function `ll_loadfunc':
loadlib.c:(.text+0x7f7): undefined reference to `dlsym'
loadlib.c:(.text+0x857): undefined reference to `dlopen'
loadlib.c:(.text+0x8d1): undefined reference to `dlerror'
loadlib.c:(.text+0x901): undefined reference to `dlerror'
/usr/local/lib/liblua.a(loadlib.o): In function `gctm':
loadlib.c:(.text+0xb78): undefined reference to `dlclose'
collect2: ld returned 1 exit status
configure:31554: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "wireshark"
| #define PACKAGE_TARNAME "wireshark"
| #define PACKAGE_VERSION "1.10.7"
| #define PACKAGE_STRING "wireshark 1.10.7"
| #define PACKAGE_BUGREPORT "http://bugs.wireshark.org/"
| #define PACKAGE_URL "http://www.wireshark.org/"
| #define PACKAGE "wireshark"
| #define VERSION "1.10.7"
| #define VERSION_MAJOR 1
| #define VERSION_MINOR 10
| #define VERSION_MICRO 7
| #define STDC_HEADERS 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_DLFCN_H 1
| #define LT_OBJDIR ".libs/"
| #define YYTEXT_POINTER 1
| #define HTML_VIEWER "mozilla"
| #define _FILE_OFFSET_BITS 64
| #define HAVE_NL80211 1
| #define HAVE_NL80211_CMD_SET_CHANNEL 1
| #define _U_ __attribute__((unused))
| #define DATAFILE_DIR "/usr/local/share/wireshark"
| #define DOC_DIR "/usr/local/share/doc/wireshark"
| #define HAVE_GLIB_PRINTF_GROUPING 1
| #define HAVE_LIBPCAP 1
| #define HAVE_PCAP_OPEN_DEAD 1
| #define HAVE_PCAP_FREECODE 1
| #define HAVE_PCAP_BREAKLOOP 1
| #define HAVE_PCAP_FINDALLDEVS 1
| #define HAVE_PCAP_DATALINK_VAL_TO_NAME 1
| #define HAVE_PCAP_DATALINK_NAME_TO_VAL 1
| #define HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION 1
| #define HAVE_PCAP_LIST_DATALINKS 1
| #define HAVE_PCAP_SET_DATALINK 1
| #define HAVE_PCAP_LIB_VERSION 1
| #define HAVE_PCAP_GET_SELECTABLE_FD 1
| #define HAVE_PCAP_FREE_DATALINKS 1
| #define HAVE_PCAP_CREATE 1
| #define HAVE_BPF_IMAGE 1
| #define PCAP_NG_DEFAULT 1
| #define HAVE_LIBZ 1
| #define HAVE_INFLATEPRIME 1
| #define HAVE_LUA_H 1
| #define HAVE_LUALIB_H 1
| #define HAVE_LAUXLIB_H 1
| /* end confdefs.h. */
|
| /* Override any GCC internal prototype to avoid an error.
| Use char because int might match the return type of a GCC
| builtin and then its argument prototype would still apply. */
| #ifdef __cplusplus
| extern "C"
| #endif
| char luaL_openlibs ();
| int
| main ()
| {
| return luaL_openlibs ();
| ;
| return 0;
| }
configure:31563: result: no
i will now read a bit more to understand the warnings and fix them.
With the help of sifflejoe i was able to track down that the libdl detection did somehow not completely work.
LDFLAGS="-ldl" ./configure --disable-wireshark --disable-packet-editor --disable-editcap --disable-mergecap --disable-reordercap --disable-text2pcap --disable-dftest --disable-randpkt --disable-airpcap --disable-dumpcap --disable-rawshark --disable-ipv6 --with-gnutls=no --with-gcrypt=no --disable-glibtest --with-lua=/usr/local/lib/
did solve the issue for us.

Resources