autotools automake generated makefile does no work: make all-am - c++

It took several painful days work to construct a autotools project. I got a configure file and it can generate a Makefile with several hundred lines of code. But when invoking make it only emits the following lines in 1 milliseconds.
make
make all-am
make[1]: Entering directory '/home/myacount/coding/orpara'
make[1]: Leaving directory '/home/myaccount/coding/orpara'
It seems that no work is done. The line that produced the output in the Makefile:
AUTOMAKE_OPTIONS = subdir-objects
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-am
My configure.ac file is not complicated:
....
AM_INIT_AUTOMAKE([-Wall -Werror])
AM_PROG_AR
AC_CONFIG_SRCDIR([src/interval.cpp])
AC_CONFIG_HEADERS([config.h])
LT_PREREQ([2.4])
LT_INIT([dlopen])
AC_CONFIG_MACRO_DIR([m4])
# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
AC_PROG_INSTALL
AC_LANG([C], [C++])
# Checks for libraries.
I have no clue where to start my debug. I am using automake to generate the makefile.
My Makefile.am in the top level directory is simple:
ACLOCAL_AMFLAGS = -I m4
SUBIDRS = src
The Makefile.am in the src directory has two targets (the PROGRAM primary is for testing only)
bin_PROGRAMS = GrishinDistance
GrishinDistance_SOURCES=GrishinDistance.cpp
Not showing the Makefile.am in subdir seqaln.

My problem is with the Makfile.am in the top directory:
SUBIDRS = src
A typo error with SUBDIRS => SUBIDRS.
If others have similar problem, you should be looking into these typo errors.

Related

How to integrate Package with both Cmake and Make files into Buildroot

