Using mingw-w64 and ./configure --host=i686-w64-mingw32.static, make fails and Makefile CC variable looks wrong - makefile

I am new to compiling.
I am trying to compile iperf3 for Windows 10 because there is no official Windows distribution of iperf3 and for the learning experience. I am trying to do so on the new Windows Subsystem for Linux feature via Bash on Ubuntu on Windows, also for the learning experience.
I installed mingw-w64, which should give me the proper compiler and environment necessary for cross-compiling:
sudo apt-get install mingw-w64
This put two directories into my /usr directory:
i686-w64-mingw32
x86_64-w64-mingw32
It also put a bunch of things that look like compilers into /usr/bin.
I unzipped the .tar.gz file from iperf3 and navigated into it. Then, I run ./configure --host=i686-w64-mingw32.static and it completes without errors.
I note that the output of the command has a worrisome line: checking for i686-w64-mingw32.static-gcc... no
I note that the Makefile's CC variable is set to gcc, which doesn't sound like the proper compiler.
Then, I run make. It fails with errors:
collect2: error: ld returned 1 exit status
make[2]: *** [iperf3] Error 1
make[2]: Leaving directory `/home/snip/iperf3/iperf-3.1.4/src'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/snip/iperf3/iperf-3.1.4/src'
make: *** [all-recursive] Error 1
I also see the line: libtool: warning: undefined symbols not allowed in i686-w64-mingw32.static shared libraries; building static only
I think that the ./configure is not working correctly since it appears to have not found the right compiler for my --host argument and put it in the Makefile.
What am I doing wrong?
EDIT:
I changed the command to ./configure --host=i686-w64-mingw32 per comments and it completes without error. But no makefile is created so make yields make: *** No targets specified and no makefile found. Stop.
What am I doing wrong, now?
EDIT 2:
Looks like the ./configure actually is failing. Last line of its output is nanosleep() required for timing operations., which seems to mean that its missing a library for nanosleep.
How do I get nanosleep?

mingw doesn't support nanosleep. So programs using it cannot be compiled using mingw-w64.

Related

How to compile tool and samples from within the kernel source tree? (e.g. bpftool, bpf samples)

GOAL: compile samples/bpf, compile bpf/bpftool and use them.
PROBLEM: on a VM with Ubuntu 18.04 bionic with a kernel 4.18.0-25-generic I've installed kernel src code executing apt install linux-source-4.18.0.
Now I cd into /usr/src/linux-source-4.18.0/linux-source-4.18.0/samples/bpf and I run make and the result is
make -C ../../ /usr/src/linux-source-4.18.0/linux-source-4.18.0/samples/bpf/ BPF_SAMPLES_PATH=/usr/src/linux-source-4.18.0/linux-source-4.18.0/samples/bpf
make[1]: Entering directory '/usr/src/linux-source-4.18.0/linux-source-4.18.0'
scripts/kconfig/conf --syncconfig Kconfig
***
*** Configuration file ".config" not found!
***
*** Please run some configurator (e.g. "make oldconfig" or
*** "make menuconfig" or "make xconfig").
***
scripts/kconfig/Makefile:40: recipe for target 'syncconfig' failed
make[3]: *** [syncconfig] Error 1
Makefile:562: recipe for target 'syncconfig' failed
make[2]: *** [syncconfig] Error 2
make[1]: *** No rule to make target 'include/config/auto.conf', needed by 'include/config/kernel.release'. Stop.
make[1]: Leaving directory '/usr/src/linux-source-4.18.0/linux-source-4.18.0'
Makefile:203: recipe for target 'all' failed
make: *** [all] Error 2
If I cd into ../samples/bpf and I run sudo make the result is
Auto-detecting system features:
... libbfd: [ OFF ]
... disassembler-four-args: [ OFF ]
CC map_perf_ring.o
CC xlated_dumper.o
CC perf.o
CC cfg.o
CC common.o
CC cgroup.o
CC main.o
main.c:36:10: fatal error: bfd.h: No such file or directory
#include <bfd.h>
^~~~~~~
compilation terminated.
Makefile:92: recipe for target 'main.o' failed
make: *** [main.o] Error 1
QUESTIONS: what am I missing? After I compile them if I want to write a program which, for example, needs to use bpftool I have to write the program inside the source kernel directory or I can write it everywhere?
Build errors
The first case (Makefile:562: recipe for target 'syncconfig' failed) fails because you run make from the top of the linux kernel repository, and before trying to compile the samples, the build system tries to load a config file to use for your system (but does not find one).
Before trying to build the samples (make -C samples/bpf), you can create a .config file from your current kernel configuration like this:
$ cp /usr/src/linux-headers-$(uname -r)/.config <path to repo>/.config
$ make olddefconfig
Or even simply generate a default config file from scratch:
$ make defconfig
See make help from top directory to see the available make options.
Your second error, regarding bfd.h not found, is that you miss a library. Libbfd on Ubuntu comes with binutils-dev, so apt install binutils-dev should do the trick.
Compiling the programs
Finally, regarding your question on compiling the programs:
You can write and build program from the kernel repository, just by creating a new sample and reusing the existing Makefiles.
You can also write and compile programs outside of the kernel tree. The basic clang (v4.0 or above, if possible v6.0 or above) command to compile them usually looks something like this:
$ clang -O2 -emit-llvm -c my_bpf_prog.c -o - | \
llc -march=bpf -filetype=obj -o my_bpf_prog.o
You can find examples of programs compiled out of the kernel tree in that repository (disclaimer: by my company) or in the XDP tutorial repo.

error: /NVIDIA_CUDA-9.0_Samples$ make CUDA-9.1_Samples$ make CUDA-9.2_Samples$ make CUDA-9.3_Samples$ make

I've had CUDA Toolkit 9.0 correctly installed on Ubuntu 16.04 with the package manager-based method since both the two commands
cat /proc/driver/nvidia/version
nvcc -V
returne the right infomation. However, it fails to make correctly when I tried to compile the official example NVIDIA_CUDA-9.0_Samples.
io#msi:~/NVIDIA_CUDA-9.0_Samples$ make
The main output is
/usr/bin/ld: can't find -lcudart
collect2: error: ld returned 1 exit status
Makefile:334: recipe for target 'simpleMPI' failed
make[1]: *** [simpleMPI] Error 1
make[1]: Leaving directory '/home/io/NVIDIA_CUDA-9.0_Samples/0_Simple/simpleMPI'
Makefile:52: recipe for target '0_Simple/simpleMPI/Makefile.ph_build' failed
make: *** [0_Simple/simpleMPI/Makefile.ph_build] Error 2
can anyone give me a hand? Thank you.
I think I've solved this problem. As I mentioned in the question, I've had CUDA Toolkit correctly installed in my computer, but it fails when execute
io#msi:~/NVIDIA_CUDA-9.0_Samples$ make
However, the following two commands
$ ~/NVIDIA_CUDA-9.0_Samples/1_Utilities/deviceQuery/deviceQuery
$ ~/NVIDIA_CUDA-9.0_Samples/1_Utilities/bandwidthTest/bandwidthTest
gives correct response "Result = pass". It's ok to ignore the "make error" listed above- I think.

install mpfr: get into multiple errors

I want to install mpfr package as a non root user. I built it using this:
./configure --with-gmp-lib=/data/home/parisa/gmp-6.1.2/lib
, but after make I got the following error
WARNING: 'makeinfo' is missing on your system.
You should only need it if you modified a '.texi' file, or
any other file indirectly affecting the aspect of the manual.
You might want to install the Texinfo package:
<http://www.gnu.org/software/texinfo/>
The spurious makeinfo call might also be the consequence of
using a buggy 'make' (AIX, DU, IRIX), in which case you might
want to install GNU make:
<http://www.gnu.org/software/make/>
make[1]: *** [mpfr.info] Error 127
make[1]: Leaving directory `/data/home/parisa/mpfr-3.1.5/doc'
make: *** [all-recursive] Error 1
I searched this error in Internet, but I couldn't find something useful and easy to understand. So, I tried to install texinfo, but after configuring this warning message appears:
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/>
make: *** [aclocal.m4] Error 127
I also tried autoreconf -f -i before configuring, but with no success. I tried to use automake installed on our cluster by using LD_LIBRARY_PATH but again nothing changed.

