I have followed this link and adapted its steps to make it work for my project.
My goal is to create a libfile.a to distribute as a static library. The project tree is the following:
project
|
+-src
+- <some cpp and hpp files>
|
+ containers
|
+- <other cpp and hpp files>
I easily created configure.ac file and the Makefile.ams. The tree structure changed this way:
project
|
+- configure.ac
+- Makefile.am
+-src
+- <some cpp and hpp files>
+ Makefile.am
|
+ containers
|
+- <other cpp and hpp files>
Now, when I go: (*)
aclocal; autoreconf --install; autoconf; ./configure
make
.o files are generated for all the .*pp files contained in src, but it fails when it starts generating those targets in src/containers. So the Makefile is not generated properly. What am I doing wrong? Can someone help me?
PS here there are files involved:
# --- configure.ac ---
AC_PREREQ([2.68])
AC_INIT([filea], [1.0], [dev#host.net])
AM_INIT_AUTOMAKE([filea], [1.0])
AC_CONFIG_SRCDIR([src/HashFunctions.cpp])
AC_CONFIG_HEADERS([config.h])
AC_PROG_CXX
AC_PROG_RANLIB
AC_CHECK_HEADERS([stddef.h stdint.h string.h])
AC_HEADER_STDBOOL
AC_C_INLINE
AC_TYPE_SIZE_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT8_T
AC_FUNC_MALLOC
AC_FUNC_MKTIME
AC_CHECK_FUNCS([memset])
AC_OUTPUT([Makefile src/Makefile])
# --- Makefile.am ---
AUTOMAKE_OPTIONS = foreign
SUBDIRS = src
# --- src/Makefile.am ---
lib_LIBRARIES = libfile.a
libfile_a_SOURCES = \
ConfigLib.hpp \
ConfigLib.cpp \
HashFunctions.cpp \
HashFunctions.hpp \
Logger.hpp \
Logger.cpp \
Queue.hpp
libfile_a_SOURCES += \
containers/SafeContainer.cpp \
containers/SafeInterger.cpp \
containers/SafeMap.cpp
EDIT 1
as suggested by Brett Hale the commands marked with (*) have been replaced by the following ones:
autoreconf -fvi
Output:
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force
autoreconf: configure.ac: tracing
autoreconf: configure.ac: not using Libtool
autoreconf: running: /usr/bin/autoconf --force
autoreconf: running: /usr/bin/autoheader --force
autoreconf: running: automake --add-missing --copy --force-missing
autoreconf: Leaving directory `.'
When going with:
./configure
make
Still no rules are found to generate targets in the subdirectory.
EDIT 2 I switched to a non-recursive approach (Thanks to Karel Zak's blog) and finally I can makemy lib.
Still I don't know what I was doing wrong following the typical recursive approach; but, finally I made this work, switching to a non-recursive approach (as I wrote in EDIT 2). This article on Karel Zak's Blog helped me a lot!
# -- new configure.ac file --
AC_PREREQ([2.68])
AC_INIT([filea], [1.0], [dev#host.net])
AM_INIT_AUTOMAKE([filea], [1.0])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_SRCDIR([src/HashFunctions.cpp])
AM_INIT_AUTOMAKE([filea], [1.0])
LT_INIT
AC_CANONICAL_HOST
AC_PROG_LIBTOOL
AC_PROG_GREP
AC_PROG_EGREP
AC_PROG_CXX
...
AC_HEADER_STDBOOL
AC_C_INLINE
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_UINT8_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_FUNC_ERROR_AT_LINE
AC_FUNC_FORK
AC_FUNC_MALLOC
AC_FUNC_MKTIME
AC_CHECK_FUNCS([memset socket])
AC_OUTPUT([Makefile]) # the makefile is only one!
# In the subdirectory I have created few
# Makemodule.am included in the "main makefile.am"
# --- makefile.am ---
AUTOMAKE_OPTIONS = foreign
lib_LIBRARIES = filea.a
libfilea_a_SOURCES =
include src/Makemodule.am
include src/containers/Makemodule.am # now filea_a_SOURCES is a
# "global variable"
# -- src/Makemodule.am
libfilea_a_SOURCES += \
src/ConfigLib.hpp \
src/ConfigLib.cpp \
src/HashFunctions.cpp \
src/HashFunctions.hpp \
src/Logger.hpp \
src/Logger.cpp \
src/Queue.hpp
# -- src/containers/Makemodule.am
libfile_a_SOURCES += \
src/containers/SafeContainer.cpp \
src/containers/SafeInterger.cpp \
src/containers/SafeMap.cpp
Notice that now, even if Makemodule.am files are placed at different levels in the dir tree, whenever a filename is typed in one those modules, it has to be preceded by its relative path. This path is relative to Makefile location.
Related
This is a strange one (to me).
I'm finding that if I have a project containing multiple cpp files and I am trying to build them on a remote linux host with the Netbeans IDE, it complains about No Rule to make target for the first additional cpp file and then stops. This issue is not present when building the same project locally or when building to a remote Linux host using Netbeans on Linux.
Firstly, some points of note;
I'm using Netbeans on a Mac.
I'm remote building C++ files onto a remote linux host.
This issue only exists when there are multiple cpp files in the project.
This issue does not exist when remote building on a Linux machine.
The issue is the same whether building from the IDE or running make on the remote host.
I can build the project from the command line on the hose using g++[...]
I can only assume the issue is when Netbeans is generating the makefile variables, but for the life of me, cant seem to find where the problem lies and as I say, it's completely fine when doing the same thing on a Linux machine.
To provide some context, we can consider the following small project;
main.cpp
#include <cstdlib>
#include <stdio.h>
#include "other.h"
int main(int argc, char** argv)
{
printf ("hello %d \n",times_two(50));
return 0;
}
other.h
#ifndef OTHER_H
#define OTHER_H
int times_two(int a);
#endif /* OTHER_H */
other.h
int times_two(int a)
{
return a*2;
}
When building from the IDE to the remote Linux host, we get;
CLEAN SUCCESSFUL (total time: 212ms)
Copying project files to /home/plisken/.netbeans/remote/oracle-linux.shared/solaros.local-MacOSX-x86_64 at plisken#oracle-linux.shared
Building project files list...
Checking directory structure...
Checking previously uploaded files...
Checking links...
Uploading changed files:
Checking exec permissions...
Uploading changed files finished successfully.
cd '/home/plisken/.netbeans/remote/oracle-linux.shared/solaros.local-MacOSX-x86_64/Volumes/D_SLAVE/My Documents/My Projects/multiple_cpp_files/multiple_cpp_files'
/usr/bin/gmake -f Makefile CONF=Debug
"/usr/bin/gmake" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
gmake[1]: Entering directory '/home/plisken/.netbeans/remote/oracle-linux.shared/solaros.local-MacOSX-x86_64/Volumes/D_SLAVE/My Documents/My Projects/multiple_cpp_files/multiple_cpp_files'
"/usr/bin/gmake" -f nbproject/Makefile-Debug.mk /home/plisken/PROJECTS/bin/multiple_cpp_files
gmake[2]: Entering directory '/home/plisken/.netbeans/remote/oracle-linux.shared/solaros.local-MacOSX-x86_64/Volumes/D_SLAVE/My Documents/My Projects/multiple_cpp_files/multiple_cpp_files'
gmake[2]: *** No rule to make target '/Volumes/D_SLAVE/My Documents/My Projects/multiple_cpp_files/multiple_cpp_files/other.cpp', needed by 'build/Debug/GNU-Linux/_ext/96b75cbb/other.o'. Stop.
gmake[2]: Leaving directory '/home/plisken/.netbeans/remote/oracle-linux.shared/solaros.local-MacOSX-x86_64/Volumes/D_SLAVE/My Documents/My Projects/multiple_cpp_files/multiple_cpp_files'
gmake[1]: *** [nbproject/Makefile-Debug.mk:60: .build-conf] Error 2
gmake[1]: Leaving directory '/home/plisken/.netbeans/remote/oracle-linux.shared/solaros.local-MacOSX-x86_64/Volumes/D_SLAVE/My Documents/My Projects/multiple_cpp_files/multiple_cpp_files'
gmake: *** [nbproject/Makefile-impl.mk:40: .build-impl] Error 2
BUILD FAILED (exit value 2, total time: 224ms)
The makefiles I believe are relevant and automatically generated are as below;
makefile
#
# There exist several targets which are by default empty and which can be
# used for execution of your targets. These targets are usually executed
# before and after some main targets. They are:
#
# .build-pre: called before 'build' target
# .build-post: called after 'build' target
# .clean-pre: called before 'clean' target
# .clean-post: called after 'clean' target
# .clobber-pre: called before 'clobber' target
# .clobber-post: called after 'clobber' target
# .all-pre: called before 'all' target
# .all-post: called after 'all' target
# .help-pre: called before 'help' target
# .help-post: called after 'help' target
#
# Targets beginning with '.' are not intended to be called on their own.
#
# Main targets can be executed directly, and they are:
#
# build build a specific configuration
# clean remove built files from a configuration
# clobber remove all built files
# all build all configurations
# help print help mesage
#
# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and
# .help-impl are implemented in nbproject/makefile-impl.mk.
#
# Available make variables:
#
# CND_BASEDIR base directory for relative paths
# CND_DISTDIR default top distribution directory (build artifacts)
# CND_BUILDDIR default top build directory (object files, ...)
# CONF name of current configuration
# CND_PLATFORM_${CONF} platform name (current configuration)
# CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration)
# CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration)
# CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration)
# CND_PACKAGE_DIR_${CONF} directory of package (current configuration)
# CND_PACKAGE_NAME_${CONF} name of package (current configuration)
# CND_PACKAGE_PATH_${CONF} path to package (current configuration)
#
# NOCDDL
# Environment
MKDIR=mkdir
CP=cp
CCADMIN=CCadmin
# build
build: .build-post
.build-pre:
# Add your pre 'build' code here...
.build-post: .build-impl
# Add your post 'build' code here...
# clean
clean: .clean-post
.clean-pre:
# Add your pre 'clean' code here...
.clean-post: .clean-impl
# Add your post 'clean' code here...
# clobber
clobber: .clobber-post
.clobber-pre:
# Add your pre 'clobber' code here...
.clobber-post: .clobber-impl
# Add your post 'clobber' code here...
# all
all: .all-post
.all-pre:
# Add your pre 'all' code here...
.all-post: .all-impl
# Add your post 'all' code here...
# build tests
build-tests: .build-tests-post
.build-tests-pre:
# Add your pre 'build-tests' code here...
.build-tests-post: .build-tests-impl
# Add your post 'build-tests' code here...
# run tests
test: .test-post
.test-pre: build-tests
# Add your pre 'test' code here...
.test-post: .test-impl
# Add your post 'test' code here...
# help
help: .help-post
.help-pre:
# Add your pre 'help' code here...
.help-post: .help-impl
# Add your post 'help' code here...
# include project implementation makefile
include nbproject/Makefile-impl.mk
# include project make variables
include nbproject/Makefile-variables.mk
Makefile-impl.mk
#
# Generated Makefile - do not edit!
#
# Edit the Makefile in the project folder instead (../Makefile). Each target
# has a pre- and a post- target defined where you can add customization code.
#
# This makefile implements macros and targets common to all configurations.
#
# NOCDDL
# Building and Cleaning subprojects are done by default, but can be controlled with the SUB
# macro. If SUB=no, subprojects will not be built or cleaned. The following macro
# statements set BUILD_SUB-CONF and CLEAN_SUB-CONF to .build-reqprojects-conf
# and .clean-reqprojects-conf unless SUB has the value 'no'
SUB_no=NO
SUBPROJECTS=${SUB_${SUB}}
BUILD_SUBPROJECTS_=.build-subprojects
BUILD_SUBPROJECTS_NO=
BUILD_SUBPROJECTS=${BUILD_SUBPROJECTS_${SUBPROJECTS}}
CLEAN_SUBPROJECTS_=.clean-subprojects
CLEAN_SUBPROJECTS_NO=
CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}}
# Project Name
PROJECTNAME=multiple_cpp_files
# Active Configuration
DEFAULTCONF=Debug
CONF=${DEFAULTCONF}
# All Configurations
ALLCONFS=Debug Release
# build
.build-impl: .build-pre .validate-impl .depcheck-impl
##echo "=> Running $#... Configuration=$(CONF)"
"${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf
# clean
.clean-impl: .clean-pre .validate-impl .depcheck-impl
##echo "=> Running $#... Configuration=$(CONF)"
"${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf
# clobber
.clobber-impl: .clobber-pre .depcheck-impl
##echo "=> Running $#..."
for CONF in ${ALLCONFS}; \
do \
"${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf; \
done
# all
.all-impl: .all-pre .depcheck-impl
##echo "=> Running $#..."
for CONF in ${ALLCONFS}; \
do \
"${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf; \
done
# build tests
.build-tests-impl: .build-impl .build-tests-pre
##echo "=> Running $#... Configuration=$(CONF)"
"${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-tests-conf
# run tests
.test-impl: .build-tests-impl .test-pre
##echo "=> Running $#... Configuration=$(CONF)"
"${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .test-conf
# dependency checking support
.depcheck-impl:
#echo "# This code depends on make tool being used" >.dep.inc
#if [ -n "${MAKE_VERSION}" ]; then \
echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES} \$${TESTOBJECTFILES}))" >>.dep.inc; \
echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \
echo "include \$${DEPFILES}" >>.dep.inc; \
echo "endif" >>.dep.inc; \
else \
echo ".KEEP_STATE:" >>.dep.inc; \
echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \
fi
# configuration validation
.validate-impl:
#if [ ! -f nbproject/Makefile-${CONF}.mk ]; \
then \
echo ""; \
echo "Error: can not find the makefile for configuration '${CONF}' in project ${PROJECTNAME}"; \
echo "See 'make help' for details."; \
echo "Current directory: " `pwd`; \
echo ""; \
fi
#if [ ! -f nbproject/Makefile-${CONF}.mk ]; \
then \
exit 1; \
fi
# help
.help-impl: .help-pre
#echo "This makefile supports the following configurations:"
#echo " ${ALLCONFS}"
#echo ""
#echo "and the following targets:"
#echo " build (default target)"
#echo " clean"
#echo " clobber"
#echo " all"
#echo " help"
#echo ""
#echo "Makefile Usage:"
#echo " make [CONF=<CONFIGURATION>] [SUB=no] build"
#echo " make [CONF=<CONFIGURATION>] [SUB=no] clean"
#echo " make [SUB=no] clobber"
#echo " make [SUB=no] all"
#echo " make help"
#echo ""
#echo "Target 'build' will build a specific configuration and, unless 'SUB=no',"
#echo " also build subprojects."
#echo "Target 'clean' will clean a specific configuration and, unless 'SUB=no',"
#echo " also clean subprojects."
#echo "Target 'clobber' will remove all built files from all configurations and,"
#echo " unless 'SUB=no', also from subprojects."
#echo "Target 'all' will will build all configurations and, unless 'SUB=no',"
#echo " also build subprojects."
#echo "Target 'help' prints this message."
#echo ""
Makefile-variables.mk
#
# Generated - do not edit!
#
# NOCDDL
#
CND_BASEDIR=`pwd`
CND_BUILDDIR=build
CND_DISTDIR=dist
# Debug configuration
CND_PLATFORM_Debug=GNU-Linux
CND_ARTIFACT_DIR_Debug=/home/plisken/PROJECTS/bin
CND_ARTIFACT_NAME_Debug=multiple_cpp_files
CND_ARTIFACT_PATH_Debug=/home/plisken/PROJECTS/bin/multiple_cpp_files
CND_PACKAGE_DIR_Debug=dist/Debug/GNU-Linux/package
CND_PACKAGE_NAME_Debug=multiplecppfiles.tar
CND_PACKAGE_PATH_Debug=dist/Debug/GNU-Linux/package/multiplecppfiles.tar
# Release configuration
CND_PLATFORM_Release=GNU-MacOSX
CND_ARTIFACT_DIR_Release=dist/Release/GNU-MacOSX
CND_ARTIFACT_NAME_Release=multiple_cpp_files
CND_ARTIFACT_PATH_Release=dist/Release/GNU-MacOSX/multiple_cpp_files
CND_PACKAGE_DIR_Release=dist/Release/GNU-MacOSX/package
CND_PACKAGE_NAME_Release=multiplecppfiles.tar
CND_PACKAGE_PATH_Release=dist/Release/GNU-MacOSX/package/multiplecppfiles.tar
#
# include compiler specific variables
#
# dmake command
ROOT:sh = test -f nbproject/private/Makefile-variables.mk || \
(mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk)
#
# gmake command
.PHONY: $(shell test -f nbproject/private/Makefile-variables.mk || (mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk))
#
include nbproject/private/Makefile-variables.mk
Makefile-debug.mk
#
# Generated Makefile - do not edit!
#
# Edit the Makefile in the project folder instead (../Makefile). Each target
# has a -pre and a -post target defined where you can add customized code.
#
# This makefile implements configuration specific macros and targets.
# Environment
MKDIR=mkdir
CP=cp
GREP=grep
NM=nm
CCADMIN=CCadmin
RANLIB=ranlib
CC=gcc
CCC=g++
CXX=g++
FC=gfortran
AS=as
# Macros
CND_PLATFORM=GNU-Linux
CND_DLIB_EXT=so
CND_CONF=Debug
CND_DISTDIR=dist
CND_BUILDDIR=build
# Include project Makefile
include Makefile
# Object Directory
OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}
# Object Files
OBJECTFILES= \
${OBJECTDIR}/_ext/96b75cbb/other.o \
${OBJECTDIR}/main.o
# C Compiler Flags
CFLAGS=
# CC Compiler Flags
CCFLAGS=
CXXFLAGS=
# Fortran Compiler Flags
FFLAGS=
# Assembler Flags
ASFLAGS=
# Link Libraries and Options
LDLIBSOPTIONS=
# Build Targets
.build-conf: ${BUILD_SUBPROJECTS}
"${MAKE}" -f nbproject/Makefile-${CND_CONF}.mk /home/plisken/PROJECTS/bin/multiple_cpp_files
/home/plisken/PROJECTS/bin/multiple_cpp_files: ${OBJECTFILES}
${MKDIR} -p /home/plisken/PROJECTS/bin
${LINK.cc} -o /home/plisken/PROJECTS/bin/multiple_cpp_files ${OBJECTFILES} ${LDLIBSOPTIONS}
${OBJECTDIR}/_ext/96b75cbb/other.o: /Volumes/D_SLAVE/My\ Documents/My\ Projects/multiple_cpp_files/multiple_cpp_files/other.cpp
${MKDIR} -p ${OBJECTDIR}/_ext/96b75cbb
${RM} "$#.d"
$(COMPILE.cc) -g -I/Volumes/D_SLAVE/My\ Documents/My\ Projects/multiple_cpp_files/multiple_cpp_files -MMD -MP -MF "$#.d" -o ${OBJECTDIR}/_ext/96b75cbb/other.o /Volumes/D_SLAVE/My\ Documents/My\ Projects/multiple_cpp_files/multiple_cpp_files/other.cpp
${OBJECTDIR}/main.o: main.cpp
${MKDIR} -p ${OBJECTDIR}
${RM} "$#.d"
$(COMPILE.cc) -g -I/Volumes/D_SLAVE/My\ Documents/My\ Projects/multiple_cpp_files/multiple_cpp_files -MMD -MP -MF "$#.d" -o ${OBJECTDIR}/main.o main.cpp
# Subprojects
.build-subprojects:
# Clean Targets
.clean-conf: ${CLEAN_SUBPROJECTS}
${RM} -r ${CND_BUILDDIR}/${CND_CONF}
# Subprojects
.clean-subprojects:
# Enable dependency checking
.dep.inc: .depcheck-impl
include .dep.inc
To be clear, if I log onto the remote host where the files are and run;
g++ -o test main.cpp other.cpp
it naturally builds completely fine.
Any suggestions would be greatly appreciated.
I'm using GoogleTest with bazel and when I run bazel test :tokens_test (rule defined below) I have a failing test, but when I run the compiled tests I see the expected result. It is failing because the test can not open the test data file. The directory layout and the BUILD rule for the test I'm running look like this:
tokens/
BUILD
tokens_test.cpp
test_data/
test_input1.txt
cc_test(
name = "tokens_test",
srcs = ["tokens_test.cpp"],
deps = [
'#gtest//:gtest'
'#gtest//:gtest_main',
],
data = ["//tokens/test_data:test_input1.txt"]
)
At this point the test is just a wrapper to open the file and read in the test data which is the bit thats failing.
TEST(Tokenizer, OpenFileTest) {
auto fin = std::ifstream("test_data/test_input1.txt");
std::cout << a.get(); // Outputs -1.
}
When I navigate to the bazel-out location and find my way to the tokens runfiles directory I can see the compiled test excutable.
[jibberish]/__main__/tokens>ls
test_data/
test_input1.txt
tokens_test
And when I run the executable:
[jibberish]/__main__/tokens>./tokens_test
...normal test output...
The correct output!
...more test output...
I'm lost as to where to start looking for the problem. I've tried including a BUILD in the test_data directory with an exports_files rule, using a variety of relatives paths in the BUILD files and my source code and a lot of permutations of those relative paths.
Define your data as
data = ["test_data/test_input1.txt"]
Use absolute path: ./tokens/test_data/test_input1.txt
To find it run your test with a bazel test --sandbox_debug -s. The last command will looks like that one:
SUBCOMMAND: # //:hello_test [action 'Testing //:hello_test', configuration: faff19e6fd939f490ac11578d94024c6b7a032836cde039fd5edd28b838194e8, execution platform: #local_config_platform//:host]
(cd /home/s/.cache/bazel/_bazel_s/fa4c7c7c7db2888182e4f15990b55d58/execroot/com_google_absl_hello_world && \
exec env - \
EXPERIMENTAL_SPLIT_XML_GENERATION=1 \
RUNFILES_DIR=bazel-out/k8-fastbuild/bin/hello_test.runfiles \
RUN_UNDER_RUNFILES=1 \
TEST_BINARY=./hello_test \
TEST_INFRASTRUCTURE_FAILURE_FILE=bazel-out/k8-fastbuild/testlogs/hello_test/test.infrastructure_failure \
TEST_LOGSPLITTER_OUTPUT_FILE=bazel-out/k8-fastbuild/testlogs/hello_test/test.raw_splitlogs/test.splitlogs \
TEST_PREMATURE_EXIT_FILE=bazel-out/k8-fastbuild/testlogs/hello_test/test.exited_prematurely \
TEST_SIZE=medium \
TEST_SRCDIR=bazel-out/k8-fastbuild/bin/hello_test.runfiles \
TZ=UTC \
XML_OUTPUT_FILE=bazel-out/k8-fastbuild/testlogs/hello_test/test.xml \
external/bazel_tools/tools/test/test-setup.sh ./hello_test)
Then you can paste the whole (cd ...) one-liner to reproduce the exact sandbox environment as during the bazel test run. For example you can substitute the last line in that way:
(cd /home/s/.cache/bazel/_bazel_s/fa4c7c7c7db2888182e4f15990b55d58/execroot/com_google_absl_hello_world && \
exec env - \
EXPERIMENTAL_SPLIT_XML_GENERATION=1 \
RUNFILES_DIR=bazel-out/k8-fastbuild/bin/hello_test.runfiles \
RUN_UNDER_RUNFILES=1 \
TEST_BINARY=./hello_test \
TEST_INFRASTRUCTURE_FAILURE_FILE=bazel-out/k8-fastbuild/testlogs/hello_test/test.infrastructure_failure \
TEST_LOGSPLITTER_OUTPUT_FILE=bazel-out/k8-fastbuild/testlogs/hello_test/test.raw_splitlogs/test.splitlogs \
TEST_PREMATURE_EXIT_FILE=bazel-out/k8-fastbuild/testlogs/hello_test/test.exited_prematurely \
TEST_SIZE=medium \
TEST_SRCDIR=bazel-out/k8-fastbuild/bin/hello_test.runfiles \
TZ=UTC \
XML_OUTPUT_FILE=bazel-out/k8-fastbuild/testlogs/hello_test/test.xml \
bash -c 'pwd && ls')
So bash -c 'pwd && ls' will show the current directory path and content.
I'm having the following problem when using automake to 'make dist'. Below is a snap shot of the error being reported by the compiler. I'm using Debian 10.5, with the default compiler version 8.0.3; autoconf 2.69; automake 1.16.1, libtool 2.4.6
######## Problem ########
aperri#debian:~/XerlangCPL2$ make dist
make dist-gzip am__post_remove_distdir='#:'
make[1]: Entering directory '/home/aperri/XerlangCPL2'
make distdir-am
make[2]: Entering directory '/home/aperri/XerlangCPL2'
make[2]: *** No rule to make target 'bootstrap', needed by 'distdir-am'. Stop.
make[2]: Leaving directory '/home/aperri/XerlangCPL2'
make[1]: *** [Makefile:633: distdir] Error 2
make[1]: Leaving directory '/home/aperri/XerlangCPL2'
make: *** [Makefile:710: dist] Error 2
I'm including my configure.ac and makefile.am in this message with the hope that there is a solution to this problem
######## configure.ac ########
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT([XerlangCPL], [1.0], [aperri1001#gmail.com])
AC_CONFIG_SRCDIR([src/xmlPROC.cpp])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4])
# Enable "automake" to simplify creating Makefiles
AM_INIT_AUTOMAKE([1.16.1 subdir-objects -Wall -Werror])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
# Checks for programs.
AC_PROG_CC
AC_PROG_CXXCPP
AC_PROG_CXX
# Used in conjuction with {TARGET}_CPPFLAGS = -DDEBUG in Makefile.am
AM_PROG_CC_C_O
# Checks for libraries.
AX_BOOST_BASE([1.67], [], AC_MSG_ERROR([Could not find a useful version of boost]))
AX_BOOST_FILESYSTEM
AX_BOOST_SYSTEM
AX_BOOST_PROGRAM_OPTIONS
AX_BOOST_REGEX
# AX_BOOST_DATE_TIME
# AX_BOOST_THREAD
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions
PKG_CHECK_MODULES(libxml, libxml++-2.6 >= 2.10.0 )
AC_CHECK_PROGS([DOXYGEN], [doxygen])
if test -z "$DOXYGEN";
then AC_MSG_WARN([Doxygen not found - continuing without Doxygen support])
fi
AM_CONDITIONAL([HAVE_DOXYGEN], [test -n "$DOXYGEN"])
AC_CONFIG_FILES([Makefile doc/Doxyfile])
# AM_CONDITIONAL([DEBUG], [test x$debug = xtrue])
# AC_ARG_WITH(debug, [ --with-debug add the debugging module], [AC_DEFINE(WITH_DEBUG,1,0)
# AC_SUBST(WITH_DEBUG,1)
# CXXFLAGS="-O0 -ggdb"])
AC_OUTPUT
echo "
XErlang Compiler ($PACKAGE_NAME) version $PACKAGE_VERSION
Prefix.........: $prefix
Debug Build....: $debug
C++ Compiler...: $CXX $CXXFLAGS $CPPFLAGS
Linker.........: $LD $LDFLAGS $LIBS
"
######## makefile.am ########
ACLOCAL_AMFLAGS = -I m4 --install
bin_PROGRAMS = xerlangCPL
xerlangCPL_SOURCES = \
src/xmlPROC.cpp \
src/xml_structs.h \
src/debug.h \
src/conxsTracker.cpp \
src/conxs_tracker.h \
src/xmlConxsParser.cpp \
src/oven_control
xerlangCPL_LDFLAGS = -DDEBUG \
$(libxml_LIBS) \
$(BOOST_LDFLAGS) \
$(BOOST_SYSTEM_LDFLAGS) \
$(BOOST_FILESYSTEM_LDFLAGS) \
$(BOOST_PROGRAM_OPTIONS_LDFLAGS)
xerlangCPL_CPPFLAGS = $(libxml_CFLAGS) \
$(BOOST_CPPFLAGS)
xerlangCPL_LIBS = $(BOOST_SYSTEM_LIBS) \
$(BOOST_FILESYSTEM_LIBS) \
$(BOOST_PROGRAM_OPTIONS_LIBS)
xerlangCPL_CXXFLAGS = -lboost_filesystem -ldl -lboost_system
# start of Doxygen section
if HAVE_DOXYGEN
doxyfile.stamp:
$(DOXYGEN) $(top_srcdir)/doc/Doxyfile
echo Timestamp > $#
CLEANFILES = $(top_srcdir)/doxyfile.stamp
# all-local: doxyfile.stamp
all-local: doxyfile.stamp
# clean-local:
# rm -rf $(top_srcdir)/
endif
EXTRA_DIST = bootstrap m4/NOTES
The problem could be related to the inclusion of Boost Modules or the lack of them.
The problem is that EXTRA_DIST lists some mysterious file called bootstrap.
Makefile.am provides no instructions for building this file.
Therefore, this file is expected to already exist in the build directory, and it does not.
That's the reason for your make dist failure.
The reason for the missing file is something that you'll have to figure out on your own, the only thing that can be stated here is that its absence is the reason for your build failure.
You could, of course
touch bootstrap
and create an empty file in the build directory, which will be good enough. But you should investigate, in your project, what this file is, and where it should come from, and fix things accordingly.
I am facing a small problem when trying to build my code with autotools.
My file structure is:
$ tree
.
|-- configure.ac
|-- Makefile.am
`-- src
|-- constants.f90
|-- environment.f90
|-- init.f90
|-- main.f90
`-- util.f90
(deleted possibly unnecessary lines)
and my Makefile.am is:
#SUBDIRS= help
bin_PROGRAMS = scasr
scasr_SOURCES = \
src/constants.f90 src/environment.f90 src/util.f90 \
src/init.f90 src/main.f90
scasr_LDADD =
EXTRA_DIST= autogen.sh
CLEANFILES =*.mod
The problem is src/(*.f90)'s except main.f90 are module. Hence, if I
have to write the makefile by hand, I will have:
constants.o : constants.f90
environment.o : environment.f90
init.o : init.f90 util.o constants.o
main.o : main.f90 init.o constants.o environment.o
util.o : util.f90 constants.o
so, for Makefile.am, I have to make a strict order of files in
scasr_SOURCES. i.e.
with the sources as :
scasr_SOURCES = \
src/constants.f90 src/environment.f90 src/util.f90 \
src/init.f90 src/main.f90
It compiles fine.
But if I have as:
scasr_SOURCES = src/main.f90 \
src/constants.f90 src/environment.f90 src/util.f90 \
src/init.f90
I get error:
make all-am
make[1]: Entering directory `/home/rudra/Programs/ScASR/trunk'
gfortran -g -O2 -c -o src/main.o src/main.f90
src/main.f90:7.4:
use mget_env
1
Fatal Error: Can't open module file 'mget_env.mod' for reading at (1):
No such file or directory
make[1]: *** [src/main.o] Error 1
Is there any way out so that make/configure will check the dependency by
itself? Or I must keep a strict order?
(Answers in the comments. See Question with no answers, but issue solved in the comments (or extended in chat) )
#Stefan wrote:
You could enter the dependencies directly to your Makefile.am. So simply put your handwritten Makefile rules (the third code part in your post) in the Makefile.am. Automatic dependency tracking is, as far as I know, not (yet) possible. This could change with the addition of submodules, which are defined in Fortran 2008 but not yet implemented in any popular compiler.
The OP Wrote:
As per #Stefan's comment, I have added the dependencies in make file, and that solved the problem. I have tested that the order of source code is not important anymore. Since, there is not many stuff in internet available, I am putting the complete procedure here:
create a dependency list (makedepf90 is a good option)
$ makedepf90 src/*.f90 src/constants.o : src/constants.f90 src/environment.o : src/environment.f90 src/init.o : src/init.f90 src/util.o src/constants.o src/main.o : src/main.f90 src/init.o src/constants.o src/environment.o src/util.o : src/util.f90 src/constants.o
Just copy-paste the output of step 1 after the scasr_SOURCES:
scasr_SOURCES = src/main.f90\ src/constants.f90 src/environment.f90 rc/util.f90 src/init.f90 src/constants.o : src/constants.f90 src/environment.o : src/environment.f90 src/init.o : src/init.f90 src/util.o src/constants.o src/main.o : src/main.f90 src/init.o src/constants.o src/environment.o src/util.o : src/util.f90 src/constants.o
NB: I have not tested if it will work if you place it some place else in the makefile. But this is working.
Does anyone know if qmake can create a .pc file? I found someone that said it could here: http://www.qtcentre.org/threads/24422-How-can-we-create-.pc-file-automatically. But I have tried it and got the same results as the person having the issue at the bottom of the thread. I was wondering if someone knew anything about this.
TEMPLATE = lib
TARGET = proc_Model
QT += declarative dbus
CONFIG += qt plugin dbus create_pc
DESTDIR = /usr/lib/
OBJECTS_DIR = .obj
MOC_DIR = .moc
TARGET = $$qtLibraryTarget($$TARGET)
INCLUDEPATH += ../common
# Input
SOURCES += ../common/proc_struct.cpp \
listitem.cpp \
listmodel.cpp \
process.cpp \
proc_if.cpp
HEADERS += ../common/proc_struct.h \
listitem.h \
listmodel.h \
process.h \
proc_if.h
headers.path= /usr/include/proc_Model
headers.files = ../common/proc_struct.h \
listitem.h \
listmodel.h \
process.h \
proc_if.h
target.path = /usr/lib
QMAKE_PKGCONFIG_NAME = proc_Model
QMAKE_PKGCONFIG_DESCRIPTION = Model that emits process info
QMAKE_PKGCONFIG_LIBDIR = $$target.path
QMAKE_PKGCONFIG_INCDIR = $$target.path
QMAKE_PKGCONFIG_DESTDIR = pkgconfig
INSTALLS+=headers target
When I make install, I get the following output:
install -m 755 -p "/usr/lib/libproc_Model.so" "/usr/lib/libproc_Model.so"
install: `/usr/lib/libproc_Model.so' and `/usr/lib/libproc_Model.so' are the same file
make: [install_target] Error 1 (ignored)
strip --strip-unneeded "/usr/lib/libproc_Model.so"
install -m 644 -p "/usr/lib/pkgconfig/proc_Model.pc" "/usr/lib/pkgconfig/proc_Model.pc"
install: cannot stat `/usr/lib/pkgconfig/proc_Model.pc': No such file or directory
make: [install_target] Error 1 (ignored)
According to qmake source code, you have to add:
CONFIG += create_prl no_install_prl
create_pc only adds the rule for the .pc file target to the makefile with the command "qmake -prl" and that command only creates the .pc file if the create_prl option is present.
no_install_prl prevents the unneeded .prl file, generated by create_prl, to be installed in ${target.path}.
I made a complete example here:
https://github.com/pvanhoof/dir-examples/blob/master/qmake-example/src/libs/qmake-example/qmake-example.pro
## We get the PREFIX, MAJOR_VERSION, MINOR_VERSION and PATCH_VERSION
## from this project-wide include
include(../../../qmake-example.pri)
## We will use the standard lib template of qmake
TEMPLATE = lib
## We need to set VERSION to a semver.org version for compile_libtool
VERSION = $${MAJOR_VERSION}"."$${MINOR_VERSION}"."$${PATCH_VERSION}
## According https://autotools.io/libtool/version.html, section 4.3
## we should have as target-name the API version in the library's name
TARGET = qmake-example-$${MAJOR_VERSION}"."$${MINOR_VERSION}
## We will write a define in config.h for access to the semver.org
## version as a double quoted string
QMAKE_SUBSTITUTES += config.h.in
## Our example happens to use QDebug, so we need QtCore here
QT = core
## This is of course optional
CONFIG += c++14
## We will be using libtool style libraries
CONFIG += compile_libtool
CONFIG += create_libtool
## These will create a pkg-config .pc file for us
CONFIG += create_pc create_prl no_install_prl
## Project sources
SOURCES = \
qmake-example.cpp
## Project headers
HEADERS = \
qmake-example.h
## We will install the headers in a API specific include path
headers.path = $${PREFIX}/include/qmake-example-$${MAJOR_VERSION}"."$${MINOR_VERSION}
## Here will go all the installed headers
headers.files = $${HEADERS}
## Here we will install the library to
target.path = $${PREFIX}/lib
## This is the configuration for generating the pkg-config file
QMAKE_PKGCONFIG_NAME = $${TARGET}
QMAKE_PKGCONFIG_DESCRIPTION = An example that illustrates how to do it right with qmake
# This is our libdir
QMAKE_PKGCONFIG_LIBDIR = $$target.path
# This is where our API specific headers are
QMAKE_PKGCONFIG_INCDIR = $$headers.path
QMAKE_PKGCONFIG_DESTDIR = pkgconfig
QMAKE_PKGCONFIG_PREFIX = $${PREFIX}
QMAKE_PKGCONFIG_VERSION = $$VERSION
## Installation targets (the pkg-config seems to install automatically)
INSTALLS += headers target