I would like to check the presence of the google sparsehash package in my C++ program with the Autotools.
Here is a minimal configure.ac:
AC_PREREQ([2.69])
AC_INIT([myprog], [1.0], [adress#email.com])
AC_CONFIG_SRCDIR([main.cpp])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([foreign -Wall -Werror])
AC_PROG_CXX
AC_PROG_CC
AC_CHECK_HEADERS([google/sparse_hash_map])
AC_CONFIG_FILES(Makefile)
AC_OUTPUT
I run autoreconf -vfi, then ./configure, and I get:
checking google/sparse_hash_map usability... no
checking google/sparse_hash_map presence... no
checking for google/sparse_hash_map... no
However, I can check the presence of /usr/include/google/sparse_hash_map, a C++ file, which is a thin wrapper around /usr/include/google/sparsehash/sparsehashtable.h. Moreover, the tiny code:
#include <google/sparse_hash_map>
int main() {return 1;}
compiles and executes fine using g++ test.cpp.
Any suggestion for a newbie?
The AC_CHECK_HEADER macro is using the C compiler by default. You can change the current language using: AC_LANG([C++]) or: AC_LANG_PUSH([C++]) / AC_LANG_POP - as described in the (single-page) manual. e.g.,
...
AC_LANG([C++])
AC_CHECK_HEADERS([google/sparse_hash_map])
# still in C++ 'mode'
or:
...
AC_LANG_PUSH([C++])
AC_CHECK_HEADERS([google/sparse_hash_map])
AC_LANG_POP([C++])
# restored previous language 'mode'
Related
I am following the Udemy Haskell course, which at one point I'm shown to download Haskell using the Stack option. I've configured my $PATH and ran stack setup when I run into an issue.
configure: WARNING: configure can't recognize your CPP program, you may need to set --with-hs-cpp-flags=FLAGS explicitly
configure: error: in `/Users/Dylan/.stack/programs/x86_64-osx/ghc-8.0.2.temp/ghc-8.0.2':
configure: error: C compiler cannot create executables
I have looked into .stack/programs/x86_64-osx/ghc-8.0.2.temp/ghc-8.0.2/config.log and found this...
configure:2234: checking for path to top of build tree
configure:2255: result: /Users/Dylan/.stack/programs/x86_64-osx/ghc-8.0.2.temp/$
configure:2981: checking for perl
configure:2999: found /usr/bin/perl
configure:3011: result: /usr/bin/perl
configure:3070: checking for a BSD-compatible install
configure:3138: result: /usr/bin/install -c
configure:3152: checking whether ln -s works
configure:3156: result: yes
configure:3168: checking for gsed
configure:3199: result: sed
configure:3211: checking XCode version
configure:3222: result: 8.3.3
configure:3226: XCode version component 1: 8
configure:3228: XCode version component 2: 3
configure:3263: checking for gcc
configure:3281: found /usr/bin/gcc
configure:3293: result: /usr/bin/gcc
configure:3573: WARNING: configure can't recognize your CPP program, you may ne$
configure:3623: checking for llc-3.7
configure:3656: result: no
configure:3739: checking for llc
configure:3772: result: no
configure:3872: checking for opt-3.7
configure:3905: result: no
configure:3988: checking for opt
configure:4021: result: no
configure:4120: checking for ld
configure:4138: found /usr/bin/ld
configure:4150: result: /usr/bin/ld
configure:4388: checking for gcc
configure:4415: result: /usr/bin/gcc
configure:4644: checking for C compiler version
configure:4653: /usr/bin/gcc --version >&5
I am able to read configure: WARNING: configure can't recognize your CPP program, you may need to set --with-hs-cpp-flags=FLAGS explicitly, but I am not sure how or where to do that. I've found my settings.in file...
[("GCC extra via C opts", "#GccExtraViaCOpts#"),
("C compiler command", "#SettingsCCompilerCommand#"),
("C compiler flags", "#SettingsCCompilerFlags#"),
("C compiler link flags", "#SettingsCCompilerLinkFlags#"),
("C compiler supports -no-pie", "#SettingsCCompilerSupportsNoPie#"),
("Haskell CPP command","#SettingsHaskellCPPCommand#"),
("Haskell CPP flags","#SettingsHaskellCPPFlags#"),
("ld command", "#SettingsLdCommand#"),
("ld flags", "#SettingsLdFlags#"),
("ld supports compact unwind", "#LdHasNoCompactUnwind#"),
("ld supports build-id", "#LdHasBuildId#"),
("ld supports filelist", "#LdHasFilelist#"),
("ld is GNU ld", "#LdIsGNULd#"),
("ar command", "#SettingsArCommand#"),
("ar flags", "#ArArgs#"),
("ar supports at file", "#ArSupportsAtFile#"),
("touch command", "#SettingsTouchCommand#"),
("dllwrap command", "#SettingsDllWrapCommand#"),
("windres command", "#SettingsWindresCommand#"),
("libtool command", "#SettingsLibtoolCommand#"),
("perl command", "#SettingsPerlCommand#"),
("cross compiling", "#CrossCompiling#"),
("target os", "#HaskellTargetOs#"),
("target arch", "#HaskellTargetArch#"),
("target word size", "#WordSize#"),
("target has GNU nonexec stack", "#HaskellHaveGnuNonexecStack#"),
("target has .ident directive", "#HaskellHaveIdentDirective#"),
("target has subsections via symbols", "#HaskellHaveSubsectionsViaSymbols#"),
("Unregisterised", "#Unregisterised#"),
("LLVM llc command", "#SettingsLlcCommand#"),
("LLVM opt command", "#SettingsOptCommand#")
]
But again, I do not know what to do with it. Sorry, if my question is basic, but I have not done something similar to this before, and what I have found online has been difficult to interpret how it is applicable to my situation.
Any help would be greatly appreciated. 😀
#n.m Commented a link leading me to a question's answer that recommended I check my xCode listed version of the developer command line tools. Turns out my version was fine, but I did later find this line in .stack/programs/x86_64-osx/ghc-8.0.2.temp/ghc-8.0.2/config.log that led me to the solution of my problem.
Agreeing to the Xcode/iOS license requires admin privileges, please run “sudo xcodebuild -license” and then retry this command
sudo xcodebuild -license allowed me to then run stack install successfully.
I am building LLVM with cmake and Ninja build generator as following:
cmake path/to/llvm/ -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=1 -DLLVM_ENABLE_CXX1Y=1 -DLLVM_ENABLE_RTTI=1 -DLLVM_TARGETS_TO_BUILD="X86" -G Ninja
Now I a am trying to use the -debug-only=mytype option of opt to print some debug information about my own passes: using the following in my passes code:
define DEBUG_TYPE "mytype"
DEBUG(errs() << "My debug message\n");
Running opt as following doesn't generate any output messages:
opt < a.bc > /dev/null -mypass -debug-only=mytype
According to LLVM documentation:
For performance reasons, -debug-only is not available in optimized build (--enable-optimized) of LLVM.
I suspect this to be the root of my issue, but I can't find how to turn on/off this option when using cmake to build llvm.
It is controlled by enabling assertions.
cmake -DLLVM_ENABLE_ASSERTIONS=ON is enough to turn it on. If you don't see your debug output, then your code is not executed.
I am adding here a complement answer to my question. As #Joky said, cmake -DLLVM_ENABLE_ASSERTIONS=ON must be specified when compiling llvm. Also, because my passes are built outside the llvm source tree, assertions must also be enabled when building the passes.
I tried to build GDB 7.51 in mingw for cross platform debugging, and I found GDB has TUI as frontend. Anyway, I configure GDB with --enable-tui, and then make always stop with error message:
configure: error: no enhanced curses library found; disable TUI
I checked this problem by google, and then I downloaded ncurses source from GNU
ncurses 5.9
build and install it in my c:/mingw/msys/1.0/local/
run the configure of GDB with following script statements
export PATH=$PREFIX/gccbinutils/bin/:/usr/local/bin:/usr/bin:/bin:/mingw/bin
export C_INCLUDE_PATH=/usr/local/include:/usr/local/include/ncursest:/usr/include:/c/mingw/include
export CPLUS_INCLUDE_PATH=/usr/local/include:/usr/local/include/ncursest:/usr/include:/c/mingw/include
export LIBRARY_PATH=/usr/local/lib:/usr/lib:/c/mingw/lib
export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/c/mingw/lib
export LDFLAGS="-L/usr/local/lib -L/usr/lib -L/c/mingw/lib"
export LIBS="-lncursest"
$BUILD_MIPSGCCDIR/gdb/configure --prefix=$PREFIX/$pkg --target=$TARGET \
--enable-tui \
--enable-curses \
--enable-sim > $BUILDPATH/$TARGET$pkg.conf1.$argn.log 2>&1
but it did not work. Make stopped with following messages
checking for zlib.h... yes
checking for library containing dlgetmodinfo... no
checking for iconv... yes
checking for iconv declaration... install-shextern size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
checking for library containing waddstr... no
configure: error: no enhanced curses library found; disable TUI
make[1]: *** [configure-gdb] Error 1
make[1]: Leaving directory `/d/tools/buildmipsgcc/build_gdb'
make: *** [all] Error 2
I have searched the waddstr , and sure it was exist in my c:/mingw/msys/1.0/local/lib/libncursest.a.
OK, lets try to fool Autotools by providing hand-written libncurses.la:
# libncurses.la - a libtool library file
# Generated by ltmain.sh (GNU libtool) 2.2.7a
#
# Please DO NOT delete this file!
# It is necessary for linking the library.
# The name that we can dlopen(3).
dlname=''
# Names of this library.
library_names=''
# The name of the static archive.
old_library='libncursest.a'
# Linker flags that can not go in dependency_libs.
inherited_linker_flags=''
# Libraries that this one depends upon.
dependency_libs=''
# Names of additional weak libraries provided by this library
weak_library_names=''
# Version information for libncurses.
current=5
age=0
revision=9
# Is this an already installed library?
installed=yes
# Should we warn about portability when linking against -modules?
shouldnotlink=no
# Files to dlopen/dlpreopen
dlopen=''
dlpreopen=''
# Directory that this library needs to be installed in:
libdir='c:/mingw/msys/1.0/local/lib'
Check paths and names that I've supplied, if they are different - change them. Report if it still does not work, and I'll try to expand it further until we finally fix it.
I'm trying to port buildsystem of my project to GNU autotools. The code need to be compiled with -std=c++11 or -std=c++0x flag. I want my configure script to check if compiler supports C++11 or not. I tried adding AX_CHECK_COMPILE_FLAG([-std=c++0x], [CXXFLAGS="$CXXFLAGS -std=c++0x"]) to configure.ac file but configure fails with this error:
...
./configure: line 2732: syntax error near unexpected token `-std=c++0x,'
./configure: line 2732: `AX_CHECK_COMPILE_FLAG(-std=c++0x, CXXFLAGS="$CXXFLAGS -std=c++0x")'
Hopefully there will be more comprehensive support for C++11 in future autoconf releases. In the mean time, I use a C++11 source test from ax_cxx_compile_stdcxx_11.m4 in the GNU autoconf archive:
AC_PROG_CXX
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_SOURCE(
[[template <typename T>
struct check
{
static_assert(sizeof(int) <= sizeof(T), "not big enough");
};
typedef check<check<bool>> right_angle_brackets;
int a;
decltype(a) b;
typedef check<int> check_type;
check_type c;
check_type&& cr = static_cast<check_type&&>(c);]])],,
AC_MSG_FAILURE(['$CXX $CXXFLAGS' does not accept ISO C++11]))
The error you're getting seems to come from AX_CHECK_COMPILE_FLAG not being expanded in your configure script. You can verify whether it is expanded by grepping AX_CHECK_COMPILE_FLAG in configure. If the grep finds it there, then it is not expanded.
You can also check it by looking into file aclocal.m4, where aclocal should copy it's definition.
The definition of this macro is not included in basic autoconf package, but in the autoconf archives. So you're probably missing this package. (Exact name of the package may differ between distributions, it is sys-devel/autoconf-archive in Gentoo and it seems to be autoconf-archive in Debian and Ubuntu).
I am using GNU autotools for my project. The configure.ac script has the following snippet.
AC_ARG_WITH(chkhere,
AC_HELP_STRING([--without-chkhere], [do not compile]),
[ac_cv_chkhere=$withval], [ac_cv_chkhere=yes])
# Check if chkhere is available
if test "x$ac_cv_chkhere" = "xyes"
then
AC_DEFINE(HAVE_CHECKED)
echo "chkhere: enabled"
else
echo "chkhere: DISABLED"
fi
And I am checking for the variable HAVE_CHECKED in the C++ code. This works for --without-chkhere option.
When I am giving ./configure --with-chkhere, it shows the message "chkhere: enabled" as required, but HAVE_CHECKED turns up undefined inside the C++ code.
Please suggest where I am going wrong, or if I can test this differently? Thanks.
P.S.: I am following this sequence of commands: automake; libtoolize; aclocal -I m4; autoconf;
If you didn't call autoheader then config.h.in may be out of date and may not mention HAVE_CHECKED. I suggest you just ditch your sequence of commands and use autoreconf instead, it will run what you need.
Are you making sure to #include <config.h>? That's where HAVE_CHECKED will be defined.
EDIT
My version of autoheader complains and fails when you don't use the full form of AC_DEFINE:
AC_DEFINE([HAVE_CHECKED], [1], [some description])
So your config.h.in wouldn't be getting updated even if you did call autoheader.