error: implicit declaration of function 'strtok_r' - linux

I am a newbie in Linux programming (Linux 3.7.10). I tried to compile a program that I got for github but run in to problems with the error. The main program is from ntop where I downloaded the ndpi (https://svn.ntop.org/svn/ntop/trunk/nDPI/) and that compiled ok. The second part is the kernel mode filter that I got from github (https://github.com/ewildgoose/ndpi-netfilter).
First, I could not locate strtok_r function declared in any of the header files. I searched the whole system, is it a prebuild function with in the system?. Please any pointers would be highly appreciated. Thanks.
CC [M] /home/mtot/ndpi/ndpi-netfilter/src/ndpi_cpy/lib/protocols/http.o
/home/mtot/ndpi/ndpi-netfilter/src/ndpi_cpy/lib/protocols/http.c: In function 'check_content_type_and_change_protocol':
/home/mtot/ndpi/ndpi-netfilter/src/ndpi_cpy/lib/protocols/http.c:610:4: error: implicit declaration of function 'strtok_r' [-Werror=implicit-function-declaration]
/home/mtot/ndpi/ndpi-netfilter/src/ndpi_cpy/lib/protocols/http.c:610:10: warning: assignment makes pointer from integer without a cast [enabled by default]
/home/mtot/ndpi/ndpi-netfilter/src/ndpi_cpy/lib/protocols/http.c:617:14: warning: assignment makes pointer from integer without a cast [enabled by default]
/home/mtot/ndpi/ndpi-netfilter/src/ndpi_cpy/lib/protocols/http.c:623:9: warning: assignment makes pointer from integer without a cast [enabled by default]
/home/mtot/ndpi/ndpi-netfilter/src/ndpi_cpy/lib/protocols/http.c:627:11: warning: assignment makes pointer from integer without a cast [enabled by default]
/home/mtot/ndpi/ndpi-netfilter/src/ndpi_cpy/lib/protocols/http.c:632:13: warning: assignment makes pointer from integer without a cast [enabled by default]
cc1: some warnings being treated as errors
make[2]: *** [/home/mtot/ndpi/ndpi-netfilter/src/ndpi_cpy/lib/protocols/http.o] Error 1
make[1]: *** [_module_/home/mtot/ndpi/ndpi-netfilter/src] Error 2
Adding more details
I have located the string.h that has the strtok_r in the /usr/include. What I did was to add the in the http.c file and also the -I/usr/include in the ccflags-y in the Makefile. I got the following errors. Help really needed. Thanks.
CC [M] /home/mtot/ndpi/ndpi-netfilter/src/ndpi_cpy/lib/protocols/http.o
In file included from include/linux/compiler.h:48:0,
from include/uapi/linux/stddef.h:1,
`enter code here` from include/linux/stddef.h:4,
from /usr/src/linux-3.7.10/include/uapi/linux/posix_types.h:4,
from include/uapi/linux/types.h:13,
from include/linux/types.h:5,
from include/uapi/linux/byteorder/little_endian.h:11,
from include/linux/byteorder/little_endian.h:4,
from /usr/src/linux-3.7.10/arch/x86/include/asm/byteorder.h:4,
from /home/mtot/ndpi/ndpi-netfilter/src/ndpi_cpy/include/ndpi_main.h:49,
from /home/mtot/ndpi/ndpi-netfilter/src/ndpi_cpy/include/ndpi_protocols.h:29,
from /home/mtot/ndpi/ndpi-netfilter/src/ndpi_cpy/lib/protocols/http.c:25:
include/linux/compiler-gcc.h:93:0: warning: "__attribute_const__" redefined [enabled by default]
In file included from /usr/include/features.h:375:0,
from /usr/include/string.h:25,
from /home/mtot/ndpi/ndpi-netfilter/src/ndpi_cpy/lib/protocols/http.c:24:
/usr/include/sys/cdefs.h:237:0: note: this is the location of the previous definition
In file included from include/linux/compiler.h:48:0,
from include/uapi/linux/stddef.h:1,
from include/linux/stddef.h:4,
from /usr/src/linux-3.7.10/include/uapi/linux/posix_types.h:4,
from include/uapi/linux/types.h:13,
from include/linux/types.h:5,
from include/uapi/linux/byteorder/little_endian.h:11,
from include/linux/byteorder/little_endian.h:4,
from /usr/src/linux-3.7.10/arch/x86/include/asm/byteorder.h:4,
from /home/mtot/ndpi/ndpi-netfilter/src/ndpi_cpy/include/ndpi_main.h:49,
from /home/mtot/ndpi/ndpi-netfilter/src/ndpi_cpy/include/ndpi_protocols.h:29,
from /home/mtot/ndpi/ndpi-netfilter/src/ndpi_cpy/lib/protocols/http.c:25:
include/linux/compiler-gcc.h:112:0: warning: "__always_inline" redefined [enabled by default]
In file included from /usr/include/features.h:375:0,
from /usr/include/string.h:25,
from /home/mtot/ndpi/ndpi-netfilter/src/ndpi_cpy/lib/protocols/http.c:24:
/usr/include/sys/cdefs.h:308:0: note: this is the location of the previous definition
In file included from include/linux/bitops.h:22:0,
from include/linux/kernel.h:10,
from include/linux/skbuff.h:17,
from include/linux/ip.h:20,
from /home/mtot/ndpi/ndpi-netfilter/src/ndpi_cpy/include/ndpi_main.h:105,
from /home/mtot/ndpi/ndpi-netfilter/src/ndpi_cpy/include/ndpi_protocols.h:29,
from /home/mtot/ndpi/ndpi-netfilter/src/ndpi_cpy/lib/protocols/http.c:25:
/usr/src/linux-3.7.10/arch/x86/include/asm/bitops.h:406:19: error: static declaration of 'ffs' follows non-static declaration
In file included from /usr/src/linux-3.7.10/arch/x86/include/asm/string.h:4:0,
from include/linux/string.h:17,
from include/linux/bitmap.h:8,
from include/linux/cpumask.h:11,
from /usr/src/linux-3.7.10/arch/x86/include/asm/cpumask.h:4,
from /usr/src/linux-3.7.10/arch/x86/include/asm/msr.h:18,
from /usr/src/linux-3.7.10/arch/x86/include/asm/processor.h:20,
from /usr/src/linux-3.7.10/arch/x86/include/asm/thread_info.h:22,
from include/linux/thread_info.h:54,
from include/linux/preempt.h:9,
from include/linux/spinlock.h:50,
from include/linux/mm_types.h:8,
from include/linux/kmemcheck.h:4,
from include/linux/skbuff.h:18,
from include/linux/ip.h:20,
from /home/mtot/ndpi/ndpi-netfilter/src/ndpi_cpy/include/ndpi_main.h:105,
from /home/mtot/ndpi/ndpi-netfilter/src/ndpi_cpy/include/ndpi_protocols.h:29,
from /home/mtot/ndpi/ndpi-netfilter/src/ndpi_cpy/lib/protocols/http.c:25:
/usr/src/linux-3.7.10/arch/x86/include/asm/string_64.h:64:5: error: expected identifier or '(' before '__extension__'
/usr/src/linux-3.7.10/arch/x86/include/asm/string_64.h:64:5: error: expected identifier or '(' before ')' token
In file included from include/linux/bitmap.h:8:0,
from include/linux/cpumask.h:11,
from /usr/src/linux-3.7.10/arch/x86/include/asm/cpumask.h:4,
from /usr/src/linux-3.7.10/arch/x86/include/asm/msr.h:18,
from /usr/src/linux-3.7.10/arch/x86/include/asm/processor.h:20,
from /usr/src/linux-3.7.10/arch/x86/include/asm/thread_info.h:22,
from include/linux/thread_info.h:54,
from include/linux/preempt.h:9,
from include/linux/spinlock.h:50,
from include/linux/mm_types.h:8,
from include/linux/kmemcheck.h:4,
from include/linux/skbuff.h:18,
from include/linux/ip.h:20,
from /home/mtot/ndpi/ndpi-netfilter/src/ndpi_cpy/include/ndpi_main.h:105,
from /home/mtot/ndpi/ndpi-netfilter/src/ndpi_cpy/include/ndpi_protocols.h:29,
from /home/mtot/ndpi/ndpi-netfilter/src/ndpi_cpy/lib/protocols/http.c:25:
include/linux/string.h:38:12: error: expected identifier or '(' before '__extension__'
include/linux/string.h:38:12: error: expected identifier or '(' before ')' token
include/linux/string.h:41:12: error: expected identifier or '(' before '__extension__'
include/linux/string.h:53:15: error: expected identifier or '(' before '__extension__'
include/linux/string.h:83:15: error: expected identifier or '(' before '__extension__'
include/linux/string.h:83:15: error: expected identifier or '(' before ')' token
include/linux/string.h:86:15: error: expected identifier or '(' before '__extension__'
include/linux/string.h:86:15: error: expected identifier or '(' before ')' token
include/linux/string.h:89:24: error: expected identifier or '(' before '__extension__'
include/linux/string.h:89:24: error: expected identifier or '(' before ')' token
include/linux/string.h:92:24: error: expected identifier or '(' before '__extension__'
include/linux/string.h:92:24: error: expected identifier or '(' before ')' token
make[2]: *** [/home/mtot/ndpi/ndpi-netfilter/src/ndpi_cpy/lib/protocols/http.o] Error 1
make[1]: *** [_module_/home/mtot/ndpi/ndpi-netfilter/src] Error 2
make[1]: Leaving directory `/usr/src/linux-3.7.10'
make: *** [all] Error 2
-----MakeFile
NDPI_PATH2 := ${NDPI_PATH}/src
NDPI_SRC := ndpi_cpy
NDPI_PRO := ${NDPI_SRC}/lib/protocols
NDPI_THIRD := $(NDPI_SRC)/lib/third_party/src
SYS_HDR := /usr/include
ccflags-y += -I${src}/${NDPI_SRC}/include -I${src}/${NDPI_SRC}/lib -I${src}/${NDPI_SRC}/lib/third_party/include -I${SYS_HDR} -DOPENDPI_NETFILTER_MODULE
EXTRA_CFLAGS := $(ccflags-y)
#MODULES_DIR := /lib/modules/$(shell uname -r)
#KERNEL_DIR := ${MODULES_DIR}/build
obj-m := xt_ndpi.o
xt_ndpi-y := main.o \
${NDPI_SRC}/lib/ndpi_main.o \
${NDPI_THIRD}/ahocorasick.o \
${NDPI_THIRD}/node.o \
${NDPI_THIRD}/sort.o \
${NDPI_PRO}/afp.o \
${NDPI_PRO}/http.o
all:
if test -d ${NDPI_SRC}; then \
cp ${NDPI_PATH2}/* ${NDPI_SRC} -R; \
else \
mkdir ${NDPI_SRC}; \
cp ${NDPI_PATH2}/* ${NDPI_SRC} -R; \
fi
make -C ${KERNEL_DIR} M=$$PWD;
rm -r ${NDPI_SRC}
modules:
make -C ${KERNEL_DIR} M=$$PWD $#;
modules_install:
make -C ${KERNEL_DIR} M=$$PWD $#;
depmod -a;
clean:
make -C ${KERNEL_DIR} M=$$PWD $#;

strtok_r is typically in string.h. On a Linux system with man-pages installed you can do
man strtok_r
and that will give the manual page:
STRTOK(3) Linux Programmer’s Manual STRTOK(3)
NAME
strtok, strtok_r - extract tokens from strings
SYNOPSIS
#include <string.h>
char *strtok(char *str, const char *delim);
char *strtok_r(char *str, const char *delim, char **saveptr);
...
The include line tells you which file it is in (and must include in your code that uses it). Have you checked to see if you have string.h on your system? It is typically under /usr/include.
A lot of distributions have development packages, have you installed such packages to gain a fully development environment?

Type
man strtok_r
in a terminal. You should get a man page like strtok_r(3) (please follow that link).
Be sure to have installed the appropriate development and documentation packages like libc6-dev (or libc-dev), glibc-doc, manpages-dev. (The actual name depends upon the distribution).

Related

problem with make command in arch linux (while trying to install RTL8723DE driver)

make -C /lib/modules/5.18.12-arch1-1/build M=/home/rim/Downloads/rtw88_8723de-master
make[1]: Entering directory '/usr/lib/modules/5.18.12-arch1-1/build'
CC [M] /home/rim/Downloads/rtw88_8723de-master/mac80211.o
In file included from ././include/linux/kconfig.h:5,
from <command-line>:
./include/generated/autoconf.h:1332: warning: "CONFIG_RTW88_DEBUGFS" redefined
1332 | #define CONFIG_RTW88_DEBUGFS 1
|
<command-line>: note: this is the location of the previous definition
./include/generated/autoconf.h:6997: warning: "CONFIG_RTW88_DEBUG" redefined
6997 | #define CONFIG_RTW88_DEBUG 1
|
<command-line>: note: this is the location of the previous definition
/home/rim/Downloads/rtw88_8723de-master/mac80211.c:741:35: error: initialization of ‘void (*)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_prep_tx_info *)’ from incompatible pointer type ‘void (*)(struct ieee80211_hw *, struct ieee80211_vif *, u16)’ {aka ‘void (*)(struct ieee80211_hw *, struct ieee80211_vif *, short unsigned int)’} [-Werror=incompatible-pointer-types]
741 | .mgd_prepare_tx = rtw_ops_mgd_prepare_tx,
| ^~~~~~~~~~~~~~~~~~~~~~
/home/rim/Downloads/rtw88_8723de-master/mac80211.c:741:35: note: (near initialization for ‘rtw_ops.mgd_prepare_tx’)
cc1: some warnings being treated as errors
make[2]: *** [scripts/Makefile.build:288: /home/rim/Downloads/rtw88_8723de-master/mac80211.o] Error 1
make[1]: *** [Makefile:1838: /home/rim/Downloads/rtw88_8723de-master] Error 2
make[1]: Leaving directory '/usr/lib/modules/5.18.12-arch1-1/build'
make: *** [Makefile:44: all] Error 2
[rim#archie rtw88_8723de-master]$
I have no idea why is this happening, I tried to install RTL8723_DE driver because I want to connect my computer to web.
Driver I used: https://github.com/rtlwifi-linux/rtw88_8723de
Can somebody help, please?

RTL8821CE(wifi) driver installation issue: KBUILD_MODNAME

I downloaded the following driver for my new HP 17z laptop running Linux Mint 19: https://github.com/endlessm/linux/tree/master/drivers/net/wireless/rtl8821ce
Upon modifying the makefile by instruction I ran the "make" command and get the following error:
z
ermacroyd#DALEK:~/Downloads/rtl8821ce$ make
make ARCH=x86_64 CROSS_COMPILE= -C /lib/modules/4.15.0-20-generic/build M=/home/zermacroyd/Downloads/rtl8821ce modules
make[1]: Entering directory '/usr/src/linux-headers-4.15.0-20-generic'
CC [M] /home/zermacroyd/Downloads/rtl8821ce/core/rtw_cmd.o
CC [M] /home/zermacroyd/Downloads/rtl8821ce/core/rtw_security.o
CC [M] /home/zermacroyd/Downloads/rtl8821ce/core/rtw_debug.o
CC [M] /home/zermacroyd/Downloads/rtl8821ce/core/rtw_io.o
CC [M] /home/zermacroyd/Downloads/rtl8821ce/core/rtw_ioctl_query.o
CC [M] /home/zermacroyd/Downloads/rtl8821ce/core/rtw_ioctl_set.o
CC [M] /home/zermacroyd/Downloads/rtl8821ce/core/rtw_ieee80211.o
CC [M] /home/zermacroyd/Downloads/rtl8821ce/core/rtw_mlme.o
CC [M] /home/zermacroyd/Downloads/rtl8821ce/core/rtw_mlme_ext.o
CC [M] /home/zermacroyd/Downloads/rtl8821ce/core/rtw_mi.o
CC [M] /home/zermacroyd/Downloads/rtl8821ce/core/rtw_wlan_util.o
CC [M] /home/zermacroyd/Downloads/rtl8821ce/core/rtw_vht.o
CC [M] /home/zermacroyd/Downloads/rtl8821ce/core/rtw_pwrctrl.o
CC [M] /home/zermacroyd/Downloads/rtl8821ce/core/rtw_rf.o
CC [M] /home/zermacroyd/Downloads/rtl8821ce/core/rtw_recv.o
CC [M] /home/zermacroyd/Downloads/rtl8821ce/core/rtw_sta_mgt.o
CC [M] /home/zermacroyd/Downloads/rtl8821ce/core/rtw_ap.o
CC [M] /home/zermacroyd/Downloads/rtl8821ce/core/rtw_xmit.o
CC [M] /home/zermacroyd/Downloads/rtl8821ce/core/rtw_p2p.o
CC [M] /home/zermacroyd/Downloads/rtl8821ce/core/rtw_tdls.o
CC [M] /home/zermacroyd/Downloads/rtl8821ce/core/rtw_br_ext.o
In file included from ./include/linux/printk.h:350:0,
from ./include/linux/kernel.h:14,
from ./include/linux/skbuff.h:17,
from ./include/linux/if_arp.h:26,
from /home/zermacroyd/Downloads/rtl8821ce/core/rtw_br_ext.c:23:
./include/net/inet_connection_sock.h: In function ‘inet_csk_clear_xmit_timer’:
./include/linux/dynamic_debug.h:77:14: error: ‘KBUILD_MODNAME’ undeclared (first use in this function); did you mean ‘KBUILD_BASENAME’?
.modname = KBUILD_MODNAME, \
^
./include/linux/dynamic_debug.h:99:2: note: in expansion of macro ‘DEFINE_DYNAMIC_DEBUG_METADATA_KEY’
DEFINE_DYNAMIC_DEBUG_METADATA_KEY(name, fmt, .key.dd_key_false, \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/dynamic_debug.h:125:2: note: in expansion of macro ‘DEFINE_DYNAMIC_DEBUG_METADATA’
DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/printk.h:354:2: note: in expansion of macro ‘dynamic_pr_debug’
dynamic_pr_debug(fmt, ##__VA_ARGS__)
^~~~~~~~~~~~~~~~
./include/net/inet_connection_sock.h:216:3: note: in expansion of macro ‘pr_debug’
pr_debug("%s", inet_csk_timer_bug_msg);
^~~~~~~~
./include/linux/dynamic_debug.h:77:14: note: each undeclared identifier is reported only once for each function it appears in
.modname = KBUILD_MODNAME, \
^
./include/linux/dynamic_debug.h:99:2: note: in expansion of macro ‘DEFINE_DYNAMIC_DEBUG_METADATA_KEY’
DEFINE_DYNAMIC_DEBUG_METADATA_KEY(name, fmt, .key.dd_key_false, \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/dynamic_debug.h:125:2: note: in expansion of macro ‘DEFINE_DYNAMIC_DEBUG_METADATA’
DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/printk.h:354:2: note: in expansion of macro ‘dynamic_pr_debug’
dynamic_pr_debug(fmt, ##__VA_ARGS__)
^~~~~~~~~~~~~~~~
./include/net/inet_connection_sock.h:216:3: note: in expansion of macro ‘pr_debug’
pr_debug("%s", inet_csk_timer_bug_msg);
^~~~~~~~
./include/net/inet_connection_sock.h: In function ‘inet_csk_reset_xmit_timer’:
./include/linux/dynamic_debug.h:77:14: error: ‘KBUILD_MODNAME’ undeclared (first use in this function); did you mean ‘KBUILD_BASENAME’?
.modname = KBUILD_MODNAME, \
^
./include/linux/dynamic_debug.h:99:2: note: in expansion of macro ‘DEFINE_DYNAMIC_DEBUG_METADATA_KEY’
DEFINE_DYNAMIC_DEBUG_METADATA_KEY(name, fmt, .key.dd_key_false, \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/dynamic_debug.h:125:2: note: in expansion of macro ‘DEFINE_DYNAMIC_DEBUG_METADATA’
DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/printk.h:354:2: note: in expansion of macro ‘dynamic_pr_debug’
dynamic_pr_debug(fmt, ##__VA_ARGS__)
^~~~~~~~~~~~~~~~
./include/net/inet_connection_sock.h:232:3: note: in expansion of macro ‘pr_debug’
pr_debug("reset_xmit_timer: sk=%p %d when=0x%lx, caller=%p\n",
^~~~~~~~
scripts/Makefile.build:332: recipe for target '/home/zermacroyd/Downloads/rtl8821ce/core/rtw_br_ext.o' failed
make[2]: *** [/home/zermacroyd/Downloads/rtl8821ce/core/rtw_br_ext.o] Error 1
Makefile:1552: recipe for target '_module_/home/zermacroyd/Downloads/rtl8821ce' failed
make[1]: *** [_module_/home/zermacroyd/Downloads/rtl8821ce] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.15.0-20-generic'
Makefile:1897: recipe for target 'modules' failed
make: *** [modules] Error 2
The problem file is rtw_br_ext.c which uses headers from the Linux kernel. So there are NO KBUILD flags in the makefile. What is the best way to fix this?
do not make changes to the make file.
without making changes run the file and it will run Ok.
On that Github url, there is no instruction for changing the make file.

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>

link error with "undefined lua_xxxxx" when building lsnes

In my ubuntu 14.xx, I try to compile lsnes emulator to use the mario-ai script from aleju/mario-ai, and I've tried to google many solutions to solve the problem below:
Here is the output from the console:
make[3]: __all__.files' is up to date.
make[3]: Leaving directory/home/pengsuyu/software/lsnes/sourcecode/src/platform/macosx'
make[2]: Leaving directory /home/pengsuyu/software/lsnes/sourcecode/src/platform'
g++ -o lsnescat all_common.files all_platform.files-pthread -lboost_iostreams -lboost_filesystem -lboost_system -lz -lgcrypt -lgpg-error -L/usr/lib/x86_64-linux-gnu -lcurl -rdynamic -ldlcat core/all.ldflags lua/all.ldflags fonts/all.ldflags library/all.ldflags interface/all.ldflags video/all.ldflags emulation/all.ldflags cmdhelp/all.ldflags platform/all.ldflags
core/multitrack.o: In functionlua::state::get_string(int, std::string const&)':
/home/pengsuyu/software/lsnes/sourcecode/src/core/../../include/library/lua-base.hpp:317: undefined reference to lua_tolstring'
core/multitrack.o: In functionlua::state::get_bool(int, std::string const&)':
/home/pengsuyu/software/lsnes/sourcecode/src/core/../../include/library/lua-base.hpp:334: undefined reference to lua_toboolean'
core/multitrack.o: In functionlua::state::type(int)':
.
.
/home/pengsuyu/software/lsnes/sourcecode/src/library/lua.cpp:536: undefined reference to lua_close'
library/lua.o: In functionlua::state::pushcfunction(int ()(lua_State))':
/home/pengsuyu/software/lsnes/sourcecode/src/library/../../include/library/lua-base.hpp:504: undefined reference to lua_pushcclosure'
library/lua.o: In functionlua::state::getfield(int, char const*)':
/home/pengsuyu/software/lsnes/sourcecode/src/library/../../include/library/lua-base.hpp:506: undefined reference to lua_getfield'
library/lua.o: In functionlua::state::insert(int)':
/home/pengsuyu/software/lsnes/sourcecode/src/library/../../include/library/lua-base.hpp:509: undefined reference to lua_insert'
collect2: error: ld returned 1 exit status
make[1]: *** [lsnes] Error 1
make[1]: Leaving directory/home/pengsuyu/software/lsnes/sourcecode/src'
make: *** [src/all_files] Error 2
==================================
At the beginning, I think, the linker cannot find my lua library. So I tried to compile my main.cpp with test.lua.
main.cpp:
#include <stdio.h>
#include <iostream>
//extern "C"
//{
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
//} // liblua5.1-c++.a
lua_State * L;
int main ()
{
L = lua_open();
luaL_openlibs(L);
luaL_dofile(L, "d:\\test.lua");
return 0;
}
test.lua:
print("Hello World");
I write a MakeFile to generate the executable file "main":
main:main.o
gcc -o $# $< -llua5.1 -lstdc++
main.o:
gcc -c main.cpp
clean:
-rm *.o
It works when I add the compile option "-llua5.1" and "-lstdc++" otherwise it throws the same error as I compiled lsnes
I am not familiar with gcc and Makefile. Please help me to solve this problem.
I've solved my question
The way to solve this problem is just to change one line in the file named "options.build".
1. find the line "LUA=lua" in options.build
2. change this line to "LUA=lua5.1"
because the needed library is 5.1, so if you want to build it successfully, you must use the "lua5.1" library however the default configuration is "lua" not "lua5.1"

toolchain arm glibc 2.12.1 error

I try to create cross toolchian for arm
but have this error:
In file included from dl-lookup.c:28:0:
../glibc-ports-2.11/sysdeps/arm/dl-machine.h:29:0: warning: "VALID_ELF_ABIVERSION" redefined
In file included from dynamic-link.h:88:0,
from dl-load.c:34:
../glibc-ports-2.11/sysdeps/arm/dl-machine.h:29:0: warning: "VALID_ELF_ABIVERSION" redefined
../sysdeps/unix/sysv/linux/ldsodefs.h:62:0: note: this is the location of the previous definition
../glibc-ports-2.11/sysdeps/arm/dl-machine.h:30:0: warning: "VALID_ELF_OSABI" redefined
../sysdeps/unix/sysv/linux/ldsodefs.h:60:0: note: this is the location of the previous definition
../glibc-ports-2.11/sysdeps/arm/dl-machine.h:32:0: warning: "VALID_ELF_HEADER" redefined
../sysdeps/unix/sysv/linux/ldsodefs.h:58:0: note: this is the location of the previous definition
../glibc-ports-2.11/sysdeps/arm/dl-machine.h: In function 'elf_machine_load_address':
../glibc-ports-2.11/sysdeps/arm/dl-machine.h:81:38: warning: taking address of expression of type 'void'
../sysdeps/unix/sysv/linux/ldsodefs.h:62:0: note: this is the location of the previous definition
../glibc-ports-2.11/sysdeps/arm/dl-machine.h:30:0: warning: "VALID_ELF_OSABI" redefined
../sysdeps/unix/sysv/linux/ldsodefs.h:60:0: note: this is the location of the previous definition
../glibc-ports-2.11/sysdeps/arm/dl-machine.h:32:0: warning: "VALID_ELF_HEADER" redefined
../sysdeps/unix/sysv/linux/ldsodefs.h:58:0: note: this is the location of the previous definition
../glibc-ports-2.11/sysdeps/arm/dl-machine.h: In function 'elf_machine_load_address':
../glibc-ports-2.11/sysdeps/arm/dl-machine.h:81:38: warning: taking address of expression of type 'void'
dl-load.c: In function 'open_verify':
dl-load.c:1663:41: error: macro "VALID_ELF_ABIVERSION" passed 2 arguments, but takes just 1
dl-load.c:1662:12: error: 'VALID_ELF_ABIVERSION' undeclared (first use in this function)
dl-load.c:1662:12: note: each undeclared identifier is reported only once for each function it appears in
dl-load.c:1708:36: error: macro "VALID_ELF_ABIVERSION" passed 2 arguments, but takes just 1
dl-load.c:1577:3: warning: unused variable 'expected2'
make[2]: *** [/home/pahlevan/Desktop/rezaee/sources/glibc-build/elf/dl-load.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory `/home/pahlevan/Desktop/rezaee/sources/glibc-2.12.1/elf'
make[1]: *** [elf/subdir_lib] Error 2
make[1]: Leaving directory `/home/pahlevan/Desktop/rezaee/sources/glibc-2.12.1'
my configuration is :
gcc-4.5.1+linux.2.6.35.4+binutils-2.20.51+glibc-2.12.1+port-2.11
CLFS_TARGET="arm-pahlevan-linux-gnu"
cd /sources
tar -jxf glibc-2.12.1.tar.bz2
cd ./glibc-2.12.1
tar -jxf ../glibc-ports-2.11.tar.bz2
cp -v Makeconfig{,.orig}
sed -e 's/-lgcc_eh//g' Makeconfig.orig > Makeconfig
patch -Np1 -i ../glibc-2.12.1-gcc_fix-1.patch
patch -Np1 -i ../glibc-2.12.1-makefile_fix-1.patch
mkdir -v ../glibc-build
cd ../glibc-build
export CC="${CLFS_TARGET}-gcc"
export LD="${CLFS_TARGET}-ld"
export AS="${CLFS_TARGET}-as"
export RANLIB="${CLFS_TARGET}-ranlib"
../glibc-2.12.1/configure --prefix=/tools \
--host=${CLFS_TARGET} --build=${CLFS_HOST} --with-tls --with-__thread \
--disable-profile --enable-add-ons --with-binutils=/cross-tools/bin --with-headers=/tools/include \
--enable-kernel=2.6.22.5 --with-headers=/tools/include libc_cv_forced_unwind=yes libc_cv_c_cleanup=yes libc_cv_gnu89_inline=yes
make
make install
cd ..
rm -rf glibc-2.12.1 glibc-build
I solved my compile error (glic-ports-2.12.1)
the problem in this file
"glibc-ports-2.12.1/sysdeps/arm/dl-machine.h"
you must erase this lines :
#define VALID_ELF_ABIVERSION(ver) (ver == 0)
#define VALID_ELF_OSABI(osabi) (osabi == ELFOSABI_SYSV || osabi == ELFOSABI_ARM)
#define VALID_ELF_HEADER(hdr,exp,size) memcmp (hdr,exp,size-2) == 0 && VALID_ELF_OSABI (hdr[EI_OSABI]) && VALID_ELF_ABIVERSION (hdr[EI_ABIVERSION])
and replace with lines :
#ifndef VALID_ELF_ABIVERSION
#define VALID_ELF_ABIVERSION(ver) (ver == 0)
#endif
#ifndef VALID_ELF_OSABI
#define VALID_ELF_OSABI(osabi) (osabi == ELFOSABI_SYSV || osabi == ELFOSABI_ARM)
#endif
#ifndef VALID_ELF_HEADER
#define VALID_ELF_HEADER(hdr,exp,size) memcmp (hdr,exp,size-2) == 0 && VALID_ELF_OSABI (hdr[EI_OSABI]) && VALID_ELF_ABIVERSION (hdr[EI_ABIVERSION])
#endif

Resources