I am new to building C lib and have mostly worked with python. My goal is to take the source code from https://github.com/torvalds/linux and build a custom driver for USB/IP (https://github.com/torvalds/linux/tree/master/drivers/usb/usbip) module (some modification).
I copied only /tool/usbip/ assuming that USB and USB-IP are already present in the alpine.
I have set up a docker Image:
FROM alpine
COPY . .
RUN apk add build-base autoconf automake libtool eudev-dev libusb-dev
WORKDIR /tool/usbip/
RUN ./autogen.sh
RUN ./configure
RUN make install
I am getting the following error for make install:
Step 7/7 : RUN make install
---> Running in 48f53c225a99
Making install in libsrc
make[1]: Entering directory '/tool/usbip/libsrc'
CC libusbip_la-names.lo
In file included from names.c:23:
usbip_common.h:18:10: fatal error: linux/usb/ch9.h: No such file or directory
18 | #include <linux/usb/ch9.h>
| ^~~~~~~~~~~~~~~~~
compilation terminated.
make[1]: *** [Makefile:459: libusbip_la-names.lo] Error 1
make[1]: Leaving directory '/tool/usbip/libsrc'
make: *** [Makefile:500: install-recursive] Error 1
This could mean that alpine doesn't have a USB drive. How do I compile and install the driver in that docker?
Another solution can be to build the entire Linux code from the repo, but can I use alpine and add a USB-IP driver there, as I can see that alpine is very lightweight?
I see some Kconfig and Makefile, but I need guidance on building the required driver, as my task also requires modifying drivers/USB/usbip code and building the driver for usbip.
Some blog links or youtube videos on build drivers will also help, but I was not able to find any good resources online.
Updated docker file:
FROM alpine:latest
COPY . /linux
RUN apk add build-base autoconf \
automake libtool eudev-dev \
linux-headers flex bison gmp-dev \
mpc1-dev mpfr-dev
WORKDIR /linux
RUN zcat /proc/config.gz > .config
RUN make olddefconfig
RUN make modules_prepare
RUN make M=drivers/usb/usbip modules
WORKDIR /linux/tools/usb/usbip/
RUN ./autogen.sh
RUN ./configure
RUN make install
Download kernel sources and go to its root.
Copy .config for system you want to build for. E.g. if it is your running system and it provides /proc/config.gz then zcat /proc/config.gz > .config
make olddefconfig
Ensure CONFIG_USBIP and other modules are enabled as a modules:
$ grep CONFIG_USBIP .config
CONFIG_USBIP_CORE=m
CONFIG_USBIP_VHCI_HCD=m
CONFIG_USBIP_VHCI_HC_PORTS=8
CONFIG_USBIP_VHCI_NR_HCS=1
CONFIG_USBIP_HOST=m
# CONFIG_USBIP_DEBUG is not set
If not, run make nconfig (or make menuconfig), navigate to Device Drivers->USB support->USB/IP support and enable it as a module (<M>); save configuration.
make modules_prepare
make M=drivers/usb/usbip modules
Your modules are in drivers/usb/usbip/
Related
I have downloaded below debian image from latest images site
Debian 8.7 2017-03-19 4GB SD LXQT
I have attached a adxl345 accelerometer, and with user space tools its working fine.
Now I am trying to attach a kernel driver i.e in adxl345. I put the source files in
/home/debian/Desktop/adxl345
and issued make.
I get this error
root#beaglebone:/home/debian/Desktop/adxl345# make
make -C /lib/modules/4.4.54-ti-r93/build M=/home/debian/Desktop/adxl345 modules
make[1]: *** /lib/modules/4.4.54-ti-r93/build: No such file or directory. Stop.
Makefile:13: recipe for target 'default' failed
make: *** [default] Error 2
I checked
root#beaglebone:/lib/modules/4.4.54-ti-r93# ls
extra modules.builtin modules.devname modules.symbols.bin
kernel modules.builtin.bin modules.order
modules.alias modules.dep modules.softdep
modules.alias.bin modules.dep.bin modules.symbols
there is no build directory. I tried to update kernel headers
sudo apt-get install linux-headers-linux-headers-4.4.54-ti-r93
but it says
E: Unable to locate package linux-headers-linux-headers-4.4.54-ti-r93
How I am going to build the drivers?
I did not updated cache
sudo apt-get update
Once updated we can check at /lib/modules
there will be a build directory.
Now it should be building.
I spent whole day trying to use QtWayland.Compositor 1.0 in Qt creator. I have followed all the steps from there https://wiki.qt.io/QtWayland but I get the following error. I don't know what does it mean, that is my first contact with linux. I have the newest linux mint on a vm.
$ sudo make install
cd src/ && ( test -e Makefile || /usr/lib/x86_64-linux-gnu/qt5/bin/qmake /home/emil/wayland/qtwayland/src/src.pro -o Makefile ) && make -f Makefile install
make[1]: Entering directory '/home/emil/wayland/qtwayland/src'
make[1]: Nothing to be done for 'install'.
make[1]: Leaving directory '/home/emil/wayland/qtwayland/src'
cd examples/ && ( test -e Makefile || /usr/lib/x86_64-linux-gnu/qt5/bin/qmake /home/emil/wayland/qtwayland/examples/examples.pro -o Makefile ) && make -f Makefile install
make[1]: Entering directory '/home/emil/wayland/qtwayland/examples'
cd wayland/ && ( test -e Makefile || /usr/lib/x86_64-linux-gnu/qt5/bin/qmake /home/emil/wayland/qtwayland/examples/wayland/wayland.pro -o Makefile ) && make -f Makefile install
make[2]: Entering directory '/home/emil/wayland/qtwayland/examples/wayland'
Some of the required modules (qtHaveModule(waylandcompositor) qtConfig(opengl)) are not available.
Skipped.
make[2]: Leaving directory '/home/emil/wayland/qtwayland/examples/wayland'
make[1]: Leaving directory '/home/emil/wayland/qtwayland/examples'
how can I fix that? All I want to do is to run the examples from the Qt installation :c.
Most of the content on the wiki page was written many years ago. I made an effort to clean up things I know are not relevant anymore and hope to get the wiki page in a usable state.
The problem as I see it, is that there are so many ways to build Qt, and how to build QtWayland depends on that.
The two most common options:
Building QtWayland as part of a full (or toplevel Qt build)
When configuring Qt, you can add -feature-wayland-server to you configure line. And it will make sure the wayland compositor API is part of your Qt build. Configure will then fail if the dependencies of QtWayland is not met. I.e. if you need dev packages for Wayland.
Then you can either just run make which will build all of Qt as you configured it, or run make module-qtwayland which should only build QtWayland and the required dependencies (qtbase, qtdeclarative, qtxmlpatterns).
Building QtWayland against an existing Qt installation (without QtWayland)
First you need to find qmake for your desired Qt version. If it's the one provided by the system, it's usually on your PATH already. If you are going to use Qt provided by the Qt installer, it's usually in ~/Qt/5.10.0/gcc_64/bin/qmake or equivalent for your version and architecture.
Clone qtwayland
git clone git://code.qt.io/qt/qtwayland.git
cd qtwayland
git checkout v5.10.0 #or whatever version your qmake reports
Configure with qmake
qmake
or
~/Qt/5.10.0/gcc_64/bin/qmake
You should now see:
Qt Wayland Client ........................ yes
Qt Wayland Compositor .................... yes
In your terminal, or else you are probably missing some dependencies.
Build with make
make
make install
Build examples
Depending on your configuration, this may need to be run explicitly:
make sub-examples
I want to install the kernel modules to lib/modules/ . Actually there has to be created a folder in lib/modules/(uname-r) after doing make modules , but there are only created 3 folders called "build", "kernel" and "source". I also get an error after make modules:
DEPMOD 3.4.79
WARNING: COULDN't open directory /lib/modules/3.4.79: No such file or direcoty
FATAL: Could not open /lib/modules/3.4.79/modules.dep.temp for writing: No suhc file or directory
make: *** [_modinst_post] Error 1
Indeed there is no directory called that, but how can I add it?
Did you try \"make modules_install\"?
to install modules
make modules_install
to install kernel
make install
Out-of-tree modules
For the benefit of future Googlers, this is what Buildroot 2018.05 does to install out-of-tree modules for LInux v4.19:
cd linux_kernel_source
mkdir -p /build/dir/default/x86_64/target/lib/modules/4.19.0/extra
/usr/bin/make -f ./scripts/Makefile.modinst
mkdir -p /build/dir/default/x86_64/target/lib/modules/4.19.0/extra
cp /build/dir/default/x86_64/build/kernel_modules-1.0/./buildroot_dep.ko /build/dir/default/x86_64/target/lib/modules/4.19.0/extra
/build/dir/default/x86_64/host/bin/x86_64-buildroot-linux-uclibc-strip --strip-debug /build/dir/default/x86_64/target/lib/modules/4.19.0/extra/buildroot_dep.ko
/bin/bash ./scripts/depmod.sh /build/dir/default/x86_64/host/sbin/depmod 4.19.0
So we can see that it uses the ./scripts/Makefile.modinst and ./scripts/depmod.sh in tree scripts, plus some ugly manual copying of the modules.
Found by building a package that contains kernel modules with V=1 and kernel_modules_package_name-reconfigure and simplifying the output commands, works every time :-).
The only missing question is how depmod was obtained, so we do another verbose build with host-kmod-reconfigure, and basically obtain:
./configure
--prefix="/build/dir/default/x86_64/host"
--sysconfdir="/build/dir/default/x86_64/host/etc"
--localstatedir="/build/dir/default/x86_64/host/var"
where the source is obtained from: https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git
In tree modules are installed with make modules_install as mentioned at: How to install Kernel Modules from Source Code. Error while make process
When I try to install any compressed file into Linux I never can, because:
When I execute ./configure the system says bash: ./configure: No such file or directory.
When I execute sudo ./configure the system says sudo: ./configure: command not found.
Worst , when I execute make the system says make: *** No rule to make target '/usr/lib64/qt-3.3/mkspecs/default/qmake.conf', needed by 'Makefile'. Stop.
With make install the system says make: *** No rule to make target '/usr/lib64/qt-3.3/mkspecs/default/qmake.conf', needed by 'Makefile'. Stop.
Completion: I can't install nothing that is not in the repository into my system.
Note: I use Linux Mint XFCE 13 (Maya).
What can I do to solve this unpleasant problem?
As ManDVD's Makefile says:
#############################################################################
# Makefile for building: mandvd
# Generated by qmake (1.07a) (Qt 3.3.8b) on: Sun Mar 8 18:32:50 2009
# Project: mandvd.pro
# Template: app
# Command: $(QMAKE) -o Makefile mandvd.pro
#############################################################################
Makefile was autogenerated by qmake.
I'm no expert at using qmake, but I think executing qmake will re-generate Makefile, so then you can run make && sudo make install as INSTALL file says.
You should've already discovered project is kind of messy (if not discontinued at all), so take care, and may the force be with you :)
I'm trying to install GCC into /my/custom/path/gcc
but for some reason it installs into the normal installation path.
the commands i'm using:
configure --target=i686-pc-linux-gnu --disable-nls --enable-languages=c,c++ --without-headers
make DESTDIR=/my/custom/path/gcc
make DESTDIR=/my/custom/path/gcc install
What am I doing wrong?
You should run (in a new build tree outside of the source tree)
/your/source/path/to/gcc/configure --target=i686-pc-linux-gnu --prefix=/my/custom/path/gcc ...
and then GCC will become installed in /my/custom/path/gcc/bin/ with include files in /my/custom/path/gcc/include/, libraries in /my/custom/path/gcc/lib/ etc etc
I suggest using /opt/ or $HOME/pub as your prefix and you might also be interested by the --program-suffix=-foo option
(do that in a fresh new build tree outside of the source tree; your previous one is rotten)
After successive compilation with make, you can run in your build tree
make install DESTDIR=/tmp/mygccinst/
and finally, you can copy the definitive files with something like
cp -va /tmp/mygccinst/ /
You may need to run this copy as root...
PS the installation prefix is built-in the gcc driver binary, which actually runs cc1 or cc1plus etc...