how to build liburing - c++

I am build liburing which is a user interface for io_uring features.
But when I run ./configure it throws this error:
/tmp/fio-conf--21449-.c:2:10: fatal error: linux/time_types.h: No such file or directory
#include <linux/time_types.h>
^~~~~~~~~~~~~~~~~~~~
compilation terminated.
but I found in
/usr/src/linux-headers-5.3.0-46-generic/include/uapi/linux$ ls time_types.h
time_types.h
My kernal version is
uname -rs
Linux 5.3.0-46-generic
I'm sure that the 5.3 version is supporting io_uring (which has already been supported by 5.1)
so how to Update kernel/libc headers to support this?

First, you have to clone the repo:
git clone https://github.com/axboe/liburing.git
Then you can build:
make -C ./liburing
After that, you can compile your program.c with liburing:
gcc program.c -o ./program -I./liburing/src/include/ -L./liburing/src/ -Wall -O2 -D_GNU_SOURCE -luring

Related

How do I compile my C++ code with anaconda boost?

I have to use Anaconda provided compilers and their Boost package to compile my C++ code. I have a problem such that I do not know how to link properly during the compilation command.
To begin with: I create a dedicated anaconda env. with the following packages:
- boost-cpp=1.77.0
- compilers=1.3.0
These packages may be found here:
https://anaconda.org/conda-forge/compilers
https://anaconda.org/conda-forge/boost-cpp
Upon env. activation: double check which compiler I use:
$ which g++
/usr/share/miniconda3/envs/MYNAME/bin/g++
And then I would like to compile, but I don't know how to include boost libraries.
When I run:
$ g++ workflow/src/CODE.cpp -o workflow/bin/CODE -lm
Of course I get:
CODE.h:10:10: fatal error: boost/property_tree/info_parser.hpp: No such file or directory
10 | #include <boost/property_tree/info_parser.hpp>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Nevermind, I have worked it out.
Although it might be useful for others so let's keep the solution in here:
g++ workflow/src/CODE.cpp -o workflow/bin/CODE -I$HOME/miniconda3/envs/MYNAME/include -lm

How can I solve this error on macOS catalina?

I am trying to compile a Cpp program with g++ compiler, but I am getting this error:
Yuliam-MBP:Documents yuliamosh$ g++-9 -std=c++17 -Wall -Wextra -pedantic vector.cpp -o vector
In file included from /usr/local/Cellar/gcc/9.2.0_3/include/c++/9.2.0/bits/postypes.h:40,
from /usr/local/Cellar/gcc/9.2.0_3/include/c++/9.2.0/iosfwd:40,
from /usr/local/Cellar/gcc/9.2.0_3/include/c++/9.2.0/ios:38,
from /usr/local/Cellar/gcc/9.2.0_3/include/c++/9.2.0/ostream:3,
from /usr/local/Cellar/gcc/9.2.0_3/include/c++/9.2.0/iostream:39,
from vector.cpp:1:
/usr/local/Cellar/gcc/9.2.0_3/include/c++/9.2.0/cwchar:44:10: fatal error: wchar.h: No such file or directory
44 | #include <wchar.h>
| ^~~~~~~~~
compilation terminated.
It seems like "wchar.h" was not found.
I would suggest to follow the instructions from this thread.
INSTALL
xcode-select --install
THEN SWITCH TO NEWLY INSTALLED TOOLS
sudo xcode-select --switch /Library/Developer/CommandLineTools/
You might need to reset the default location of the compile tools:
xcode-select --reset
These are the usual fixes. SADLY, NONE OF THEM WORKED FOR ME!
THIS IS WHAT WORKED FOR ME:
Homebrew Solution

Coverity Self-Build can't build a C++17 application