I want to integrate the package amazon kinesis video streams webrtc SDK in buidroot. Can anyone guide me on how can I do this? I am a newbie with buildroot.
The issue is the examples available on the internet only discussion if the package has make the file only, the issue with webrtc SDK is that it has both Cmake and make file.
Executing CMake command builds the build and make command builds the application.
https://github.com/awslabs/amazon-kinesis-video-streams-webrtc-sdk-c
Cmake projects generally use make (or some other generated build system) to build the actual code. You should follow the instructions in the buildroot manual for a "Cmake package", and it should generally work out
In the manual, it's section 18.7
https://buildroot.org/downloads/manual/manual.html#_infrastructure_for_cmake_based_packages
Hi I tried adding package:
this is my amazon-kinesis-video-streams-webrtc-sdk-c.mk file:
################################################################################
#
# amazon-kinesis-video-streams-webrtc-sdk-c
#
################################################################################
BR2_PACKAGE_AMAZON_KINESIS_VIDEO_STREAMS_WEBRTC_SDK_C_VERSION = 1.6.0
BR2_PACKAGE_AMAZON_KINESIS_VIDEO_STREAMS_WEBRTC_SDK_C_SITE = $(call github,awslabs,amazon-kinesis-video-streams-webrtc-sdk-c,v$(BR2_PACKAGE_AMAZON_KINESIS_VIDEO_STREAMS_WEBRTC_SDK_C_VERSION))
BR2_PACKAGE_AMAZON_KINESIS_VIDEO_STREAMS_WEBRTC_SDK_C_LICENSE = MIT
BR2_PACKAGE_AMAZON_KINESIS_VIDEO_STREAMS_WEBRTC_SDK_C_LICENSE_FILES = LICENSE-MIT
BR2_PACKAGE_AMAZON_KINESIS_VIDEO_STREAMS_WEBRTC_SDK_C_CONF_OPTS = -DBUILD_DEMOS=ON
BR2_PACKAGE_AMAZON_KINESIS_VIDEO_STREAMS_WEBRTC_SDK_C_INSTALL_STAGING = YES
$(eval $(cmake-package))
and this Config.in file:
config BR2_PACKAGE_AMAZON_KINESIS_VIDEO_STREAMS_WEBRTC_SDK_C
bool "amazon-kinesis-video-streams-webrtc-sdk-c"
depends on !BR2_STATIC_LIBS
depends on BR2_TOOLCHAIN_HAS_THREADS
help
web-rtc
But I am getting an error that CMakeTextfile does not exist.
make amazon-kinesis-video-streams-webrtc-sdk-c-rebuild
rm -f /home/bilal/work/buildroot/output/build/amazon-kinesis-video-streams-webrtc-sdk-c/.stamp_installed
rm -f /home/bilal/work/buildroot/output/build/amazon-kinesis-video-streams-webrtc-sdk-c/.stamp_staging_installed
rm -f /home/bilal/work/buildroot/output/build/amazon-kinesis-video-streams-webrtc-sdk-c/.stamp_target_installed
rm -f /home/bilal/work/buildroot/output/build/amazon-kinesis-video-streams-webrtc-sdk-c/.stamp_images_installed
rm -f /home/bilal/work/buildroot/output/build/amazon-kinesis-video-streams-webrtc-sdk-c/.stamp_host_installed
rm -f /home/bilal/work/buildroot/output/build/amazon-kinesis-video-streams-webrtc-sdk-c/.stamp_built
>>> amazon-kinesis-video-streams-webrtc-sdk-c Extracting
>>> amazon-kinesis-video-streams-webrtc-sdk-c Patching
>>> amazon-kinesis-video-streams-webrtc-sdk-c Configuring
(mkdir -p /home/bilal/work/buildroot/output/build/amazon-kinesis-video-streams-webrtc-sdk-c/ && cd /home/bilal/work/buildroot/output/build/amazon-kinesis-video-streams-webrtc-sdk-c/ && rm -f CMakeCache.txt && PATH="/home/bilal/work/buildroot/output/host/bin:/home/bilal/work/buildroot/output/host/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin" /usr/local/bin/cmake /home/bilal/work/buildroot/output/build/amazon-kinesis-video-streams-webrtc-sdk-c/ -DCMAKE_TOOLCHAIN_FILE="/home/bilal/work/buildroot/output/host/share/buildroot/toolchainfile.cmake" -DCMAKE_INSTALL_PREFIX="/usr" -DCMAKE_COLOR_MAKEFILE=OFF -DBUILD_DOC=OFF -DBUILD_DOCS=OFF -DBUILD_EXAMPLE=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TEST=OFF -DBUILD_TESTS=OFF -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=ON )
CMake Error: The source directory "/home/bilal/work/buildroot/output/build/amazon-kinesis-video-streams-webrtc-sdk-c" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
package/pkg-generic.mk:249: recipe for target '/home/bilal/work/buildroot/output/build/amazon-kinesis-video-streams-webrtc-sdk-c/.stamp_configured' failed
make[1]: *** [/home/bilal/work/buildroot/output/build/amazon-kinesis-video-streams-webrtc-sdk-c/.stamp_configured] Error 1
Makefile:84: recipe for target '_all' failed
make: *** [_all] Error 2

CMake is not found when running through make

I'm trying to build https://github.com/AlbertWerner/cryptonotecoinwallet and facing an issue.
According to the README of the repo, I can run cmake command and it completes without any errors. But then, when I run make, it gives me the below error.
$ make
make: /usr/bin/cmake: Command not found
make: *** [Makefile:5138: cmake_check_build_system] Error 127
I'm using MSYS on Windows and here are the corresponding details.
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/opt/bin:/c/Windows/System32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/mingw32/bin
$ which cmake
/mingw32/bin/cmake
Seems like it's looking for cmake in the wrong path.
Makefile
cmake_check_build_system:
$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
.PHONY : cmake_check_build_system # <== Line 5139
I'm not sure what's wrong. Please help me out.
Thanks.
Make sure that you launch MSYS2 using the mingw32.exe executable at the top level of your MSYS2 installation, and that you use that environment when you first run cmake. If you ran CMake in a different environment, remove all the files it created. The commands for running cmake and building the project should be something like this, assuming the developers have set it up in a reasonable way:
mkdir build
cd build
cmake .. -G"MSYS Makefiles"
make
I didn't try this myself because I am wary of running random code from the internet, but I found this note in the CMakefile indicating that the developers do not support MSYS2:
if (WIN32)
if (NOT MSVC)
message(FATAL_ERROR "Only MSVC is supported on this platform")
endif ()
...
So you will have to spend some effort on porting the Windows-specific code in this program to GCC if you really want to do this.

