How to fix ./configure in MSYS2? - windows

I'm trying to build libxc-4.3.4 in an MSYS2 shell on Windows 10. I've installed the latest version of MSYS2 (msys2-x86_64-20220319.exe) and followed the installation instructions. I've installed build tools using
pacman -S --needed base-devel mingw-w64-x86_64-toolchain autoconf
I've installed libxc dozens of time on Linux machines. The first step is
./configure --prefix /somewhere
But in MSYS2 I get
$ ./configure --prefix $PWD/../libxc
bash: ./configure: No such file or directory
How can I make this work?

MSYS2 prerequisites
First of all make sure MSYS2 has all programs that are needed.
In the MSYS2 shell first update the package manager information:
pacman -Syu --noconfirm
Then install the packages you need. I would recommend at least these:
pacman -S --noconfirm autoconf autoconf-archive automake make libtool pkg-config
Project sources
Next you should make sure the folder you are in actually has a configure script:
ls -l configure
A lot of projects these days are switching to more efficient build systems like CMake or Meson.
I usually use the following command in the projects source folder to check for several build systems:
ls -ld configure* m4 CMakeLists.txt cmake Makefile GNUmakefile setup.py scons SConscript SConstruct meson.build meson_options.txt *.pro *.proj *.sln BUILD.gn .gn 2> /dev/null
building libxc
For the libxc project I see there is a CMakeLists.txt file and also a configure.ac file.
So either you should look into using CMake or generate the configure file with:
touch README ChangeLog
autoreconf -f -i -I m4
I have just tried to build libxc in MSYS2 with CMake and Ninja and this worked:
# set the line below to the desired install location
INSTALLPREFIX=D:\Prog\changeme
# build static library
cmake -Wno-dev -GNinja -DCMAKE_INSTALL_PREFIX:PATH=$INSTALLPREFIX -DCMAKE_BUILD_TYPE:STRING=Release -DBUILD_SHARED_LIBS:BOOL=OFF -DENABLE_PYTHON:BOOL=OFF -DBUILD_TESTING:BOOL=OFF -S. -Bbuild_static &&
ninja -Cbuild_static install/strip &&
echo SUCCESS
# build shared library
cmake -Wno-dev -GNinja -DCMAKE_INSTALL_PREFIX:PATH=$INSTALLPREFIX -DCMAKE_BUILD_TYPE:STRING=Release -DBUILD_SHARED_LIBS:BOOL=ON -DENABLE_PYTHON:BOOL=OFF -DBUILD_TESTING:BOOL=OFF -S. -Bbuild_shared &&
ninja -Cbuild_shared install/strip &&
echo SUCCESS

Related

arm-none-eabi toolchain compile from source

For my current project we are having an issue which we can solve if we are able to recompile the arm toolchain (gcc, c++stdlib, nanolibc, etc) from source.
From the arm website I can download a snapshot of the source. I found a blog but it's outdated. The pdf he refers to no longer exists in this snapshot anyway.
Browsing through the extracted archive I can't seem to find any instructions how to compile.
Where can I find documentation how to compile arm-none-eabi from source?
The release notes available at the download site include build-from-source instructions.
I've made a quick transcription here, but future readers should be warned it may have become out-of-date.
How to build the toolchain from sources
You can build Arm GNU Toolchain from sources using Linaro ABE (Advanced Build Environment) and provided ABE manifest files.
Below example shows how to build gcc-arm-aarch64-none-elf toolchain from sources using Linaro ABE build system.
Instructions
ABE has a dependency on git-new-workdir and needs this tool to be installed in /usr/local/bin directory:
$ wget https://raw.githubusercontent.com/git/git/master/contrib/workdir/git-new-workdir
$ sudo mv git-new-workdir /usr/local/bin
$ sudo chmod +x /usr/local/bin/git-new-workdir
Clone ABE from the URL below and checkout the stablebranch (see Getting ABE):
$ git clone https://git.linaro.org/toolchain/abe.git
Create the build directory and change to it. Any name for the directory will work:
$ mkdir build && cd build
Configure ABE (from the build directory):
$ ../abe/configure
Download the toolchain manifest file, from https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/downloads, into the build folder, for the required toolchain, for example, gcc-arm-aarch64-none-elf-abe-manifest.txt:
$ wget https://developer.arm.com/-/media/Files/downloads/gnu/11.2-2022.02/manifest/gcc-arm-aarch64-none-elf-abe-manifest.txt
Build toolchain (from the build directory):
$ ../abe/abe.sh --manifest gcc-arm-aarch64-none-elf-abe-manifest.txt --build all
The built toolchain will be installed and available for use in the builds/destdir/x86_64-unknown-linux-gnu/bin/ directory.
# Usage
# sudo ./build_arm
# Setup vars
export TARGET=arm-none-eabi
export PREFIX=/opt/gnuarm
export PATH=$PATH:$PREFIX/bin
export JN='-j 8'
export GCCVER=11.2.0
export BINUVER=2.37
rm -rf build-*
rm -rf gcc-*
rm -rf binutils-*
# Get archives
wget https://ftp.gnu.org/gnu/binutils/binutils-$BINUVER.tar.gz
wget https://ftp.gnu.org/gnu/gcc/gcc-$GCCVER/gcc-$GCCVER.tar.gz
# Extract archives
tar xf binutils-$BINUVER.tar.gz
tar xf gcc-$GCCVER.tar.gz
# Build binutils
mkdir build-binutils
cd build-binutils
../binutils-$BINUVER/configure --target=$TARGET --prefix=$PREFIX
echo "MAKEINFO = :" >> Makefile
make $JN all
sudo make install
# Build GCC
mkdir ../build-gcc
cd ../build-gcc
../gcc-$GCCVER/configure --target=$TARGET --prefix=$PREFIX --without-headers --with-newlib --with-gnu-as --with-gnu-ld --enable-languages='c' --enable-frame-pointer=no
make $JN all-gcc
sudo make install-gcc
# Build libgcc.a
make $JN all-target-libgcc CFLAGS_FOR_TARGET="-g -O2"
sudo make install-target-libgcc

