Building gold linker with MinGW on Windows, FLEX/bison 'YYSTYPE' was not declared in this scope - c++

I'm trying to build the gold linker included with GNU binutils using mingw. The steps I have taken-
Install mingw with all packages using the installer.
Install the windows version of FLEX to the default location using the windows installer.
Run ./configure in the gold linker directory from the mingw shell which seems to work fine
Run make, this is where I'm getting some errors.
I've included the complete output of ./configure and make in a pastebin here:
http://pastebin.com/1XLkZVVm
But the important part is this:
make[2]: Entering directory `c:/binutils-2.23.1/binutils-2.23.1/gold'
g++ -DHAVE_CONFIG_H -I. -I. -I./../include -I./../elfcpp -DLOCALEDIR="\"/usr/lo
cal/share/locale\"" -DBINDIR="\"/usr/local/bin\"" -DTOOLBINDIR="\"/usr/local//bi
n\"" -DTOOLLIBDIR="\"/usr/local//lib\"" -W -Wall -Wno-format -Werror -D_LAR
GEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -frandom-seed=expression.o -MT expression.
o -MD -MP -MF .deps/expression.Tpo -c -o expression.o expression.cc
In file included from expression.cc:33:0:
script-c.h:221:7: エラー: 'yylex' initialized and declared 'extern' [-Werror]
script-c.h:221:7: エラー: 'YYSTYPE' was not declared in this scope
script-c.h:221:15: エラー: expected primary-expression before ',' token
script-c.h:221:17: エラー: expected primary-expression before 'void'
script-c.h:221:30: エラー: expression list treated as compound expression in ini
tializer [-fpermissive]
cc1plus.exe: all warnings being treated as errors
make[2]: *** [expression.o] Error 1
make[2]: Leaving directory `c:/binutils-2.23.1/binutils-2.23.1/gold'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `c:/binutils-2.23.1/binutils-2.23.1/gold'
make: *** [all] Error 2
I've looked in the script-c.h file and it has this function:
/* Called by the bison parser skeleton to return the next token. */
extern int
yylex(YYSTYPE*, void* closure);
However YYSTYPE is not defined anywhere that I can find.
I'm new to using mingw and msys so I may have missed some steps somewhere. Any help getting this to build would be really appreciated.

As this question had lain unanswered for some months, I looked into the problem.
I downloaded binutils-2.25 (latest at this date) and tried to follow your actions.
I discovered that if you only build gold without the rest of binutils it does not build. If you perform a ./configure and make at the top level it builds the gold fine. If you then cd gold and do the ./configure and make (albeit unnecessarily) then it works fine also.
I did find that when it failed on gold alone it got further than your build did.
My attention was also drawn to your phrase FLEX to the default location. The instructions with FLEX make it clear that you should not rely on the default location (which may be /Program Files/ or similar) but must use path that does not contain any spaces. If you had not noticed this, then that is your fault.
As the latest builds, you can get gold working by ensuring you have installed flex (and bison) properly in non-space paths, then downloading 2.25 and building the whole of binutils rather than gold alone.
I hope this analysis is useful for someone who comes later and finds similar issues.

Related

Cannot convert ‘bool’ to ‘gzFile {aka gzFile_s*}’