installing isolated gcc on server without sudo

I have access to a server (but don't have root permissions on there). To cut a long story short the admin won't upgrade to the newer version of gcc that I need, but has suggested that I can just install it locally.
I'm having some issues doing this, despite trying to follow the guide at http://gcc.gnu.org/install/index.html. I want to use the new versions of GMP, MPFR, and MPC that are installed now on the server.
I first go into my home dir on the server then mkdir mygcc which I then cd into (this is to be the build dir and is not a sub-dir of src dir), from there I do
/home/username/gcc-4.6.3/configure --with-gmp="/software/gmp-5.0.5" --with-
gmp-include="/software/gmp-5.0.5/include" --with-gmp-lib="/software/gmp-5.0.5/lib"
--with-mpfr="/software/mpfr-3.1.1" --with-mpfr-include="/software/mpfr-3.1.1/include"
--with-mpfr-lib="/software/mpfr-3.1.1/lib" --with-mpc-include="/home/username/usr/local
/include" --with-mpc-lib="/home/username/usr/local/lib" --prefix="/home/username/mygcc"
--with-local-prefix="/home/username/usr/local"
the src files that I unzipped are at /home/pmxlh1/gcc-4.6.3.
I also made the directories /home/username/usr/include, /home/username/usr/local etc and set the prefix flags to try and install various things there, but it also fails if I just leave those flags out for the same reasons.
When I get to make however it ends with
checking for suffix of object files... configure: error: in `/home/pmxlh1/mygcc/x86_64-
unknown-linux-gnu/libgcc':
configure: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details.
make[2]: *** [configure-stage1-target-libgcc] Error 1
make[2]: Leaving directory `/home/pmxlh1/mygcc'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/home/pmxlh1/mygcc'
make: *** [all] Error 2
Not sure if I'm going about this the correct way? But basically I want to install it in my home/dir and so that it uses the correct GMP/MPFR/MPC not the old versions that maybe lurking elsewhere on the server.
thanks for any help

dtrace: failed to compile script Preprocessor not found

I'm trying to test this script from oracle to get active NFS clients on Ubuntu 10.04, but I can' get it to run.
To achieve that, I first installed dtrace following these instructions. This is what I've done exactly:
apt-get install bison flex zlib1g-dev libelf-dev binutils-dev libdw-dev libc6-dev-i386
wget ftp://crisp.dyndns-server.com/pub/release/website/dtrace/dtrace-20121009.tar.bz2
tar xfj dtrace-20121009.tar.bz2
cd dtrace-20121009
make all
make install
make load
However, I get this warning when compiling:
=================================================================
=== You need /usr/lib/libdwarf.a and /usr/lib/libbfd.a installed to build.
===
=== apt-get install binutils-dev
=== apt-get install libdw-dev
===
=== Without these, we will not build ctfconvert (needed for
=== SDT structure definitions).
=================================================================
cd cmd/instr ; make --no-print-directory
cd usdt/c ; make --no-print-directory
tools/mkdriver.pl all
Executing: /usr/src/dtrace/dtrace-20121009/tools/make-me
make -C /lib/modules/2.6.38-16-server/build M=/usr/src/dtrace/dtrace-20121009/build-2.6.38-16-server/driver
CC [M] /usr/src/dtrace/dtrace-20121009/build-2.6.38-16-server/driver/systrace.o
LD [M] /usr/src/dtrace/dtrace-20121009/build-2.6.38-16-server/driver/dtracedrv.o
Building modules, stage 2.
MODPOST 1 modules
LD [M] /usr/src/dtrace/dtrace-20121009/build-2.6.38-16-server/driver/dtracedrv.ko
tools/mkctf.sh
build/ctfconvert not available - so not building the linux.ctf file
NOTE: The build is complete, but build/ctfconvert is not available.
This means you will get run time errors from the io.d and sched.d files
due to undefined kernel structure definitions. Simply delete or rename
these files until a fix can be put in place to handle older
distros which do not have the required libdwarf dependencies.
(Typical error is references to undefined struct definitions such
as dtrace_cpu_t).
sync
I've installed libdw-dev and binutils-dev, but taking a look at the makefile, it seems it looks for libdwarf.so, and libdw on my system is named libdw.so.
To circunvent this, I create a symlink with ln -s /usr/lib/libdw.so /usr/lib/libdwarf.so. After doing so, compiling fails.
cd cmd/ctfconvert ; make --no-print-directory
gcc -g -I. -I../../ -I../../libctf -I../../common -I../../uts/common -I../../linux -I/usr/include/libdwarf -c dwarf.c
In file included from dwarf.c:94:
/usr/include/dwarf.h:56: error: expected identifier before numeric constant
/usr/include/dwarf.h:136: error: expected identifier before numeric constant
/usr/include/dwarf.h:321: error: expected identifier before numeric constant
/usr/include/dwarf.h:461: error: expected identifier before numeric constant
/usr/include/dwarf.h:517: error: expected identifier before numeric constant
make[3]: *** [../../build/ctfconvert.obj/dwarf.o] Error 1
make[2]: *** [all] Error 2
make[1]: *** [do_cmds] Error 2
tools/bug.sh
make: *** [all] Error 1
So, let's undo that. I remove the symlink, compile again, run make install and make load and hope everything is fine. And everything seems to be fine.
But, then I try to run the script mentioned above, and it fails:
# ./get_ngs_clients.d
dtrace: failed to compile script ./get_ngs_clients.d: Preprocessor not found
I have no clue on what's going on. I have gcc installed, just in case.
# dpkg -l | grep gcc
ii gcc 4:4.4.3-1ubuntu1 The GNU C compiler
ii gcc-4.4 4.4.3-4ubuntu5.1 The GNU C compiler
ii gcc-4.4-base 4.4.3-4ubuntu5.1 The GNU Compiler Collection (base package)
ii gcc-4.4-multilib 4.4.3-4ubuntu5.1 The GNU C compiler (multilib files)
ii gcc-multilib 4:4.4.3-1ubuntu1 The GNU C compiler (multilib files)
ii lib32gcc1 1:4.4.3-4ubuntu5.1 GCC support library (32 bit Version)
ii libgcc1 1:4.4.3-4ubuntu5.1 GCC support library
If you do not have libdwarf.a on your system, the ctfconvert tool will not build. (libdwarf.a and libdw.a are not the same).
If ctfconvert does not build, then any of your own, or the dtrace etc/*.d scripts may not load. (Dtrace force loads these scripts for you automatically, which is annoying). Any script which relies on structure definitions will then fail.
As of May 2013, I am looking at seeing what it takes to update to libdw.a since this seems to be the modern replacement for libdwarf.
(posted by the 'author' of DTrace/Linux).
Have you tried to add --enable-dtrace=false to /.configure?
Or maybe --with-dtrace=false?
That should do the trick I think...

Resources