I am working with autotools to install several doc directories, however, it is adding an unneeded prefix to the directories in question:
I run
autoreconf -f;automake; ./configure; make; sudo make install
Error:
test -z "/usr/local/share/opendiameter/docs" || /bin/mkdir -p "/usr/local/share/opendiameter/docs"
/usr/bin/install -c -m 644 docs/msvc-solution-usage.txt docs/development_policy.txt docs/coding_style.txt docs/bugtracking-diagram.pdf ./docs/framework/ ./docs/libdiameter ./docs/libdiametereap ./docs/libdiameternasreq ./docs/libdiametermip4 ./docs/libeap ./docs/libpana ./docs/nasreq opendiameter.kdevelop tools/getopt.patch tools/getopt1.patch autogen.sh RELEASE README '/usr/local/share/opendiameter/docs'
/usr/bin/install: omitting directory `./docs/framework/'
/usr/bin/install: omitting directory `./docs/libdiameter'
/usr/bin/install: omitting directory `./docs/libdiametereap'
/usr/bin/install: omitting directory `./docs/libdiameternasreq'
/usr/bin/install: omitting directory `./docs/libdiametermip4'
/usr/bin/install: omitting directory `./docs/libeap'
/usr/bin/install: omitting directory `./docs/libpana'
/usr/bin/install: omitting directory `./docs/nasreq'
</code>
And here is the Makefile.am - NOTE that I have tried $(top_srcdir) as a prefix to the docs/
docdir = $(prefix)/share/opendiameter/docs
doc_DATA = docs/msvc-solution-usage.txt \
docs/development_policy.txt \
docs/coding_style.txt \
docs/bugtracking-diagram.pdf \
docs/framework/ \
docs/libdiameter \
docs/libdiametereap \
docs/libdiameternasreq \
docs/libdiametermip4 \
docs/libeap \
docs/libpana \
docs/nasreq \
opendiameter.kdevelop \
tools/getopt.patch \
tools/getopt1.patch \
autogen.sh \
RELEASE \
README
SUBDIRS_LIBS = libodutl \
libdiamparser \
libdiameter \
libdiametermip4 \
libeap \
libpana \
libdiametereap \
libdiameternasreq
SUBDIRS_APPS = applications
SUBDIRS_DOCS = docs
SUBDIRS = $(SUBDIRS_LIBS) $(SUBDIRS_APPS)
DIST_SUBDIRS = $(SUBDIRS_LIBS) $(SUBDIRS_APPS) $(SUBDIRS_DOCS)
includedir = $(prefix)/include/opendiameter
include_HEADERS = $(top_srcdir)/include/framework.h \
$(top_srcdir)/include/aaa_parser_api.h \
$(top_srcdir)/include/aaa_global_config.h \
$(top_srcdir)/include/aaa_dictionary_api.h \
$(top_srcdir)/include/aaa_parser_defs.h \
$(top_srcdir)/include/resultcodes.h
dist-hook:
rm -rf `find $(distdir) -name CVS`
You are assuming that _DATA knows how to deal with directories. It does not. It deals with files.
I'm assuming that you want the directory structure kept in the install.
In order to layout a directory structure you'll need to do something like this for each directory:
docdir = $(datadir)/opendiameter/docs
docframeworkdir = $(docdir)/framework
dist_doc_DATA = docs/msvc-solution-usage.txt \
...
dist_docframework_DATA = \
docs/framework/foo \
docs/framework/bar
Basically, you need to create a destination installation directory (like docframeworkdir)
and list out the files in it (like dist_docframework_DATA). If the toplevel (e.g. docs/framework) directories also contain directories (e.g. docs/framework/nest), you'll need to create destinations for those also if the have files you want to install.
If this is too tedious, you can write an install data hook to copy directories, which might be easier.
If you don't want the directory structure, you can add the list of files in docs to dist_doc_DATA. You can also write an install data hook for this as well.
Related
I am trying to link with static C API version of the TensorFlow library.
I built the static library using the following commands:
// get the sources
git clone https://github.com/tensorflow/tensorflow.git tensorflow_src
// create a build directory
mkdir builddir
cd builddir
// build the lib using CMake
cmake -S ../tensorflow_src/tensorflow/lite/c -DTFLITE_C_BUILD_SHARED_LIBS:BOOL=OFF
cmake --build . -j
This builds the libtensorflow-lite.a. However, the libtensorflow-lite.a is not self-contained and has its own set of 10 dependencies, stated here in the CMake file:
# TensorFlow Lite dependencies.
find_package(absl REQUIRED)
find_package(eigen REQUIRED)
find_package(farmhash REQUIRED)
find_package(fft2d REQUIRED)
find_package(flatbuffers REQUIRED)
find_package(gemmlowp REQUIRED)
find_package(neon2sse REQUIRED)
find_package(clog REQUIRED)
find_package(cpuinfo REQUIRED) #CPUINFO is used by XNNPACK and RUY library
find_package(ruy REQUIRED)
The question is, how do I find out the .a names of the required sub-libraries?
I used find ./builddir -type f -name "*.a" to list the libraries built by CMake, and expected roughly 10 libs, but the actual list is too long:
./_deps/xnnpack-build/libXNNPACK.a
./_deps/ruy-build/ruy/libruy_pack_avx2_fma.a
./_deps/ruy-build/ruy/libruy_have_built_path_for_avx2_fma.a
./_deps/ruy-build/ruy/libruy_block_map.a
./_deps/ruy-build/ruy/libruy_system_aligned_alloc.a
./_deps/ruy-build/ruy/libruy_have_built_path_for_avx512.a
./_deps/ruy-build/ruy/profiler/libruy_profiler_instrumentation.a
./_deps/ruy-build/ruy/libruy_trmul.a
./_deps/ruy-build/ruy/libruy_cpuinfo.a
./_deps/ruy-build/ruy/libruy_blocking_counter.a
./_deps/ruy-build/ruy/libruy_pack_arm.a
./_deps/ruy-build/ruy/libruy_apply_multiplier.a
./_deps/ruy-build/ruy/libruy_kernel_avx2_fma.a
./_deps/ruy-build/ruy/libruy_prepacked_cache.a
./_deps/ruy-build/ruy/libruy_tune.a
./_deps/ruy-build/ruy/libruy_context_get_ctx.a
./_deps/ruy-build/ruy/libruy_have_built_path_for_avx.a
./_deps/ruy-build/ruy/libruy_ctx.a
./_deps/ruy-build/ruy/libruy_wait.a
./_deps/ruy-build/ruy/libruy_allocator.a
./_deps/ruy-build/ruy/libruy_context.a
./_deps/ruy-build/ruy/libruy_kernel_avx.a
./_deps/ruy-build/ruy/libruy_prepare_packed_matrices.a
./_deps/ruy-build/ruy/libruy_pack_avx512.a
./_deps/ruy-build/ruy/libruy_kernel_arm.a
./_deps/ruy-build/ruy/libruy_denormal.a
./_deps/ruy-build/ruy/libruy_kernel_avx512.a
./_deps/ruy-build/ruy/libruy_frontend.a
./_deps/ruy-build/ruy/libruy_pack_avx.a
./_deps/ruy-build/ruy/libruy_thread_pool.a
./_deps/flatbuffers-build/libflatbuffers.a
./_deps/fft2d-build/libfft2d_fftsg2d.a
./_deps/fft2d-build/libfft2d_fftsg.a
./_deps/farmhash-build/libfarmhash.a
./_deps/clog-build/libclog.a
./_deps/abseil-cpp-build/absl/synchronization/libabsl_graphcycles_internal.a
./_deps/abseil-cpp-build/absl/synchronization/libabsl_synchronization.a
./_deps/abseil-cpp-build/absl/strings/libabsl_strings.a
./_deps/abseil-cpp-build/absl/strings/libabsl_str_format_internal.a
./_deps/abseil-cpp-build/absl/strings/libabsl_cord.a
./_deps/abseil-cpp-build/absl/strings/libabsl_strings_internal.a
./_deps/abseil-cpp-build/absl/status/libabsl_status.a
./_deps/abseil-cpp-build/absl/hash/libabsl_city.a
./_deps/abseil-cpp-build/absl/hash/libabsl_wyhash.a
./_deps/abseil-cpp-build/absl/hash/libabsl_hash.a
./_deps/abseil-cpp-build/absl/flags/libabsl_flags_reflection.a
./_deps/abseil-cpp-build/absl/flags/libabsl_flags_program_name.a
./_deps/abseil-cpp-build/absl/flags/libabsl_flags_internal.a
./_deps/abseil-cpp-build/absl/flags/libabsl_flags_private_handle_accessor.a
./_deps/abseil-cpp-build/absl/flags/libabsl_flags_marshalling.a
./_deps/abseil-cpp-build/absl/flags/libabsl_flags_commandlineflag_internal.a
./_deps/abseil-cpp-build/absl/flags/libabsl_flags_commandlineflag.a
./_deps/abseil-cpp-build/absl/flags/libabsl_flags_config.a
./_deps/abseil-cpp-build/absl/flags/libabsl_flags.a
./_deps/abseil-cpp-build/absl/numeric/libabsl_int128.a
./_deps/abseil-cpp-build/absl/debugging/libabsl_symbolize.a
./_deps/abseil-cpp-build/absl/debugging/libabsl_debugging_internal.a
./_deps/abseil-cpp-build/absl/debugging/libabsl_demangle_internal.a
./_deps/abseil-cpp-build/absl/debugging/libabsl_stacktrace.a
./_deps/abseil-cpp-build/absl/base/libabsl_spinlock_wait.a
./_deps/abseil-cpp-build/absl/base/libabsl_raw_logging_internal.a
./_deps/abseil-cpp-build/absl/base/libabsl_malloc_internal.a
./_deps/abseil-cpp-build/absl/base/libabsl_throw_delegate.a
./_deps/abseil-cpp-build/absl/base/libabsl_exponential_biased.a
./_deps/abseil-cpp-build/absl/base/libabsl_base.a
./_deps/abseil-cpp-build/absl/base/libabsl_log_severity.a
./_deps/abseil-cpp-build/absl/time/libabsl_time_zone.a
./_deps/abseil-cpp-build/absl/time/libabsl_civil_time.a
./_deps/abseil-cpp-build/absl/time/libabsl_time.a
./_deps/abseil-cpp-build/absl/container/libabsl_hashtablez_sampler.a
./_deps/abseil-cpp-build/absl/container/libabsl_raw_hash_set.a
./_deps/abseil-cpp-build/absl/types/libabsl_bad_variant_access.a
./_deps/abseil-cpp-build/absl/types/libabsl_bad_optional_access.a
./_deps/cpuinfo-build/libcpuinfo.a
The state of the libs seems to be the following:
absl: 30 libraries found
eigen: OK, template library defined in the headers
farmhash: OK, 1 library found
fft2d: OK, 2 libraries found
flatbuffers: OK, 1 library found
gemmlowp: OK, headers only
neon2sse: OK, headers only
clog: OK, 1 library found
cpuinfo: OK, 1 library found
ruy: 30 libraries found
All in all, most libs are OK, either there is 1 lib to link with, or the libs are header-only. What remains to be the problem are:
absl
ruy
because they contain about 30 .a libs.
Not sure if I have to link with all of those? It would be very cumbersome, as my build system is Meson and I am using custom_target() to link with TensorFlow.
A year later, but I just went through this myself, so here goes my answer.
Based on my experience (using a makefile and without your -DTFLITE_C_BUILD_SHARED_LIBS:BOOL=OFF) a program that performs inference does not need to link to Abseil.
You need to link to all other libs you mentioned, except ruy_kernel_arm and ruy_pack_arm, assuming you're running your program on the x64 platform. (Annoyingly -DTFLITE_ENABLE_RUY=OFF is not respected when building TfLite, so you're stuck with Ruy)
Detailed steps:
Build TfLite:
mkdir ~/my_tflite_project
cd ~/my_tflite_project/
git clone https://github.com/tensorflow/tensorflow.git tensorflow_src
mkdir tflite_build_x64
cd tflite_build_x64/
cmake ../tensorflow_src/tensorflow/lite/
/* You may encounter two CMake messages:
-- The Fortran compiler identification is unknown
I believe a Fortran compiler is only necessary to build Fortran bindings for TfLite.
-- Could NOT find CLANG_FORMAT: Found unsuitable version "0.0", but required is exact version "9" (found CLANG_FORMAT_EXECUTABLE-NOTFOUND)
sudo apt install clang-format-9
Annoyingly you need clang-format-9, plain clang-format (version 13, the newest) won't do. */
cmake --build . -j 4
Relevant libs:
$ cd ~/my_tflite_project/tflite_build_x64
$ ls *.a
libtensorflow-lite.a
$ ls pthreadpool/*.a
pthreadpool/libpthreadpool.a
$ ls _deps/*/*.a
_deps/clog-build/libclog.a _deps/farmhash-build/libfarmhash.a _deps/fft2d-build/libfft2d_fftsg2d.a _deps/xnnpack-build/libXNNPACK.a
_deps/cpuinfo-build/libcpuinfo.a _deps/fft2d-build/libfft2d_fftsg.a _deps/flatbuffers-build/libflatbuffers.a
$ ls _deps/ruy-build/ruy/*.a
_deps/ruy-build/ruy/libruy_allocator.a _deps/ruy-build/ruy/libruy_ctx.a _deps/ruy-build/ruy/libruy_kernel_avx.a _deps/ruy-build/ruy/libruy_prepacked_cache.a
_deps/ruy-build/ruy/libruy_apply_multiplier.a _deps/ruy-build/ruy/libruy_denormal.a _deps/ruy-build/ruy/libruy_kernel_avx2_fma.a _deps/ruy-build/ruy/libruy_prepare_packed_matrices.a
_deps/ruy-build/ruy/libruy_block_map.a _deps/ruy-build/ruy/libruy_frontend.a _deps/ruy-build/ruy/libruy_kernel_avx512.a _deps/ruy-build/ruy/libruy_system_aligned_alloc.a
_deps/ruy-build/ruy/libruy_blocking_counter.a _deps/ruy-build/ruy/libruy_have_built_path_for_avx.a _deps/ruy-build/ruy/libruy_pack_arm.a _deps/ruy-build/ruy/libruy_thread_pool.a
_deps/ruy-build/ruy/libruy_context.a _deps/ruy-build/ruy/libruy_have_built_path_for_avx2_fma.a _deps/ruy-build/ruy/libruy_pack_avx.a _deps/ruy-build/ruy/libruy_trmul.a
_deps/ruy-build/ruy/libruy_context_get_ctx.a _deps/ruy-build/ruy/libruy_have_built_path_for_avx512.a _deps/ruy-build/ruy/libruy_pack_avx2_fma.a _deps/ruy-build/ruy/libruy_tune.a
_deps/ruy-build/ruy/libruy_cpuinfo.a _deps/ruy-build/ruy/libruy_kernel_arm.a _deps/ruy-build/ruy/libruy_pack_avx512.a _deps/ruy-build/ruy/libruy_wait.a
Construct MWE using TfLite:
$ cd ~/my_tflite_project
$ mkdir my_dev_x64
$ cd my_dev_x64/
/* Construct minimal.cpp and makefile below */
$ cat minimal.cpp
#include "tensorflow/lite/model.h"
#include "tensorflow/lite/interpreter.h"
#include "tensorflow/lite/kernels/register.h"
#include <iostream>
int main() {
std::unique_ptr<tflite::FlatBufferModel> model = tflite::FlatBufferModel::BuildFromFile("your_network_here.tflite");
tflite::ops::builtin::BuiltinOpResolver resolver;
std::cout "Done\n";
return EXIT_SUCCESS;
}
$ cat makefile
COMPILER := g++
LINKER := g++
CXX_FILES := minimal.cpp
OBJ_FILES := $(CXX_FILES:.cpp=.o)
EXE_FILE := app
INCLUDE_DIRS := -I../tensorflow_src -I../tflite_build_x64/flatbuffers/include
LIB_DIRS := \
-L../tflite_build_x64 \
-L../tflite_build_x64/_deps/fft2d-build \
-L../tflite_build_x64/_deps/flatbuffers-build \
-L../tflite_build_x64/_deps/ruy-build/ruy \
-L../tflite_build_x64/_deps/farmhash-build \
-L../tflite_build_x64/_deps/xnnpack-build \
-L../tflite_build_x64/_deps/cpuinfo-build \
-L../tflite_build_x64/_deps/clog-build \
-L../tflite_build_x64/pthreadpool
LIBS := \
-ltensorflow-lite \
-lfft2d_fftsg \
-lfft2d_fftsg2d \
-lflatbuffers \
-lruy_ctx \
-lruy_allocator \
-lruy_frontend \
-lruy_context_get_ctx \
-lruy_context \
-lruy_apply_multiplier \
-lruy_prepacked_cache \
-lruy_tune \
-lruy_cpuinfo \
-lruy_system_aligned_alloc \
-lruy_prepare_packed_matrices \
-lruy_trmul \
-lruy_block_map \
-lruy_denormal \
-lruy_thread_pool \
-lruy_blocking_counter \
-lruy_wait \
-lruy_kernel_avx \
-lruy_kernel_avx2_fma \
-lruy_kernel_avx512 \
-lruy_pack_avx \
-lruy_pack_avx2_fma \
-lruy_pack_avx512 \
-lruy_have_built_path_for_avx \
-lruy_have_built_path_for_avx2_fma \
-lruy_have_built_path_for_avx512 \
-lfarmhash \
-lXNNPACK \
-lpthreadpool \
-lcpuinfo \
-lclog
CXX_FLAGS := -Wall #-pedantic
LINK_FLAGS :=
#Do not print the output of the commands
.SILENT:
#Phony targets do not represent actual files, so files with the following names are ignored
.PHONY: clean depend
#Link object files to form an executable file
$(EXE_FILE): $(OBJ_FILES)
$(LINKER) $(LINK_FLAGS) $(OBJ_FILES) -o $(EXE_FILE) $(LIB_DIRS) $(LIBS)
#Compile cpp files to object files
%.o: %.cpp
$(COMPILER) $(CXX_FLAGS) $(INCLUDE_DIRS) -c $<
#Remove object files, executable, and possible linkinfo files
clean:
-rm -f $(OBJ_FILES) $(EXE_FILE)
#Generate dependency file
depend:
$(COMPILER) $(CXX_FLAGS) $(INCLUDE_DIRS) -MM $(CXX_FILES) > make.dep
#Include dependency file
-include make.dep
Build and run MWE:
$ cd ~/my_tflite_project/my_dev_x64
$ make
$ ./app
Done
Hopefully that helps you or some other poor fellow to get TfLite C++ working.
When trying to compile my code, I get a linker error:
undefined reference to ‘xdg_popup_interface’
It seems to occur when trying to build wlr-layer-shell-v1-client-protocol.o, I think, or something like that, I’ll have to look at the output tomorrow.
AFAIK xdg_popup should be defined by wayland-protocols? My configure.ac.in has this line:
PKG_CHECK_MODULES(WAYLAND_PROTOCOLS, [wayland-protocols >= 1.13], [ac_wayland_protocols_pkgdatadir=`$PKG_CONFIG --variable=pkgdatadir wayland-protocols`])
and my src/Makefile.am has this:
xfway_CFLAGS = \
$(WAYLAND_SERVER_CFLAGS) \
$(WAYLAND_PROTOCOLS_CFLAGS) \
$(LIBWESTON_CFLAGS) \
$(LIBWESTON_DESKTOP_CFLAGS) \
$(LIBINPUT_CFLAGS) \
$(XKBCOMMON_CFLAGS) \
$(EGL_CFLAGS) \
$(EVDEV_CFLAGS) \
$(GTK_CFLAGS) \
$(LIBXFCONF_CFLAGS)
xfway_LDADD = \
$(WAYLAND_SERVER_LIBS) \
$(WAYLAND_PROTOCOLS_LIBS) \
$(LIBWESTON_LIBS) \
$(LIBWESTON_DESKTOP_LIBS) \
$(LIBINPUT_LIBS) \
$(XKBCOMMON_LIBS) \
$(EGL_LIBS) \
$(EVDEV_LIBS) \
$(PIXMAN_LIBS) \
$(GTK_LIBS) \
$(LIBXFCONF_LIBS)
The autotools output listed no cflags or libs for wayland-protocols, is this normal? Though autotools detected an installed version, so it’s definitely installed.
Here is the rest of my code:
https://github.com/adlocode/xfway
This seems to be a part that mentions xdg-popup:
https://github.com/adlocode/xfway/blob/master/protocol/wlr-layer-shell-unstable-v1.xml#L194
As far as I can see everything that is needed is there, what am I missing?
Update:
Is it that I have to generate xdg-shell header files myself using wayland-scanner?
I solved this by generating header files from the xdg-shell XML file using wayland-scanner, and compiling them into my project.
I'm writting a dockerfile to install the C version of opencv.
I have found a working solution for the python version, which looks like this.
FROM python:2.7
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# Various Python and C/build deps
RUN apt-get update && apt-get install -y \
wget \
build-essential \
cmake \
git \
unzip \
pkg-config \
python-dev \
python-opencv \
libopencv-dev \
libav-tools \
libjpeg-dev \
libpng-dev \
libtiff-dev \
libjasper-dev \
libgtk2.0-dev \
python-numpy \
python-pycurl \
libatlas-base-dev \
gfortran \
webp \
python-opencv \
qt5-default \
libvtk6-dev \
zlib1g-dev
# Install Open CV - Warning, this takes absolutely forever
RUN mkdir -p ~/opencv cd ~/opencv && \
wget https://github.com/opencv/opencv/archive/3.0.0.zip && \
unzip 3.0.0.zip && \
rm 3.0.0.zip && \
mv opencv-3.0.0 OpenCV && \
cd OpenCV && \
mkdir build && \
cd build && \
cmake \
-DWITH_QT=ON \
-DWITH_OPENGL=ON \
-DFORCE_VTK=ON \
-DWITH_TBB=ON \
-DWITH_GDAL=ON \
-DWITH_XINE=ON \
-DBUILD_EXAMPLES=ON .. && \
make -j4 && \
make install && \
ldconfig
COPY requirements.txt /usr/src/app/
RUN pip install --no-cache-dir -r requirements.txt
COPY . /usr/src/app
My problem is that I don't know to change it to install the C version. Do I really need to put the whole installation procedure as written here? I don't need the newest version. 3.x would be awesome.
Any ideas are welcome!
The project is about a root directory that contains a src directory. I created two makefiles, one at the top directory and the other at the src directory. Here is the makefile of the src directory:
## Process this file with automake to produce Makefile.in
## Created by Netbeans
AM_CPPFLAGS = \
-DPACKAGE_LOCALE_DIR=\""$(localedir)"\" \
-DPACKAGE_SRC_DIR=\""$(srcdir)"\" \
-DPACKAGE_DATA_DIR=\""$(pkgdatadir)"\"
bin_PROGRAMS = scratchautotool
program_INCLUDE_DIRS := /usr/bin/PR__bin
program_LIBRARY_DIRS := /usr/lib/PR__lib
CFLAGS += $(foreach includedir,$(program_INCLUDE_DIRS),-I$(includedir))
AM_LDFLAGS += $(foreach librarydir,$(program_LIBRARY_DIRS),-L$(librarydir))
scratchautotool_SOURCES = \
main.c \
Task.c \
SeedVP.c
depend :
makedepend --$(CFLAGS) --$(scratchautotool_SOURCES)
The makefile of the root directory is shown below:
## Process this file with automake to produce Makefile.in
## Created by Netbeans
SUBDIRS = src
scratchautotooldocdir = ${prefix}/doc/scratchautotool
scratchautotooldoc_DATA = \
README\
COPYING\
AUTHORS\
ChangeLog\
INSTALL\
NEWS
INTLTOOL_FILES = intltool-extract.in \
intltool-merge.in \
intltool-update.in
EXTRA_DIST = $(scratchautotooldoc_DATA) \
$(INTLTOOL_FILES)
DISTCLEANFILES = intltool-extract \
intltool-merge \
intltool-update \
po/.intltool-merge-cache
# Remove doc directory on uninstall
uninstall-local:
-rm -r $(scratchautotooldocdir)
but while I was invoking make from the terminal it gave me the following error:
Making all in src
make[2]: Entering directory `../src'
make[2]: *** No rule to make target `all'. Stop.
make[2]: Leaving directory `../src'
The error is pretty clear: it is expecting to find the target all, and isn't. I'm assuming you called make without specifying a target; the default is (surprise!) all.
I want to share the solution for my question with any one who will encounter the same issue, I have modified the makefile as shown below:
all: scratchautotool
depend :
makedepend $(CFLAGS) $(scratchautotool_SOURCES)
but this also gave the same error, so I've searched and I've found that the makedepend didn't exist so I had to install xutils-dev package(which includes the program makedepend) using the below command:
sudo apt-get install xutils-dev
but this command solves the above mentioned issue only! but the makefile now has a new issue :)
I'm building an uClibc i486 cross toolchain for an embedded system. The toolchain is built on Debian Wheezy (x86-64) and consists of the following components:
Binutils 2.24
GCC 4.7.3
Linux 3.2.54
uClibc 0.9.33.2
GMP 5.1.3
MPFR 3.1.2
MPC 1.0.2
These steps are used to build the toolchain:
Install Linux 3.2.54 headers
make mrproper
make \
ARCH=x86 \
INSTALL_HDR_PATH=/home/build-user/toolchain/i486-linux-uclibc \
headers_install
This step is successfully completed.
Build Binutils 2.24
Binutils is built in a separate directory as specified in the documentation.
./configure \
--prefix=/home/build-user/toolchain/ \
--target=i486-linux-uclibc
--with-sysroot=/home/build-user/toolchain/i486-linux-uclibc \
--with-lib-path=/home/build-user/toolchain/i486-linux-uclibc/lib \
--disable-nls \
--disable-multilib
make configure-host
make
make install
This step is successfully completed.
Build GMP 5.1.3
./configure \
--prefix=/home/build-user/toolchain/gmp \
--disable-shared \
--enable-static
make
make install
This step is successfully completed.
Build MPFR 3.1.2
./configure \
--prefix=/home/build-user/toolchain/mpfr \
--with-gmp=/home/build-user/toolchain/gmp \
--disable-shared \
--enable-static
make
make install
This step is successfully completed.
Build MPC 1.0.2
./configure \
--prefix=/home/build-user/toolchain/mpc \
--with-gmp=/home/build-user/toolchain/gmp \
--with-mpfr=/home/build-user/toolchain/mpfr \
--disable-shared \
--enable-static
make
make install
This step is successfully completed.
Build static GCC 4.7.3
GCC is built in a separate directory as specified in the documentation.
./configure \
--prefix=/home/build-user/toolchain \
--target=i486-linux-uclibc \
--with-arch=i486 \
--with-sysroot=/home/build-user/toolchain/i486-linux-uclibc \
--disable-multiarch \
--disable-nls \
--disable-shared \
--without-headers \
--with-newlib \
--disable-decimal-float \
--disable-libgomp \
--disable-libmudflap \
--disable-libssp \
--disable-libquadmath \
--disable-threads \
--enable-languages=c \
--disable-multilib \
--with-gmp=/home/build-user/toolchain/gmp \
--with-mpfr=/home/build-user/toolchain/mpfr \
--with-mpc=/home/build-user/toolchain/mpc
make all-gcc all-target-libgcc
make install-gcc install-target-libgcc
This step is successfully completed.
Build uClibc 0.9.33.2
The configuration file for uClibc is default with following options enabled:
TARGET_i386=y
CONFIG_486=y
UCLIBC_HAS_FENV=y
LINUXTHREADS_OLD=y
make \
ARCH=x86 \
DESTDIR=/home/build-user/toolchain/i486-linux-uclibc \
CROSS=i486-linux-uclibc- \
RUNTIME_PREFIX=/ \
DEVEL_PREFIX=/ \
KERNEL_HEADERS=/home/build-user/toolchain/i486-linux-uclibc/include \
install
This step is successfully completed.
Build final GCC 4.7.3
GCC is built in a separate directory as specified in the documentation.
./configure \
--prefix=/home/build-user/toolchain \
--target=i486-linux-uclibc \
--with-arch=i486 \
--with-sysroot=/home/build-user/toolchain/i486-linux-uclibc \
--with-native-system-header-dir=/include \
--disable-multiarch \
--disable-nls \
--enable-libssp \
--enable-c99 \
--disable-libgomp \
--enable-long-long \
--disable-libmudflap \
--enable-languages=c \
--disable-multilib \
--with-gmp=/home/build-user/toolchain/gmp \
--with-mpfr=/home/build-user/toolchain/mpfr \
--with-mpc=/home/build-user/toolchain/mpc
make
This step fails with the following errors:
/bin/bash /home/build-user/toolchain/packages/gcc-4.7.3/libgcc/../mkinstalldirs .
/home/build-user/toolchain/gcc-final-build/./gcc/xgcc -B/home/build-user/toolchain/gcc-final-build/./gcc/ -B/home/build-user/toolchain/i486-linux-uclibc/bin/ -B/home/build-user/toolchain/i486-linux-uclibc/lib/ -isystem /home/build-user/toolchain/i486-linux-uclibc/include -isystem /home/build-user/toolchain/i486-linux-uclibc/sys-include -O2 -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -fpic -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector -shared -nodefaultlibs -Wl,--soname=libgcc_s.so.1 -Wl,--version-script=libgcc.map -o ./libgcc_s.so.1.tmp -g -O2 -B./ _muldi3_s.o _negdi2_s.o _lshrdi3_s.o _ashldi3_s.o _ashrdi3_s.o _cmpdi2_s.o _ucmpdi2_s.o _clear_cache_s.o _trampoline_s.o __main_s.o _absvsi2_s.o _absvdi2_s.o _addvsi3_s.o _addvdi3_s.o _subvsi3_s.o _subvdi3_s.o _mulvsi3_s.o _mulvdi3_s.o _negvsi2_s.o _negvdi2_s.o _ctors_s.o _ffssi2_s.o _ffsdi2_s.o _clz_s.o _clzsi2_s.o _clzdi2_s.o _ctzsi2_s.o _ctzdi2_s.o _popcount_tab_s.o _popcountsi2_s.o _popcountdi2_s.o _paritysi2_s.o _paritydi2_s.o _powisf2_s.o _powidf2_s.o _powixf2_s.o _powitf2_s.o _mulsc3_s.o _muldc3_s.o _mulxc3_s.o _multc3_s.o _divsc3_s.o _divdc3_s.o _divxc3_s.o _divtc3_s.o _bswapsi2_s.o _bswapdi2_s.o _clrsbsi2_s.o _clrsbdi2_s.o _fixunssfsi_s.o _fixunsdfsi_s.o _fixunsxfsi_s.o _fixsfdi_s.o _fixdfdi_s.o _fixxfdi_s.o _fixunssfdi_s.o _fixunsdfdi_s.o _fixunsxfdi_s.o _floatdisf_s.o _floatdidf_s.o _floatdixf_s.o _floatundisf_s.o _floatundidf_s.o _floatundixf_s.o _divdi3_s.o _moddi3_s.o _udivdi3_s.o _umoddi3_s.o _udiv_w_sdiv_s.o _udivmoddi4_s.o tf-signs_s.o addtf3_s.o divtf3_s.o eqtf2_s.o getf2_s.o letf2_s.o multf3_s.o negtf2_s.o subtf3_s.o unordtf2_s.o fixtfsi_s.o fixunstfsi_s.o floatsitf_s.o floatunsitf_s.o fixtfdi_s.o fixunstfdi_s.o floatditf_s.o floatunditf_s.o extendsftf2_s.o extenddftf2_s.o extendxftf2_s.o trunctfsf2_s.o trunctfdf2_s.o trunctfxf2_s.o enable-execute-stack_s.o unwind-dw2_s.o unwind-dw2-fde-dip_s.o unwind-sjlj_s.o unwind-c_s.o emutls_s.o libgcc.a -lc && rm -f ./libgcc_s.so && if [ -f ./libgcc_s.so.1 ]; then mv -f ./libgcc_s.so.1 ./libgcc_s.so.1.backup; else true; fi && mv ./libgcc_s.so.1.tmp ./libgcc_s.so.1 && ln -s libgcc_s.so.1 ./libgcc_s.so
/home/build-user/toolchain/i486-linux-uclibc/bin/ld: cannot find /lib/libc.so.0
/home/build-user/toolchain/i486-linux-uclibc/bin/ld: cannot find /lib/uclibc_nonshared.a
/home/build-user/toolchain/i486-linux-uclibc/bin/ld: cannot find /lib/ld-uClibc.so.0
collect2: error: ld returned 1 exit status
make[2]: *** [libgcc_s.so] Error 1
make[2]: Leaving directory `/home/build-user/toolchain/gcc-final-build/i486-linux-uclibc/libgcc'
make[1]: *** [all-target-libgcc] Error 2
make[1]: Leaving directory `/home/build-user/toolchain/gcc-final-build'
make: *** [all] Error 2
I check the linker search path:
/home/build-user/toolchain/i486-linux-uclibc/bin/ld --verbose | grep SEARCH_DIR
SEARCH_DIR("/home/build-user/toolchain/i486-linux-uclibc/lib");
The path is correct, so I search for the allegedly missing files in the directory:
find /home/build-user/toolchain/i486-linux-uclibc/lib \( -name libc.so.0 -o -name uclibc_nonshared.a -o -name ld-uClibc.so.0 \)
/home/build-user/toolchain/i486-linux-uclibc/lib/uclibc_nonshared.a
/home/build-user/toolchain/i486-linux-uclibc/lib/ld-uClibc.so.0
/home/build-user/toolchain/i486-linux-uclibc/lib/libc.so.0
All the files are found in the directory.
Can someone tell me what I'm doing wrong?
This is a guess, but when I build GCC cross compilers, I use sysroot equal to prefix. This creates a special configuration for binutils and GCC which may help you here.
I've had a similar problem lately.
I've used: uClibc-ng-1.0.29, GCC-6.2.0, Linux from Analog Devices (4.6.0 or something close to it) and binutils-2.27. It was a cross-build for ARM. But I think it should also work in this case.
The problem is that when building uClibc, libc.so is not a real binary but a linker script that contains locations of libc.so.1, uclibc_nonshared.a and ld-uClibc.so.1. When uClibc is built the way you did, the linker script (libc.so) provides locations of these libraries with respect to /.
The solutions is to build uClibc like this:
D=home/build-user/toolchain/i486-linux-uclibc;
make \
ARCH=x86 \
DESTDIR=/ \
CROSS=i486-linux-uclibc- \
RUNTIME_PREFIX=${D}/ \
DEVEL_PREFIX=${D}/usr/ \
KERNEL_HEADERS=/home/build-user/toolchain/i486-linux-uclibc/include \
install
The eventual installation location remains the same, but the entrances in libc.so will contain now the correct paths to the missing/not-found libraries.
If you need for some reason RUNTIME_PREFIX to be the same as DEVEL_PREFIX then keep it. But uClibc's .config file suggests the way I proposed. Note that it may also affect building of GCC.