I am new to Linux environments, and trying to install a bioinformatics package (vcftools - https://vcftools.github.io/examples.html). For some reason I can compile without a problem in a Cygwin environment, other colleagues have installed the package without a glitch, but i get an error (per below) if I try to compile in an Ubuntu environment in a VirtualBox on the same computer. I get the following error. Does anyone have a suggestion on how to resolve this error?
$make install
output
Installing VCF tools
make[1]: Entering directory '/home/wde/selt/selectionTools/vcftools_0.1.11/cpp'
g++ -c -O2 -D_FILE_OFFSET_BITS=64 vcftools.cpp -o vcftools.o
g++ -MM -O2 -D_FILE_OFFSET_BITS=64 vcftools.cpp > vcftools.d
g++ -c -O2 -D_FILE_OFFSET_BITS=64 bcf_file.cpp -o bcf_file.o
g++ -MM -O2 -D_FILE_OFFSET_BITS=64 bcf_file.cpp > bcf_file.d
g++ -c -O2 -D_FILE_OFFSET_BITS=64 vcf_file.cpp -o vcf_file.o
vcf_file.cpp: In constructor ‘vcf_file::vcf_file()’:
**vcf_file.cpp:25:13: **error: cannot convert ‘bool’** to ‘gzFile {aka gzFile_s*}’ in assignment**
gzvcf_in = false;
^~~~~
Makefile:53: recipe for target 'vcf_file.o' failed
make[1]: *** [vcf_file.o] Error 1
make[1]: Leaving directory '/home/wde/selt/selectionTools/vcftools_0.1.11/cpp'
/bin/sh: 2: cd: can't cd to perl
Makefile:24: recipe for target 'install' failed
make: *** [install] Error 2
error with make
Basically what the makefile does is automating the calls to the compiler.
Thus, the output from the makefile is similar to usual compile errors you get, compiling a source file from within the command line.
The important line from the error log above is:
vcf_file.cpp: In constructor ‘vcf_file::vcf_file()’:
**vcf_file.cpp:25:13: **error: cannot convert ‘bool’** to ‘gzFile {aka gzFile_s*}’ in assignment**
gzvcf_in = false;
gzvcf_in is of type pointer to gzFile_s. Assigning a bool variable to a pointer type won't compile.
Thus, the error message. Replace, inside the vcf_file.cpp, false with the pointer literal std::nullptr or the macro NULL and re-run the makefile.
Btw. I checked the vcf_file.cpp file in the github repo from vcf. They do not contain the line leading to the above error. May you have an outdated / modified version, introducing the compiler error.

How to properly configure Clang?

I've just compiled latest reps of LLVM, Clang and libc++. Now however I have no idea how to configure the environment to use them. I've added in $PATH the one to compiled binaries and have set the
$D_LIBRARY_PATH=$(llvm-config --libdir)
but anyway when I test run 'clang' with example file it uses some '/usr/bin/ld' linker which I have no idea what is it (as I've uninstalled 'g++' because thought it was the problem (before 'clang' used some linker from it) and I don't have any other C++ compilers).
So now how do I point out the right 'llvm-ld', libc++ include and library paths? I don't want to pass some complex arguments every-time. Perhaps I should set some environment variables.
I'm also using KDevelop with the same effect.
Don't judge me if this sounds stupid but it's my first time with Linux (have always used Windows before). I'm using latest 'OpenSUSE' dist.
Update - here is the output window of CodeLite using clang compiler:
/bin/sh -c 'make -j 2 -e -f Makefile'
----------Building project:[ ClangTest - Debug ]---------- make[1]: Entering directory
'/run/media/bs_ld/8688602a-296d-40e1-bd37-c90e69f45769/Workspace/CL_C++_WP/ClangTest'
clang++ -c
"/run/media/bs_ld/8688602a-296d-40e1-bd37-c90e69f45769/Workspace/CL_C++_WP/ClangTest/main.cpp"
-stdlib=libc++ -o ./Debug/main.cpp.o -I. -I/run/media/bs_ld/8688602a-296d-40e1-bd37-c90e69f45769/Build/include/c++/v1/
clang++ -o ./Debug/ClangTest #"ClangTest.txt" -L.
-L/run/media/bs_ld/8688602a-296d-40e1-bd37-c90e69f45769/Build/lib/ /usr/bin/ld: cannot find crtbegin.o: No such file or directory
/usr/bin/ld: cannot find -lstdc++ /usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find -lgcc clang-3.7: error: linker command failed
with exit code 1 (use -v to see invocation) ClangTest.mk:76: recipe
for target 'Debug/ClangTest' failed make[1]: * [Debug/ClangTest]
Error 1 make[1]: Leaving directory
'/run/media/bs_ld/8688602a-296d-40e1-bd37-c90e69f45769/Workspace/CL_C++_WP/ClangTest'
Makefile:4: recipe for target 'All' failed make: * [All] Error 2 0
errors, 0 warnings
You should be able to run make install with perhaps an optional DESTDIR=/...... so that it doesn't clobber your system files.
Since you're on OpenSUSE, you might as well use your distribution's build services, and install the SVN version of LLVM-Clang from here. You should be able to find libc++ and LLVM itself as well.
Otherwise, make install DESTDIR=/opt/llvm should work, and then you can add /opt/llvm/bin/ to PATH and use libc++ by adding this compile and link option: -stdlib=libc++. You'll need something like /opt/llvm/lib in LD_LIBRARY_PATH as well to find the libc++ so.
This should work pretty much out of the box, but I have only ever used my distribution's packages, not a self-built Clang to do this.
Note that Clang still uses your system linker, ld, and this is fine. Currently, LLVM does not yet provide a fully functional alternative to this program, but they are working on it.
EDIT: It seems you uninstalled too much: Clang also uses the GCC crtbegin and crtend object files. So just install GCC again along with glibc and its dev package.

make: *** [src/Class.o] Error 1 eclipse

ok so i installed CDT for C++ development on my machine. I tried to make it work and followed these instructions to set everything up. By mistake i have gone into the Project>Properties>C++ Build>Enviorement and hit restore defaults by mistake. I dont know if that changed anything but i get the following error when i run my class.
I tried to switch the slashes in the given path "C:\Users\Nathan\workspace\Project\Debug" to forward slashes but that did nothing. I still get the same error. Any hints on what im doing wrong?
19:12:58 **** Incremental Build of configuration Debug for project Project ****
make all
Building file: ../src/Project.cpp
Invoking: Cross G++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/Project.d" -MT"src/Project.d" -o "src/Project.o" "../src/Project.cpp"
cygwin warning:
MS-DOS style path detected: C:\Users\Nathan\workspace\Project\Debug
Preferred POSIX equivalent is: /cygdrive/c/Users/Nathan/workspace/Project/Debug
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
In file included from /usr/lib/gcc/i686-pc-cygwin/4.5.3/include/c++/cwchar:44:0,
from /usr/lib/gcc/i686-pc-cygwin/4.5.3/include/c++/bits/postypes.h:42,
from /usr/lib/gcc/i686-pc-cygwin/4.5.3/include/c++/iosfwd:42,
from /usr/lib/gcc/i686-pc-cygwin/4.5.3/include/c++/ios:39,
from /usr/lib/gcc/i686-pc-cygwin/4.5.3/include/c++/ostream:40,
from /usr/lib/gcc/i686-pc-cygwin/4.5.3/include/c++/iostream:40,
from ../src/Project.cpp:9:
/usr/lib/gcc/i686-pc-cygwin/4.5.3/include/c++/cstddef:44:20: fatal error: stddef.h: No such file or directory
src/subdir.mk:18: recipe for target `src/Project.o' failed
compilation terminated.
make: *** [src/Project.o] Error 1
19:12:59 Build Finished (took 535ms)

Newbie question f2c compilation problem: cc1plus error: /include: not a directory What does this mean?

I am having problems with compiling code on my Mac (OS X, 10.6.5).
The code uses f2c.
I don't understand the error, and would really appreciate any help. I wondered if it might be a problem with my compiler, and just in case I reinstalled Xcode, which installs a new g++ compiler. But I still get the same error.
Here's the error:
cc1plus: error: /include: not a directory
cc1plus: error: /lib: not a directory
make: *** [Task1.o] Error 1
Thanks!
This may be an error in the installation of your gcc compiler. It seems it may be looking for includes in /usr/include, but it is missing the first part of the directory. Try executing:
$ gcc -v
to see what directories the gcc you're using has by default. In my case, I see
--prefix=/usr
as one of the options.

Compiling Festival on MingW32

I'm trying to compile Festival on MingW32, so I can have a Windows binary. I couldn't find the Windows binary on their site. Anyone have one they can post?
If not, here's what I have so far. I did the ./configure and make for it and have the following message:
$ make
config/config:43: ../speech_tools/config/config: No such file or directory
So, I downloaded the speech_tools tar ball and got. Did the ./configure and make to get:
$ make
config/config:156: config/systems/ix86_unknown.mak: No such file or directory
../config/config:156: ../config/systems/ix86_unknown.mak: No such file or directory
make: *** No rule to make target `../config/systems/ix86_unknown.mak'. Stop.
config/rules/modules.mak:133: config/modincludes.inc: No such file or directory
make --no-print-directory -C ./config MADE_FROM_ABOVE=1 MODINCLUDES=1 INCLUDE_EVERYTHING='' modincludes.inc
../config/config:156: ../config/systems/ix86_unknown.mak: No such file or directory
make[1]: *** No rule to make target `../config/systems/ix86_unknown.mak'. Stop.
make: *** [config/modincludes.inc] Error 2
So, I copied config/systems/ix86_CYGWIN32.mak to ix86_unknown.mak and tried again. Now I get this message:
g++ -c -fno-implicit-templates -O3 -Wall -Wno-non-template-friend -Wno-deprecated -DSUPPORT_EDITLINE -I../include slib.cc
In file included from slib.cc:85:
../include/EST_unix.h:53:25: sys/wait.h: No such file or directory
../include/EST_unix.h:54:29: sys/resource.h: No such file or directory
In file included from ../include/EST_String.h:50,
from ../include/siod.h:17,
from slib.cc:88:
../include/EST_iostream.h:54:26: strstream.h: No such file or directory
In file included from ../include/EST_TList.h:50,
from ../include/EST_string_aux.h:43,
from ../include/siod.h:18,
from slib.cc:88:
Where do I get sys/wait.h, sys/resource.h and strstream.h? I'd rather not have to try this whole bit in Cygwin and carry around those annoying DLL's. Any advice?
Windows binaries are available here
You'll get further with a full cygwin install instead of just mingwin, but I can't promise success.
I run Ubuntu and remember having Festival available in the Synaptics repository, implying I just had to double click the name, and the thing installed itself with all its dependencies.
If all else fails, you might want to run a VM with ubuntu or dual boot.