cmake command issue while compile project of tbb

I tried using a demo to compile tbb in my project.
Link of the demo https://www.selectiveintellect.net/blog/2016/7/29/using-cmake-to-add-third-party-libraries-to-your-project-1
IDE for me is VS2013 and get an error about command 'make'
Performing build step for 'tbb44'
2> CMake Error at F:/CPPs/FAsT-Match-master/build/tbb44/src/tbb44-stamp/tbb44-build-Debug.cmake:49 (message):
2> Command failed: 2
2>
2> 'make' 'tbb_build_prefix=tbb44'
The original command is generated via tbb.cmake, for which it looks like
ExternalProject_Add(${TBB_PREFIX}
PREFIX ${TBB_PREFIX}
URL ${TBB_URL}
URL_MD5 ${TBB_URL_MD5}
CONFIGURE_COMMAND ""
# BUILD_COMMAND ${TBB_MAKE} -j${NCPU} tbb_build_prefix=${TBB_PREFIX}
BUILD_COMMAND ${TBB_MAKE} tbb_build_prefix=${TBB_PREFIX}
The one commented is the original and the one behind is modified.
Is this the problem of MSVC?
That blog post is just completely wrong. TBB comes with its own CMake build now, so there's absolutely no reason to go through ExternalProject like this.
Here's how I built it from source, using Visual Studio 2019 (the instructions should be pretty much the same). From a developer command prompt, using CMake 3.20:
D:\>git clone https://github.com/oneapi-src/oneTBB
D:\>cmake -S oneTBB -B oneTBB-build -DTBB_TEST=OFF
D:\>cmake --build oneTBB-build --config Release
D:\>cmake --build oneTBB-build --config Debug
D:\>cmake --install oneTBB-build --prefix oneTBB-install --config Release
D:\>cmake --install oneTBB-build --prefix oneTBB-install --config Debug
Setting TBB_TEST to OFF saves a lot of time waiting on TBB's tests to build. These commands install the Debug and Release binaries to D:\oneTBB-install. Of course, you can place this folder anywhere you like.
Once this is done, you may use your new TBB build from your project like so:
cmake_minimum_required(VERSION 3.20)
project(TBB-test)
find_package(TBB REQUIRED)
add_executable(main main.cpp)
target_link_libraries(main PRIVATE TBB::tbb)
The TBB package also includes libraries TBB::tbbmalloc and TBB::tbbmalloc_proxy.
When you build your project, you may point find_package to your TBB installation by setting the CMake variable TBB_ROOT to D:/oneTBB-install at the command line via:
D:\>cmake -S myProject -B myProject-build -DTBB_ROOT=D:/oneTBB-install

Compile boost-python 1.73.0 for Windows with MinGW64 on Fedora

I need to compile boost-python 1.73.0 with MinGW64 on Fedora's rawhide, so that I can build Python bindings for Windows 10 64bit (no, I can't use Visual Studio unfortunately). And unfortunately the only library missing from Fedora's mingw64-boost package is boost-python, argggh!
Actually all dependencies are packaged on Fedora for MinGW64, which is quite nice. So I'm trying to build myself with:
wget https://dl.bintray.com/boostorg/release/1.73.0/source/boost_1_73_0.tar.bz2
tar -xjf boost_1_73_0.tar.bz2 && cd boost_1_73_0
./bootstrap.sh
# in a docker container, so /root
./b2 --with-python address-model=64 target-os=windows toolset=gcc-mingw64 \
variant=release link=shared --user-config=/root/user-config.jam
And a ~/user-config.jam:
using gcc : mingw64 : x86_64-w64-mingw32-g++ ;
using python
: 3.9
: /usr/x86_64-w64-mingw32/sys-root/mingw/bin/python3.9.exe
: /usr/x86_64-w64-mingw32/sys-root/mingw/include/python3.9
: /usr/x86_64-w64-mingw32/sys-root/mingw/lib/python3.9 ;
It runs for a while successfully, but then errors out on
/usr/lib/gcc/x86_64-w64-mingw32/10.2.1/../../../../x86_64-w64-mingw32/bin/ld: cannot find -lutil
collect2: error: ld returned 1 exit status
So libutil is missing somehow. What a super specific name! I tried (re-)installing all glibc packages (where libutil.so apparently usually is in), to no avail. Also found a /usr/x86_64-w64-mingw32/sys-root/mingw/lib/libutildll.a, tried including it via ./b2 library=..., again no luck.
What's going on here? BTW, this gist has the full command which is failing.
So, this needed a patch to the boost sources to get rid of the libutil linking. To compile fully, a batch of other patch files had to be applied. Here's my full command chain in fedora:rawhide:
Get the sources
wget https://dl.bintray.com/boostorg/release/1.73.0/source/boost_1_73_0.tar.bz2
tar -xjf boost_1_73_0.tar.bz2
cd boost_1_73_0
Setup ~/user-config.jam
cat >> ~/user-config.jam <<EOL
using gcc : mingw64 : x86_64-w64-mingw32-g++ ;
using python
: 3.9
: /usr/x86_64-w64-mingw32/sys-root/mingw/bin/python3.9
: /usr/x86_64-w64-mingw32/sys-root/mingw/include/python3.9
: /usr/x86_64-w64-mingw32/sys-root/mingw/lib/python3.9/config-3.9 ;
EOL
Bootstrap boost
./bootstrap.sh --with-icu=/usr/x86_64-w64-mingw32/sys-root/mingw/ --with-toolset=gcc
Patch all files in ./boost_1_73_0_patches from
the single patch in this repo (git clone for source): https://aur.archlinux.org/packages/mingw-w64-boost-python/
all patch files from this repo: https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-boost
Mostly apply like this:
patch -p1 -i patches/boost-1.63.0-python-test-PyImport_AppendInittab.patch
Build boost-python
./b2 address-model=64 link=shared runtime-link=shared threading=multi threadapi=win32 toolset=gcc variant=release python=3.9 --with-python

