Not able to enable C++11 using autoconf - c++11

I am trying to enable c++11 for gcc 4.6; I am using autconf and I added following to my configure.ac file
AC_PREREQ(2.61)
AC_INIT(SOLARCORE, 1.0.0, BUG-REPORT-ADDRESS)
AM_INIT_AUTOMAKE([1.10 no-define foreign])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR([src/threading/node.h])
AC_CONFIG_HEADER([config.h])
AC_OUTPUT([Makefile src/threading/Makefile])
# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
#AC_LANG_PUSH([C++])
AC_LANG([C++])
AC_GNU_SOURCE
AX_CXX_COMPILE_STDCXX_11(,[mandatory])
CXXFLAGS='-Wall -std=gnu++0x'
AC_TYPE_SIZE_T
AC_OUTPUT
I am getting following error
./configure: line 4949: syntax error near unexpected token ,mandatory'
./configure: line 4949:AX_CXX_COMPILE_STDCXX_11(,mandatory)'
I also tried AX_CXX_COMPILE_STDCXX_11([ext],[mandatory])
I want to enable C++11 so that I can use it. I tried without AX_CXX_COMPILE_STDCXX_11 and with just CXXFLAGS in my Makefile but it is not working. So please help. THanks.
Found the answer: Recent version of AX_CXX_COMPILE_STDCXX_11 doesnt need a argument.

Are you sure you have the latest version of the macro? Judging from the history available from the autoconf archive, the original version of the macro only expected one argument, not two. If you've not got the second or third revisions of the test, that might account for your trouble.

Related

gdb compile issue yyin and lexer_init

I am trying to compile gdb 9.2 in Ubuntu 18.04, The following errors are printed.
make[2]: Entering directory '/home/ata/gdb-9.2/build/gdb'
CXX ada-exp.o
ada-exp.y: In function ‘int ada_parse(parser_state*)’:
ada-exp.y:736:15: error: ‘yyin’ was not declared in this scope
ada-exp.y:736:15: note: suggested alternative: ‘yylen’
ada-exp.y:736:3: error: ‘lexer_init’ was not declared in this scope
ada-exp.y:736:3: note: suggested alternative: ‘pex_init’
In file included from ada-exp.y:56:0:
gdb 10.1 compiled successfully before this.
I searched online but could not come up with a reason or solution.
What might be the issue ?
Edit1: I have gcc version 7.5.0
I also faced this issue and this is how I fixed it:
ada-exp.y includes file ada-lex.c which contains the definition for function lexer_init.
But if you don't have flex installed initially, then it may generate an empty ada-lex.c (from ada-lex.l). And even if you do make clean, it will not clean the generated ada-lex.c, i.e., it will remain empty upon next compile command as well.
So to fix this error, you can delete all such intermediate .c files (in your case, building with fresh .tar.gz) and do the make again.

"Makefile:26: *** missing separator" - Makefile condition

I am having some trouble to compile GCC. When I try to compile it, this error appears:
Makefile:26: *** missing separator. Stop.
The line 26 refers to the first line of this condition:
#if gcc
ifeq (,$(.VARIABLES)) # The variable .VARIABLES, new with 3.80, is never empty.
$(error GNU make version 3.80 or newer is required.)
endif
#endif gcc
I already tried to insert a TAB between the keywords but it didn't work. The only thing I tried and seems to work is to change the condition to:
ifeq ($(gcc),)
ifeq (,$(.VARIABLES)) # The variable .VARIABLES, new with 3.80, is never empty.
$(error GNU make version 3.80 or newer is required.)
endif
endif
Informations:
Make log: http://pastebin.com/t5eNYJd5
Make log (after changing the condition): http://pastebin.com/HHjQKdDx
My make version is: 4.0.
GCC version I am trying to build: 5.2.0
I am using fedora 22.
I've got a workaround. The problem is that the Makefile contains hundreds of '#if', therefore, I would like to know why is it using '#if' if they do not work ?
Thanks in advance.
I stumbled upon this same problem. This question is a little old and it looks like you found a workaround, but I'll document my findings here as well for the People of the Future.
Background
GCC currently requires you to perform an out-of-source build. Based on the commands shown, some of the documentation and online QA implies that this is valid:
svn checkout svn://gcc.gnu.org/svn/gcc/trunk gcc;
gcc/configure <configure options>;
make -j 8 && make install;
This nests the source directory in the build directory, but I would expect that to count as "out-of-source." Running without -j 8 still produced the problem. I did this on a RHEL6 system, using GNU make 4.2. I was attempting to build GCC 8.0.0.
Solution
I found that making the source and build directories adjacent rather than creating builddir/sourcedir resolved the problem.
Additional info
Here's are relevant snippets from the GCC build instructions:
We use srcdir to refer to the toplevel source directory for GCC; we use objdir to refer to the toplevel build/object directory.
...
If you obtained the sources via SVN, srcdir must refer to the top gcc directory, the one where the MAINTAINERS file can be found, and not its gcc subdirectory, otherwise the build will fail.
...
First, we highly recommend that GCC be built into a separate directory from the sources which does not reside within the source tree. This is how we generally build GCC; building where srcdir == objdir should still work, but doesn’t get extensive testing; building where objdir is a subdirectory of srcdir is unsupported.
Depending on your definition of "source tree", these instructions may or may not proscribe building the way I first attempted. They should probably be updated to clarify this case.
As to the specific reason that Makefile won't run, that snippet is not valid make syntax - if is not a make keyword, and referenced variables must be enclosed like so: $(varname). # simply prevents the command from being echoed.
Rather, this is supposed to be multiline interpolated bash. This StackOverflow answer shows this being done in a Makefile, but it's done as part of a recipe. I see no evidence that this is valid as a standalone entity.
In the correctly-generated Makefile, the section you posted is absent, and all interpolated bash appears in a recipe.