How to compile Box2D in Linux?

Compiling the Box2d Tesbed is supposed to be simple:
from iforce2d:
Download the Box2D source code archive from here. If you want to use the terminal all the way, you could also do this (if wget is not available, use yum to install it):
wget http://box2d.googlecode.com/files/Box2D_v2.1.2.zip
Use the following commands to unzip and build it.
[...]
unzip Box2D_v2.1.2.zip
cd Box2D_v2.1.2/Box2D/Build
cmake ..
make
( These instructions are pretty old, I did get my source with git clone https://github.com/erincatto/Box2D.git )
Running cmake .. from Box2D/Build in the freshly cloned directory causes multiple errors :
CMake Error at Testbed/CMakeLists.txt:84 (add_executable):
Cannot find source file:
Framework/imgui.h
Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
.hxx .in .txx
CMake Error: Cannot determine link language for target "glfw".
CMake Error: CMake can not determine linker language for target: glfw
Of course, make fails:
[ 42%] Building CXX object Box2D/CMakeFiles/Box2D.dir/Dynamics/b2Body.cpp.o
/home/cabri/Documents/Box2D/Box2D/Box2D/Dynamics/b2Body.cpp: In member function ‘void b2Body::DestroyFixture(b2Fixture*)’:
/home/cabri/Documents/Box2D/Box2D/Box2D/Dynamics/b2Body.cpp:216:17: error: ‘nullptr’ was not declared in this scope
if (fixture == nullptr)
^
Box2D/CMakeFiles/Box2D.dir/build.make:566: recipe for target 'Box2D/CMakeFiles/Box2D.dir/Dynamics/b2Body.cpp.o' failed
make[2]: *** [Box2D/CMakeFiles/Box2D.dir/Dynamics/b2Body.cpp.o] Error 1
CMakeFiles/Makefile2:85: recipe for target 'Box2D/CMakeFiles/Box2D.dir/all' failed
make[1]: *** [Box2D/CMakeFiles/Box2D.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
Multiple similar questions can be found on these sites, but none has an answer. I know I can install box2d with
sudo apt-get install libox2d but I'd like to have the testbed as well.
How can this be done ?
Short answer...
yes this can be built, rollback your git clone of Box2D until the build doesn't fail.
Long answer...
Seems you've encountered two separate problems:
Not finding the imgui.h file.
The introduction of nullptr to the Git source tree which requires C++11 or newer language acceptance from the compiler.
Regarding problem 1, there's been an issue filed about that back at the beginning of February 2017: issue 433. Regarding problem 2, there's also been an issue filed for this back in June 2016: issue 414.
While I did not see a resolution on GitHub for problem 1, problem 2 apparently is resolvable by applying pull request #412. You should also be able to resolve problem 2 by having your compiler accept C++11 (or newer).
As for resolving problem 1, you can roll back your git clone of Box2D until the Testbed can be built. If you rollback far enough, that should also resolve problem 2 (without needing to do anything else). Information on how to do the reversion can be found at the SO question of How to revert Git repository to a previous commit?.
Ubuntu 17.10 Testbed
The major annoyance is that you currently need premake5, which is yet in alpha and therefore not in Ubuntu:
cd
git clone https://github.com/premake/premake-core
cd premake-core
git checkout v5.0.0-alpha12
make -f Bootstrap.mak linux
cd
git clone https://github.com/erincatto/Box2D
cd Box2D
git checkout f655c603ba9d83f07fc566d38d2654ba35739102
cd Box2D
~/premake-core/bin/release/premake5 gmake
cd Build/gmake
make
# Must be run from there because of a ttf font is at that reative path. GDB told me that. :-)
cd ../../Testbed
../Build/gmake/bin/Debug/Testbed
This builts the .a static library under Build/gmake/bin/Debug.
https://github.com/erincatto/Box2D/issues/387#issuecomment-219168623 gives some insight on the chaotic history of the build system.
First CMake was used, but Erin though premake was better, then premake lost support and the project stuck to Visual Studio + Xcode config files, then the premake project came back from the dead and was reinstated. When will they switch to CMake, which is infinitely portable, and will be forever supported? :-)
Shared library
The steps are the exact same, but first clean up the old static binaries:
git clean -xdf :/
and then before running premake5, apply the following patch to Box2D:
diff --git a/Box2D/premake5.lua b/Box2D/premake5.lua
index b937866..f666651 100644
--- a/Box2D/premake5.lua
+++ b/Box2D/premake5.lua
## -23,7 +23,7 ## workspace "Box2D"
buildoptions { "-std=c++11" }
project "Box2D"
- kind "StaticLib"
+ kind "SharedLib"
language "C++"
files { "Box2D/**.h", "Box2D/**.cpp" }
includedirs { "." }
The testbed still runs as before, but if you move the shared library it stops working as expected.
TODO clean system-wide installation. Manually copying the .so and headers into appropriate paths should work... but not much fun.
CMake revived
So simple, so much better.
Box2D/Box2D/CMakeLists.txt:
cmake_minimum_required(VERSION 3.0)
set (CMAKE_CXX_STANDARD 11)
file(GLOB_RECURSE SOURCES RELATIVE ${CMAKE_SOURCE_DIR} "Box2D/*.cpp")
include_directories(${CMAKE_SOURCE_DIR})
add_library(Box2D SHARED ${SOURCES})
target_include_directories(Box2D PUBLIC ${CMAKE_SOURCE_DIR})
set(HELLO_SOURCES HelloWorld/HelloWorld.cpp)
add_executable(hello ${HELLO_SOURCES})
target_link_libraries(hello PRIVATE Box2D)
Then:
cd Box2D/Box2D
mkdir build
cd build
cmake ..
make
./hello
For now, I'll be tracking Box2D as a submodule and using this method for my projects I think, here is an example: https://github.com/cirosantilli/sdl-box2d
find compile static library
This might also be useful if you don't care about OS, and don't want to install premake:
cd Box2D/Box2D/Box2D
find . -iname '*.cpp' | xargs g++ -c -I../
ar rcs libBox2D.a *.o
g++ -I.. ../HelloWorld/HelloWorld.cpp libBox2D.a
./a.out
If you have the most recent commit from the Box2D repo checked out, you can restore the original CMake files by running this git command in the repository directory:
git checkout 05ee3c3c22af9ac1e5d88061d0b473f814c8210f^ \
Box2D/Box2D/Box2DConfig.cmake.in \
Box2D/Box2D/CMakeLists.txt \
Box2D/Box2D/UseBox2D.cmake \
Box2D/CMakeLists.txt \
Box2D/HelloWorld/CMakeLists.txt \
Box2D/Testbed/CMakeLists.txt \
Box2D/glew/CMakeLists.txt \
Box2D/glfw/CMakeLists.txt
Since Box2D has started using C++11 features since this commit, so you will need to add this line to Box2D/CMakeLists.txt:
set (CMAKE_CXX_STANDARD 11)
If you only want the core library built, you're done; just run the following commands:
mkdir build
cd build
cmake -D BOX2D_BUILD_EXAMPLES=OFF ../Box2D
Testbed
If you want the Testbed, things get a bit more involved. The CMakeLists for Box2D's copy of GLFW seems to be completely broken. Open Box2D/CMakeLists.txt, and find these two lines:
add_subdirectory(glew)
add_subdirectory(glfw)
Replace them with the following. This will cause the build to use your system versions of the libraries, so you will need to have them installed:
find_package(GLEW REQUIRED)
if (GLEW_FOUND)
include_directories(${GLEW_INCLUDE_DIRS})
link_libraries(${GLEW_LIBRARIES})
endif()
find_package(PkgConfig REQUIRED)
pkg_search_module(GLFW REQUIRED glfw3)
include_directories(${GLFW_INCLUDE_DIRS})
Open Box2D/Testbed/CMakeLists.txt. At the top of the file, under set(Testbed_Framework_SRCS, remove the 4 lines referring to imgui and RenderGL3. Add the following lines in that section:
../imgui/imgui.h
../imgui/imgui.cpp
../imgui/imgui_draw.cpp
../imgui/imgui_impl_glfw_gl3.cpp
Scroll to the bottom and replace the glew and glfw lines with:
${GLEW_LIBRARIES}
${GLFW_STATIC_LIBRARIES}
Finally replace
file(COPY ../Build/Data DESTINATION ..)
with
file(COPY ./Data DESTINATION .)
At this point, the full library and testbed should be buildable:
mkdir build
cd build
cmake ../Box2D

Qt creator with several projects: avoid each project "reviewing"

I currently have a .pro of subprojects template. This .pro file references a lot of other .pro files, each one being a project itself. It compiles, builds and runs.
The problem is that each time I want to run my program, Qt Creator (or perhaps it's make itselfs) checks all projects' status or something like that. For each project it shows the following:
cd A_PROJECT_DIRECTORY && ( test -e Makefile ||
/opt/Qt5.5.1/5.5/gcc_64/bin/qmake A_PROJECT_DIRECTORY/PROJECT_FILE.pro
-spec linux-g++ CONFIG+=debug -o Makefile ) && /usr/bin/make -f Makefile
make[1]: Entering directory `A_PROJECT_DIRECTORY'
make[1]: Nothing to be done for `first'.
make[1]: Leaving directory `A_PROJECT_DIRECTORY'
It takes very little time for each one of those operations but there are so many projects that at the end it has a sensible impact in the edit + build + test workflow.
So, the question is: is there any way to skip those make "tests" or whatever are they and launch immediatly the executable after it has been built? Or some other way to speed up this process?
All the above is in Linux environment.
Thank you very much.

Add c++ support in a autotools project?

I am now writing an app that need using c++ in my c code.My problem is i can't compile through the c++ code.
i have two source folders,cpp (contains only a c source file ) and src (contains only a c++ source file ).
my configure.in is just like this,very simple
AC_PREREQ([2.68])
AC_INIT([tste], [1.0], [ee#b.com])
AC_PROG_CXX
AC_PROG_CC
AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE()
AC_CONFIG_FILES([Makefile cpp/Makefile src/Makefile] )
AC_OUTPUT
./Makefile.am:
SUBDIRS= src cpp
./cpp/Makefile.am:
bin_PROGRAMS=main
main_SOURCES=main.c
./src/Makefile.am:
bin_PROGRAMS=test
test_SOURCES=testcpp.cpp
When i using make to compile my project , the error occurs:
Making all in src
make[1]: Entering directory `/home/hujin/Desktop/test/src'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/hujin/Desktop/test/src'
Making all in cpp
make[1]: Entering directory `/home/hujin/Desktop/test/cpp'
make[1]: *** No rule to make target `main.o', needed by `main'. Stop.
make[1]: Leaving directory `/home/hujin/Desktop/test/cpp'
make: *** [all-recursive] Error 1
If I was in your skin, I wouldn't have split the project in submakefiles since it all goes to a single target ("tste").
You better put all of your source files in the root Makefile.am (you can generate more than one output from it):
# ./Makefile.am:
bin_PROGRAMS=main test
main_SOURCES=cpp/main.c
test_SOURCES=src/testcpp.cpp
Change your configure.acto something like:
# configure.ac
AC_PREREQ([2.68])
AC_INIT([tste], [1.0], [ee#b.com])
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([src/testcpp.cpp])
AC_PROG_CXX
AC_PROG_CC
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
Then run:
aclocal && autoconf && automake
./configure
make
Here are some good links:
A tutorial for porting to autoconf & automake
Using Automake and Autoconf with C++
autotut: Using GNU auto{conf,make,header}