I'm trying to use Coverity Scan with an embedded application written in C++17 (ARM GCC Embedded v7.2). The application itself builds well and error/warning-free; however, the Coverity Scan Self-Build tool (cov-analysis-linux64-2017.07, the latest) fails to compile certain C++ files with the following error (abridged):
[19888] EXECUTING: /home/pavel/opt/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/as -I . -I src -I src/os_config -I eigen -I senoval -I legilimens -I popcop/c++ -I build/current_build_info -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -meabi=5 -alms=build/lst/ch.lst -o build/obj/ch.o /tmp/ccK73Qaa.s
"/home/pavel/opt/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/include/c++/7.2.1/bits/c++17_warning.h", line 32:
error #35: #error directive: This file requires compiler and library
support for the ISO C++ 2017 standard. This support must be enabled
with the -std=c++17 or -std=gnu++17 compiler options.
#error This file requires compiler and library support \
^
As can be seen, the build tool did not pass the option -std=c++17 to the assembler. By the way, the application's own build system does not make direct calls to the assembler; the Self-Build tool does it on its own. This is how the Coverity Self-Build process is configured:
cov-configure --comptype gcc --compiler arm-none-eabi-gcc --template
make clean
cov-build --dir build/cov-int make -j8
cd build
tar czvf coverity.tgz cov-int
How do I configure the Self-Build tool to build C++17 code correctly?

LLVM header not found after apt-get install

I installed llvm and clang 3.9 along with all the other packages using the below command as given in LLVM Nightly packages link.
sudo apt-get install clang-3.9 clang-3.9-doc llvm-3.9 llvm-3.9-dev llvm-3.9-doc llvm-3.9-examples llvm-3.9-runtime clang-format-3.9 python-clang-3.9 libclang-common-3.9-dev libclang-3.9-dev libclang1-3.9 libclang1-3.9-dbg libllvm-3.9-ocaml-dev libllvm3.9 libllvm3.9-dbg lldb-3.9 lldb-3.9-dev liblldb-3.9-dbg
Then I tried to compile and run the sample lexer and parser for kaleidoscope language according to this tutorial.
However, I am not able to compile the given sample program, because I get the error:
clang++-3.9 -g -O3 toy.cpp
toy.cpp:1:10: fatal error: 'llvm/ADT/STLExtras.h' file not found
#include "llvm/ADT/STLExtras.h"
^
1 error generated.
I think this error is because LLVM was installed as llvm-3.9 and hence all the files were installed in directories ending with *-3.9. How can I fix this error without having to remove the installation and do a manual build install from the LLVM source?
That looks like a bug in the tutorial -- the code in toy.cpp used to be self-contained, but it now depends on an LLVM header (this is a recent change).
You can use the command provided in chapter 3 to build instead, i.e.:
clang++ -g -O3 toy.cpp `llvm-config --cxxflags --ldflags --system-libs --libs core` -o toy

How to install Boost with specified compiler (say GCC)

