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

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.

Related

g++: fatal error: cannot execute 'as': CreateProcess: No such file or directory compilation terminated

Hello, I'm trying to learn c++, having installed VStudio Code and MinGW, I was ready to get started but when I try to run the code it says this error:
g++: fatal error: cannot execute 'as': CreateProcess: No such file or directory
compilation terminated.
I tried searching for answers to this error but I so far no luck. What can I do to fix this error? what is causing this error?
You have to install MinGW's binutils before you use any compiler of GCC, try to find out it in the MinGW get program.

Is it possible to compile c++ using Clang only on windows?

I really tried a lot. Clang does not come with standard C++ includes, and obviously can not find them :
clang++ file.cpp -o file.out
C:\Folder\file.cpp:1:11: fatal error: 'iostream' file not found
#include <iostream>
^
1 error generated.
Passing the mingw includes by arguments, it returns another error:
clang++ -target x86_64-w64-mingw32 C:\Folder\file.cpp -IC:\MinGW\mingw64\lib\gcc\x86_64-w64-mingw32\6.3.0\include\c++ -IC:\MinGW\mingw64\lib\gcc\x86_64-w64-mingw32\6.3.0\include\c++\x86_64-w64-mingw32 -IC:\MinGW\mingw64\x86_64-w64-mingw32\include -o C:\Folder\file.out -std=c++11
clang++.exe: error: unable to execute command: program not executable
clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)
When I use -c it does not use the linker and also not generate an executable file.
Edit : I'm running on windows
Run your commands from "x64 Native Tools Command Prompt for VS 2017", or something similar. It will setup some required env vars for you.

luarocks 'gcc-plugin.h' build error

I am trying to use torch together with the hdf5 package. I am trying to install it via luarocks install hdf5 but during the build phase I get an error regarding the gcc-plugin header. (gcc relies on clang backend). The complete error message is:
luarocks install --local hdf5
Installing https://luarocks.org/hdf5-2.0.0-1.src.rock...
Using https://luarocks.org/hdf5-2.0.0-1.src.rock... switching to 'build' mode
Warning: variable CFLAGS was not passed in build_variables
gcclua-config.h:1:10: fatal error: 'gcc-plugin.h' file not found
#include "gcc-plugin.h"
^
1 error generated.
env MACOSX_DEPLOYMENT_TARGET=10.8 gcc -c -o gcclua.o -Iplugin/include -fPIC -O2 -Wall -Wformat-security -I/usr/local/Cellar/lua/5.2.4_3/include gcclua.c
gcclua.c:7:10: fatal error: 'gcc-plugin.h' file not found
#include "gcc-plugin.h"
^
1 error generated.
make[2]: *** [gcclua.o] Error 1
make[1]: *** [gcc] Error 2
make: *** [gcc-lua] Error 2
Just to give more information, I am relying on
gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
xcrun: error: couldn't stat toolchain: '/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.11.xctoolchain' (errno=No such file or directory)
Apple LLVM version 7.3.0 (clang-703.0.29)
Target: x86_64-apple-darwin15.0.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Does anybody has maybe a hint how to fix this issue?
Every help is greatly appreciated!!!
In addition to gcc, you need the headers, which on Linux you can get with sudo apt-get install gcc-4.8-plugin-dev. If you're on a different OS or version of gcc, just substitute the appropriate package manager / gcc version number.
gcc-plugin.h is a part of GCC, so I think you'll really need to install gcc to get that. Clang provides a gcc-compatible front-end script but that merely presents a command-line driver with compatible flags.
You should be able to install GCC using Homebrew: https://apple.stackexchange.com/a/86588
I bet you tried to work on a CS287-16 class :). I have contacted the developer of this library who wasn't that easy to do something to solve the problem. Apparently he has no friends who have a Mac PC... As a workaround I could suggest you to use a Docker container with Linux in it to run Lua scripts. That's what I have ended up with...
Here's the Docker image I was talking about: https://github.com/aoboturov/cs287-16-lua. You could build it yourself and the just run as a Docker container :)

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.

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

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.