Compiling kernel module - what packages are required - c

Until now, When I compiled my kernel module, I installed: kernel-devel, kernel-headers.
Later on, I had to include kernel sources.
So now the packages I install in order to compile my kernel module are: kernel-devel, kernel-headers and kernel.src.rpm (kernel source).
Im in the process of creating a "build machine" that will check for Available latest kernel, download necessary packages and compile the kernel module for that kernel.
I dont want to install the package, just to download it, and copy the files to their location (download kernel.src.rpm, rpm2cpio, cpio, and copy to /lib/modules/kernel-X-Y/)
I noticed that if kernel src is installed, there is not need for kernel-headers.
kernel-devel is needed ??, I am not sure it is, when trying to install without kernel-devel, I get the following exception:
make[2]: Entering directory `/usr/src/kernels/3.10.0-693.el7.x86_64'
ERROR: Kernel configuration is invalid.
include/generated/autoconf.h or include/config/auto.conf are missing.
Run 'make oldconfig && make prepare' on kernel src to fix it.
WARNING: Symbol version dump ./Module.symvers
is missing; modules will have no dependencies and modversions.
What am I missing ? If i install kernel-devel, then i dont get this exception, I dont want to install kernel-devel.

Before you can run make to compile the kernel you need to run make oldconfig or copy a .config file over into the build tree. make oldconfig will then use the .config and update it to the newer kernel.
You also have other options:
a simple make help | grep -i config in the kernel source directory shows:
Configuration targets:
config - Update current config utilising a line-oriented program
nconfig - Update current config utilising a ncurses menu based
menuconfig - Update current config utilising a menu based program
xconfig - Update current config utilising a Qt based front-end
gconfig - Update current config utilising a GTK+ based front-end
oldconfig - Update current config utilising a provided .config as base
localmodconfig - Update current config disabling modules not loaded
localyesconfig - Update current config converting local mods to core
silentoldconfig - Same as oldconfig, but quietly, additionally update deps
defconfig - New config with default from ARCH supplied defconfig
savedefconfig - Save current config as ./defconfig (minimal config)
allnoconfig - New config where all options are answered with no
allyesconfig - New config where all options are accepted with yes
allmodconfig - New config selecting modules when possible
alldefconfig - New config with all symbols set to default
randconfig - New config with random answer to all options
listnewconfig - List new options
olddefconfig - Same as silentoldconfig but sets new symbols to their
kvmconfig - Enable additional options for kvm guest kernel support
xenconfig - Enable additional options for xen dom0 and guest kernel support
tinyconfig - Configure the tiniest possible kernel
kselftest-merge - Merge all the config dependencies of kselftest to existing
.config.
configuration. This is e.g. useful to build with nit-picking config.
i386_defconfig - Build for i386
x86_64_defconfig - Build for x86_64
make O=dir [targets] Locate all output files in "dir", including .config

Related

How to specify config file for building buildroot?

I downloaded buildroot package and tried to build using a config file under /configs directory such as raspberrypi3_64_defconfig.
If I run make menuconfig, menuconfig screen loads a default config.
If I copy the raspberrypi3_64_defconfig under /buildroot and change the name to .config and run make menuconfig, then I can see the configs for raspberrypi3_64.
Is there any way I can specify the raspberrypi3_64_defconfig when I run make menuconfig without copying the file and renaming it?
make raspberrypi3_64_defconfig is what you need

hugo builds with read-only source-tree

We would like to integrate hugo for documentation generation in our automake project.
The problem i'm facing is, that I would like to support
out-of-tree builds
builds from read-only source trees (which is related to out-of-tree builds)
out-of-tree builds kind of work with:
hugo --source $(srcdir) --destination $(abs_builddir)
However, when my source-tree is read-only (e.g. as tested by make distcheck), this fails with:
$ make
hugo --source ../../../hugo --destination "<<SRCDIR>>/project-0.1/_build/sub/hugo"
Error: add site dependencies: create deps: failed to create file caches from configuration: mkdir <<SRCDIR>>/project-0.1/hugo/resources: permission denied
Total in 1 ms
make: *** [Makefile:555: all] Error 255
Obviously, hugo tries to create it's "file caches" as a resources/ directory in the (read-only) <<SRCDIR>>.
How can I tell hugo to creat this "file caches" directory in an alternative (writeable) place?
I tried setting --cacheDir (to $(abs_builddir), but this didn't change anything.
apparently there's a resourceDir config-file option, but afaict that is not available via the cmdline (and I don't know whether it would actually help).

How to configure build input packages/dependencies within Nix development shells?

I'm not using NixOS but I wrote a flake that I'm using to generate a dev shell to build a Rust project (this is essentially just the audio example from the Bevy repository). My issue is that I encounter the following error when attempting to run the project in the dev shell:
$ nix --extra-experimental-features nix-command --extra-experimental-features flakes develop
bash-4.4$ cargo run
Finished dev [unoptimized + debuginfo] target(s) in 6.62s
Running `target/debug/audio`
ALSA lib pcm_dmix.c:1075:(snd_pcm_dmix_open) unable to open slave
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: NoDevice', /home/a/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_audio
-0.5.0/src/audio_output.rs:22:67
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
bash-4.4
One of the dependencies of the project is the Bevy crate which requires ALSA, so I'm assuming the issue is because the ALSA package exposed by the dev shell is probably misconfigured. I use PipeWire on my actual system (I think it also uses ALSA as a backend) and I tried adding ALSA and PipeWire as one of the buildInputs for the flake, but I'm not sure how I'm supposed to configure these within the dev shell. According to this issue on the Bevy repository, the usual fix for this issue, at least for Arch-based distros, is to install the pipewire-alsa package. I'm not sure what the equivalent of doing that is in the context of a Nix dev shell is though, since there is no pipewire-alsa package in nixpkgs that I can add to my flake. So with that said, how should I go about configuring ALSA or PipeWire in the dev shell?

Error: chaincode install failed with status: 500

I have created a chaincode and I am trying to install it on the peer organization. I am able to package the chaincode on the peer organization but when it turns to install phase, I got error message:
Error: chaincode install failed with status: 500 - failed to invoke backing implementation of 'InstallChaincode': could not build chaincode: docker build failed: docker image build failed: docker build failed: Error returned from build: 2
# github.com/Nik-U/pbc
/usr/lib/gcc/x86_64-alpine-linux-musl/9.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lpbc
/usr/lib/gcc/x86_64-alpine-linux-musl/9.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lgmp
collect2: error: ld returned 1 exit status
I am using Nik-U's go wrapper of the PBC library Nik-U pbc. In his homepage, description shows:
This package must be compiled using cgo. It also requires the installation of GMP and PBC. During the build process, this package will attempt to include <gmp.h> and <pbc/pbc.h>, and then dynamically link to GMP and PBC.
Here's what I have tried:
I have manually configured the GMP and PBC under the Nik-U's directory and changed all the addresses of <gmp.h> and <pbc.h> to the right location.
I have tried to use command ln -s /usr/local/lib/libpbc.so libpbc.so and ln -s /usr/local/lib/libgmp.so to create link library files, but it shows the same error message.
As the Nik-U wrapper uses cgo, I changed the sentence in c.go file from #cgo LDFLAGS: -lpbc -lgmp to #cgo LDFLAGS: -L/usr/local/lib -lpbc -lgmp. Inside the /usr/loca/lib there are: libgmp.a libgmp.la libgmp.so libgmp.so.10 libgmp.so.10.4.1 libpbc.a libpbc.la libpbc.so libpbc.so.1 libpbc.so.1.0.0. This change did not work. I still got the same error message.
I copied all files of the directory /usr/local/lib to the same directory of the docker container using command docker cp **.so containerName:/usr/local/lib/. It does not work.
Here are what I doubt that may be the problem:
I am using go.mod file to manage all dependencies but the go.mod does not manage the original PBC library and GMP library. However, I do not know how to use go module to manage these two libraries (written in C?).
Nik-U's pbc wrapper has to link PBC and GMP libraries dynamically, which is why my efforts to manually configure and install them in the subdirectory, and change the include information such as from #include <pbc/pbc.h> to #include <pbc-0.5.14/include/pbc.h> of no use.
Can anybody help..
In hyperledger fabric, chaincode is executed in the form of sandbox based on virtual environment. In other words, it is not executed in the peer, but in a new docker container.
Even if you move the *.so file to the peer, it seems that a cannot find error has occurred because the newly created chaincode does not import it.
To solve this, two tasks are required.
1. import library to fabric-ccenv docker image
The go chaincode container of the fabric occurs in the image of fabric-ccenv. Based on the fabric-ccenv image, create a new image with your library embedded
FROM fabric-ccenv:<your_fabric_tag>
COPY <your_src_library_path> <your_target_library_path>
docker build -f <your_dockerfile> -t fabric-ccenv:<your_new_fabric_tag>
2. Change core.yaml of fabric-peer
You have to change the peer's configuration. That is, set the configuration for chaincode in core.yaml.
You can set information about fabric-ccenv in the builder item of chaincode. Change this value to the value of your image created in step 1 above.
chaincode:
id:
path:
name:
#builder: $(DOCKER_NS)/fabric-ccenv:$(TWO_DIGIT_VERSION)
builder: $(DOCKER_NS)/fabric-ccenv:<your_new_fabric_tag>
pull: false
golang:
runtime: $(DOCKER_NS)/fabric-baseos:$(TWO_DIGIT_VERSION)
dynamicLink: false

How can I install the libwebsocket library in Ubuntu?

I am trying to install the libwebsocket in my ubuntu .
so I downloaded the project https://github.com/warmcat/libwebsockets
unzipped it and I followed the installation instruction.
I type the command cmake FH and get the following messages.
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:State or Province Name (full name) [Some-State]:Locality Name (eg, city) []:Organization Name (eg, company) [Internet Widgits Pty Ltd]:Organizational Unit Name (eg, section) []:Common Name (e.g. server FQDN or YOUR name) []:Email Address []:SUCCSESFULLY generated SSL certificate
Generating API documentation
-- Looking for RPMTools... - rpmbuild NOT FOUND
---------------------------------------------------------------------
Settings: (For more help do cmake -LH <srcpath>
---------------------------------------------------------------------
LWS_WITH_SSL = ON (SSL Support)
LWS_SSL_CLIENT_USE_OS_CA_CERTS = 1
LWS_USE_CYASSL = OFF (CyaSSL replacement for OpenSSL)
LWS_WITHOUT_BUILTIN_GETIFADDRS = OFF
LWS_WITHOUT_CLIENT = OFF
LWS_WITHOUT_SERVER = OFF
LWS_LINK_TESTAPPS_DYNAMIC = OFF
LWS_WITHOUT_TESTAPPS = OFF
LWS_WITHOUT_TEST_SERVER = OFF
LWS_WITHOUT_TEST_SERVER_EXTPOLL = OFF
LWS_WITHOUT_TEST_PING = OFF
LWS_WITHOUT_TEST_CLIENT = OFF
LWS_WITHOUT_TEST_FRAGGLE = OFF
LWS_WITHOUT_DEBUG = OFF
LWS_WITHOUT_EXTENSIONS = OFF
LWS_WITH_LATENCY = OFF
LWS_WITHOUT_DAEMONIZE = OFF
LWS_USE_LIBEV =
LWS_IPV6 = OFF
LWS_WITH_HTTP2 = OFF
---------------------------------------------------------------------
-- Configuring done
-- Generating done
-- Build files have been written to: /home/maroua/libwebsocket/libwebsockets-master
-- Cache values
// Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.
CMAKE_BUILD_TYPE:STRING=
// Install path prefix, prepended onto install directories.
CMAKE_INSTALL_PREFIX:PATH=/usr/local
// Libwebsockets include directories
LIBWEBSOCKETS_INCLUDE_DIRS:PATH=/home/maroua/libwebsocket/libwebsockets-master/lib;/home/maroua/libwebsocket/libwebsockets-master
// Libwebsocket libraries
LIBWEBSOCKETS_LIBRARIES:STRING=websocket;websockets_shared
// Libwebsocket shared library
LIBWEBSOCKETS_LIBRARIES_SHARED:STRING=websockets_shared
// Libwebsocket static library
LIBWEBSOCKETS_LIBRARIES_STATIC:STRING=websocket
// Path to the CyaSSL include directory
LWS_CYASSL_INCLUDE_DIRS:PATH=
// Path to the CyaSSL library
LWS_CYASSL_LIB:PATH=
// Installation directory for executables
LWS_INSTALL_BIN_DIR:PATH=bin
// Installation directory for CMake files
LWS_INSTALL_CMAKE_DIR:PATH=lib/cmake/libwebsockets
// Installation directory for example files
LWS_INSTALL_EXAMPLES_DIR:PATH=bin
// Installation directory for header files
LWS_INSTALL_INCLUDE_DIR:PATH=include
// Installation directory for libraries
LWS_INSTALL_LIB_DIR:PATH=lib
// Compile with support for ipv6
LWS_IPV6:BOOL=OFF
// Link the test apps to the shared version of the library. Default is to link statically
LWS_LINK_TESTAPPS_DYNAMIC:BOOL=OFF
// Server SSL certificate directory
LWS_OPENSSL_CLIENT_CERTS:PATH=../share
// SSL support should make use of OS installed CA root certs
LWS_SSL_CLIENT_USE_OS_CA_CERTS:BOOL=ON
// Use CyaSSL replacement for OpenSSL. When settings this, you also need to specify LWS_CYASSL_LIB and LWS_CYASSL_INCLUDE_DIRS
LWS_USE_CYASSL:BOOL=OFF
// Search the system for ZLib instead of using the included one (on Windows)
LWS_USE_EXTERNAL_ZLIB:BOOL=OFF
// Don't use BSD getifaddrs implementation from libwebsockets if it is missing (this will result in a compilation error) ... Default is your libc provides it. On some systems such as uclibc it doesn't exist.
LWS_WITHOUT_BUILTIN_GETIFADDRS:BOOL=OFF
// Don't build the client part of the library
LWS_WITHOUT_CLIENT:BOOL=OFF
// Don't build the daemonization api
LWS_WITHOUT_DAEMONIZE:BOOL=OFF
// Don't compile debug related code
LWS_WITHOUT_DEBUG:BOOL=OFF
// Don't compile with extensions
LWS_WITHOUT_EXTENSIONS:BOOL=OFF
// Don't build the server part of the library
LWS_WITHOUT_SERVER:BOOL=OFF
// Don't build the libwebsocket-test-apps
LWS_WITHOUT_TESTAPPS:BOOL=OFF
// Don't build the client test application
LWS_WITHOUT_TEST_CLIENT:BOOL=OFF
// Don't build the ping test application
LWS_WITHOUT_TEST_FRAGGLE:BOOL=OFF
// Don't build the ping test application
LWS_WITHOUT_TEST_PING:BOOL=OFF
// Don't build the test server
LWS_WITHOUT_TEST_SERVER:BOOL=OFF
// Don't build the test server version that uses external poll
LWS_WITHOUT_TEST_SERVER_EXTPOLL:BOOL=OFF
// Compile with support for http2
LWS_WITH_HTTP2:BOOL=OFF
// Build latency measuring code into the library
LWS_WITH_LATENCY:BOOL=OFF
// Compile with support for libev
LWS_WITH_LIBEV:BOOL=OFF
// Include SSL support (default OpenSSL, CyaSSL if LWS_USE_CYASSL is set)
LWS_WITH_SSL:BOOL=ON
// The RPM builder tool
RPMTools_RPMBUILD_EXECUTABLE:FILEPATH=RPMTools_RPMBUILD_EXECUTABLE-NOTFOUND
I tried to compile a C program that uses libwebsocket.h, it tells me that it does not exist.
Can any one show me the right way to install this lib.
Thanks for any help .
A simple way to install libwebsocket in Ubuntu is to use this command in a terminal:
sudo apt-get install libwebsockets-dev
This command will install the version 1.2.
The libwebsockets.h file will be located at /usr/include/libwebsockets.h
An other way to have this library is to get the latest version (1.4 at the moment) from GitHub. To do that open a Terminal and go in the directory you want to get the library (I will call it lib_dir).
When you are in the lib_dir directory enter this command to get the code:
git clone https://github.com/warmcat/libwebsockets.git
When the command finish you will find a directory named libwebsockets.
The libwebsockets.h file will be located at lib_dir/libwebsockets/lib
If you need / want to build the library and install it in your system go in lib_dir then enter the following commands:
sudo apt-get install libssl-dev
mkdir build
cd build
cmake ..
make
sudo make install
ldconfig
This will install the library in /usr/local/include.
And to make sure of the version you just installed:
pkg-config --modversion libwebsockets
Finally you need to include in the compiler (include paths -I):
/usr/local/include
In the linker libraries (Libraries -l):
websockets
Finally (Library search path -L):
/usr/local/lib

Resources