I would like to install boost with specified compilers, such as the gcc-4.9.1 that I have installed in <gcc_49_root>. The current OS is Mac OS X 10.9.4, but I would like this installation process to work on other OS. The documentation of boost is quite opaque about this scenario. What I have tried is as following:
$ ./bootstrap.sh
-n Building Boost.Build engine with toolset darwin...
tools/build/src/engine/bin.macosxx86_64/b2
-n Detecting Python version...
2.7
-n Detecting Python root...
/System/Library/Frameworks/Python.framework/Versions/2.7
-n Unicode/ICU support for Boost.Regex?...
not found.
Generating Boost.Build configuration in project-config.jam...
Insert using gcc : 4.9.1 : <gcc_49_root>/bin/g++-4.9 : ; into project-config.jam.
$ ./b2 --prefix=<...> toolset=gcc-4.9.1 install
But encountered the errors:
Jamfile</Users/dongli/Shares/works/packman/test/packages/Boost/boost_1_56_0/libs/context/build>.gas64 bin.v2/libs/context/build/gcc-4.9.1/release/address-model-64/architecture-x86/threading-multi/asm/make_x86_64_sysv_macho_gas.o
FATAL:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../libexec/as/x86_64/as: I don't understand '-' flag!
clang: error: no input files
cpp -x assembler-with-cpp "libs/context/src/asm/make_x86_64_sysv_macho_gas.S" | as --64 -o "bin.v2/libs/context/build/gcc-4.9.1/release/address-model-64/architecture-x86/threading-multi/asm/make_x86_64_sysv_macho_gas.o"
...failed Jamfile</Users/dongli/Shares/works/packman/test/packages/Boost/boost_1_56_0/libs/context/build>.gas64 bin.v2/libs/context/build/gcc-4.9.1/release/address-model-64/architecture-x86/threading-multi/asm/make_x86_64_sysv_macho_gas.o...
gcc.link.dll bin.v2/libs/atomic/build/gcc-4.9.1/release/threading-multi/libboost_atomic.dylib
ld: unknown option: -h
collect2: error: ld returned 1 exit status
"/usr/local/opt/gcc/bin/g++-4.9" -o "bin.v2/libs/atomic/build/gcc-4.9.1/release/threading-multi/libboost_atomic.dylib" -Wl,-h -Wl,libboost_atomic.dylib -shared -Wl,--start-group "bin.v2/libs/atomic/build/gcc-4.9.1/release/threading-multi/lockpool.o" -Wl,-Bstatic -Wl,-Bdynamic -Wl,--end-group
...failed gcc.link.dll bin.v2/libs/atomic/build/gcc-4.9.1/release/threading-multi/libboost_atomic.dylib...
What should I do with these errors? Thanks in advance!
Apple's linker ld(ld64) is different from other UNIX/GNU linkers and does not support some options, such as -h(soname), --start-group, --end-group, etc,. Those errors you got("unknown option") were the results of trying to pass non-supported flags to Apple's ld when you specify the gcc toolset.
The way I hacked mine was to first include "darwin" in the project config file:
using gcc : 4.9.1 : <gcc_49_root>/bin/g++-4.9 : <linker-type>darwin ;
Next removing the non-supported flags from {BOOST_DIR}/tools/build/src/tools/gcc.jam, from the long command in the "actions link.dll bind LIBRARIES" block:
remove/comment out this portion:
... $(HAVE_SONAME)-Wl,$(SONAME_OPTION)$(SPACE)-Wl,$(<[-1]:D=) ...
Afterwards the Boost libraries built without errors and worked fine in other gcc4.9 compiled codes.
$ ./bootstrap.sh --with-toolset=gcc
$ ./b2 --toolset=gcc-4.9.1
UPDATE (May 2015): I recently did a new built of gcc 5.1.0 and Boost 1.58.0 on Yosemite (10.10.1). Same fix worked for me.
I am using Mac Yosemite and this worked for me.
Open "tools/build/example/user-config.jam" and change
# Configure gcc (default version).
# using gcc ;
# Configure specific gcc version, giving alternative name to use.
using darwin : 5 : g++-5 ;
Then open "tools/build/src/tools/darwin.jam" then delete below line (this step may not be required. just try both way);
"$(CONFIG_COMMAND)" -dynamiclib -Wl,-single_module -install_name "$(<:B)$(<:S)" -L"$(LINKPATH)" -o "$(<)" "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-SA) -l$(FINDLIBS-ST) $(FRAMEWORK_PATH) -framework$(_)$(FRAMEWORK:D=:S=) $(OPTIONS) $(USER_OPTIONS)
As last step, compile and install
$ ./bootstrap.sh --with-libraries=all --with-toolset=darwin --prefix=/usr/local/boost_for_gcc
$ ./b2
$ ./b2 install
Now you can compile your code like below
$ g++ -o main main.cpp -L/usr/local/boost_for_gcc/lib -I/usr/local/boost_for_gcc/include -lboost_regex
Reference:
http://qiita.com/misho/items/0c0b3ca25bb8f62aa681