opencv library installation on windows

I found this project on github that requires the opencv library. The author has given the following instruction for linux and osx but none for windows:
I tried using the linux commands on windows but it gave me an error at cmake, saying
cmake command not found. So i downloaded cmake and tried running it again it still continues to give the same error.
Can someone advise on how to get this working? Or point me to some other way to install the library?
OSX
cd ~
git clone git://code.opencv.org/opencv.git
cd opencv
git checkout 2.4.5
mkdir build
cd build
cmake -G "Unix Makefiles" -D CMAKE_OSX_ARCHITECTURES=x86_64 ..
make -j8
sudo make install
Linux (Tested on Ubuntu 12.04)
cd ~
git clone git://code.opencv.org/opencv.git
cd opencv
git checkout 2.4.5
mkdir build
cd build
cmake -G "Unix Makefiles" ..
make -j8
sudo make install
Compiling PuzzleSolver
Once the opencv library has been installed, you can try to open the xcodeproject, or on linux or mac run this from the PuzzleSolver directory (with the source files):
g++ -O3 `pkg-config --cflags opencv` -o PuzzleSolver *.cpp `pkg-config --libs opencv`
This will result in an executable called PuzzleSolver.
just get the binary pack [~400mb]

Installing gcc 4.1.0 on ubuntu

I have latest version of ubuntu, but the version of gcc is higher than what I want. How do I build gcc 4.1.0 or install gcc 4.1.0 on this.
I did not find steps to build gcc 4.1.0
Here are the steps to building gcc:
http://gcc.gnu.org/install/
Note that, while "It refers to the current development sources, instructions for specific released versions are included with the sources."
It is a typical* configure, make, make install process. The most important configure flag is probably --enable-languages. and --prefix of course. Also --program-suffix=-4.1 will cause the generated executable to be called gcc-4.1 instead of gcc. The prerequisites list may look scary but most of it is optional, especially if only building for C/C++.
[*] ok, not so typical: another caveat pointed out by JonathanWakely in the comments below is that you shouldn't build gcc in the source dir since that is not supported, so :
(after getting all the prerequisites)
[gcc-src-dir] $ cd ../my-build-dir
[my-build-dir] $ ../gcc-src-dir/configure $CONFIG_FLAGS
[my-build-dir] $ make
[my-build-dir] $ make install
And he pointed to a wiki page he wrote which will walk you through the whole process.
I had a few issues installing gcc 4.1.2 on ubuntu (12.04 in my case). This script sorted it for me:
#!/bin/tcsh
if ($#argv != 1) then
echo "Synopsis: $argv[0] <install_dir>"
exit(-1)
endif
setenv GCCINSTALL $argv[1]
setenv LIBRARY_PATH /usr/lib/x86_64-linux-gnu
setenv SRC ~/gccSrc
mkdir -p $SRC
cd $SRC
wget http://gcc.cybermirror.org/releases/gcc-4.1.2/gcc-4.1.2.tar.gz
tar xvf gcc-4.1.2.tar.gz
cd gcc-4.1.2
mkdir build
cd build
../configure --prefix=${GCCINSTALL} --disable-multilib
grep 4.1.2/missing Makefile
sed -i "s#${SRC}/gcc-4.1.2/missing##" Makefile
grep 4.1.2/missing Makefile
make bootstrap
make install

Resources