How do I change GCC's default search directory for crti.o?

I'd like to specify GCC's search directory for the startfile and
endfile: crt1.o, crti.o and crtn.o. Passing -B on the command line to
the GCC driver works, but is inconvenient. How do I modify the specs
file (lib/gcc/x86_64-unknown-linux-gnu/4.9.2/specs) to specify the search path for startfile?
I tried adding the -B option to the startfile spec and got the error:
ld: unrecognized option '-B/gsc/btl/linuxbrew/lib'
I then tried adding the -B option to the cc1 spec and got the error:
cc1: error: command line option '-B/gsc/btl/linuxbrew/lib' is valid
for the driver but not for C
If it's not possible to do this via the specs file, is there an environment variable or a configure option to GCC that accomplishes the same goal?
I've installed a recent version of glibc in my home directory. Everything's working great. I've modified the specs file to link against the new version of glibc, but it's still linking against the old system version in /usr of startfile and endfile.
Here's a the unanswered question on the gcc-help mailing list. Here's a related Linuxbrew bug, gfortran is broken with stand alone Linuxbrew, and a proposed fix, gcc, binutils: link to Cellar instead of system libs.
Thanks,
Shaun
You can use an absolute path in the *startfile: and *endfile: sections in the specs file, instead of the default relative paths. This will override GCC's choice of the default location.
As per https://wiki.debian.org/Multiarch/LibraryPathOverview, gcc will look for startup files such as crt1.o in $(sysroot)/lib, so you can specify the --sysroot option when running gcc, or compile gcc with --with-sysroot.

Disable -Werror in 'configure' file

While making a project with Makefile, I get this error:
error: implicit declaration of function ‘fatal’ [-Werror=implicit-function-declaration]
cc1: all warnings being treated as errors
The ./configure --help shows:
Optional Features:
--disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--disable-dependency-tracking speeds up one-time build
--enable-dependency-tracking do not reject slow dependency extractors
--disable-gtktest do not try to compile and run a test GTK+ program
--enable-debug Turn on debugging
How can I tell configure not to include -Werror?
Werror is a GCC argument, and you cannot remove it directly via ./configure. Otherwise, an option like --disable-error would show up in the help text. However, it's possible.
Set an environment variable:
export CFLAGS="-Wno-error"
That's for C compilers. If the project uses C++, do:
export CXXFLAGS="-Wno-error"
In the very rare case the project does not honor this variables, your last resort is to edit the configure.ac file and search for -Werror and remove it from the string it occurs in (be careful though).
It seems like the feature has been in autotools for many years:
./configure --disable-werror
Unfortunately, I wasn't able to get the following specific case to work:
./configure --enable-wno-error=unused-value
Maybe it could work if one escaped the '=' symbol, assuming it's possible. Like skim says, one can still use CFLAGS or CXXFLAGS.
I had to use --disable-Werror (with an uppercase W) on my module. While sudoman's answer above suggests to use --disable-werror (with a lowercase w).
It may look like a typo, but it is actually dependent on your particular configure setup, especially if configure is generated by autoconf. What needs to be passed to the configure script to disable Werror depends on how the build system was setup.
If your project uses the AX_COMPILER_FLAGS option from the autoconf-archive project, then by default -Werror is enabled.
In another module you may find something like this:
+AC_ARG_ENABLE([werror],
+ AC_HELP_STRING([--disable-werror],
+ [do not build with -Werror]),
And thus you would need to use --disable-werror.
This works for me, compiling curlpp on Lubuntu 16.10:
./configure --disable-ewarning
I ran into this problem, and it turned out that GCC was not installed on my freshly-started EC2 instance running Ubuntu 20.04 (Focal Fossa).
Simply running sudo apt install gcc fixed this issue for me.

Compiling Ruby 1.9.1-p129 on HPUX

I am trying to compile Ruby on HPUX but get the following:
cc: "transcode.c", line 1489: error 1588: "SIZE_MAX" undefined.
cc: "transcode.c", line 1489: error 1563: Expression in if must be scalar.
I had a problem with SIZE_MAX being undefined using aCC compiler without the C99 flag. Using this environment option in the ./configure got me past it, but I'm hitting other problems later on (miniruby compiles and links, but throws a Bus Error when the make process continues :-/). Does this help you build?
CC="cc -AC99" CPPFLAGS="-D_HPUX_SOURCE" ./configure
What HPUX and compiler version?
If I remember correctly SIZE_MAX is only available if you use c99 compiler and include stdint.h (not limits.h).

Resources