I am trying to configure my computer to learn C++.
I have errors and warnings once I run gcc from the terminal to call hello.cpp.
C:\Users\Mathieu>gcc -g hello.cpp -o hello -lm
I am using a Windows computer / windows 7 (64 bits) / IDE: Sublime text or Visual Studio Code.
What I have done so far by looking for solutions in the web:
I have added into the PATH the address of MinGW and I have added ";" before the previous PATH.
I have also been checking all the PATH by using echo %PATH% into the terminal and checking the environmental variables.
By typing g++ or gcc alone in the terminal, I get "fatal error, no input file", which means gcc and g++ are well detected by the computer.
I have checked g++ and gcc versions, there are equal.
gcc (MinGW.org GCC Build-20200227-1) 9.2.0
gcc (MinGW.org GCC Build-20200227-1) 9.2.0
I have also performed #alisonc recommandation found here by reviewing links.
g++ 4.6.1 compiler error: Error: unknown pseudo-op: `.cfi_personality'
C:\Users\Mathieu>ls 'which g++' -al
ls: which g++: No such file or directory
C:\Users\Mathieu>ls 'which gcc' -al
ls: which gcc: No such file or directory
When I have launched the program from the terminal I get a long list of errors. I am just adding 3 lines to illustrate. I am not sure if that is relevant to add everything, please, see a few ones:
C:\Users\Mathieu\AppData\Local\Temp\ccUFD66I.s:6498: Error: Unknown pseudo-op:
.secrel32
C:\Users\Mathieu\AppData\Local\Temp\ccUFD66I.s:153: Warning: Missing string
C:\Users\Mathieu\AppData\Local\Temp\ccUFD66I.s:153: Error: Rest of line ignored.
First ignored character is `3'.'''
May someone help me ?
Thank you in advance
All the best
Mathieu
Try to run:
g++ -g hello.cpp -o hello -lm
Related
I try desperatly to compile with c++ intel compiler (icpc) a simple code that I was used to compile on my previous macBook 10.14.
Now, since Headers don't exist anymore with 10.15 Catalina, the compiler has difficulties to find stdlib.h. Here the output I get :
icpc -std=c++11 -O3 -xHost -fp-model strict -prec-div -prec-sqrt -fma -ftz -mp1 -qopenmp -Wall -c -I/opt/intel/compilers_and_libraries_2020.2.258/mac/mkl/include -mkl=parallel main.cpp -o main.o
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/math.h(301),
from /opt/intel/compilers_and_libraries_2020.2.258/mac/compiler/include/math.h(177),
from /Library/Developer/CommandLineTools/usr/include/c++/v1/cmath(304),
from TSAF.h(1),
from main.cpp(1):
/Library/Developer/CommandLineTools/usr/include/c++/v1/stdlib.h(20): catastrophic error: cannot open source file "stdlib.h"
#include_next <stdlib.h>
^
compilation aborted for main.cpp (code 4)
make: *** [Makefile:13: main.o] Error 4
./main_intel.exe: No such file or directory
I tried a lot of potential workarounds from the net but none works. I would like to avoid to create a directory /usr/include/ by removing the security system of my macBook.
I thought maybe this would work by downloading XCode_12.0.1 but same problems remain.
For the moment, I have the version Catalina OS 10.15.7, all has been updated.
EDIT 1: There is something that I don't understand : on my previous macBook 10.14, I didn't need to use the headers of clang c++ for intel compilation.
If anyone could give me a suggestion/clue/track, this would be fine.
Run the command in the Terminal
sudo xcode-select --reset
And then check if proper developer tools are selected instead of the command line tools
xcode-select -p
I'm new to C++, I am trying to compile gtest with Cygwin. I have installed the GNU g++ compiler which works fine. I ran the following command on Cygwin:
g++ -I /cygdrive/c/devel/cpp/gtest/include -I /cygdrive/c/devel/cpp/gtest -pthread -c /cygdrive/c/devel/cpp/gtest/googletest/src/gtest-all.cc
/cygdrive/c/devel/cpp/gtest/googletest/src/gtest-all.cc:39:25: fatal error: gtest/gtest.h: No such file or directory
compilation terminated.
All the files seem to be in place, however the error does not go, any ideas why?
It looks like you have provided space between -I and path.
There should not be any space between -I and corresponding path.
It should be like
g++ -I/cygdrive/c/devel/cpp/gtest/include -I/cygdrive/c/devel/cpp/gtes..
Check it.
I compiled C and link libpcap
after adding the library. I use the following line to compile my code.
mipsel-openwrt-linux-gcc -c -Wall -I /home/osboxes/Downloads/OpenWrt-SDK-brcm47xx-for-Linux-i686-gcc-4.3.3+cs_uClibc-0.9.30.1/staging_dir/toolchai,n-mipsel_gcc-4.3.3+cs_uClibc-0.9.30.1/include -o sniffex.o sniffex.c
Output:
cc1: error: /home/osboxes/Downloads/OpenWrt-SDK-brcm47xx-for-Linux-i686-gcc-4.3.3+cs_uClibc-0.9.30.1/staging_dir/toolchain-mipsel_gcc-4.3.3+cs_uClibc-0.9.30.1/usr/bin/../lib/gcc/mipsel-openwrt-linux-uclibc/4.3.3/../../../../mipsel-openwrt-linux-uclibc/sys-include: not a directory
cc1: error: /home/osboxes/Downloads/OpenWrt-SDK-brcm47xx-for-Linux-i686-gcc-4.3.3+cs_uClibc-0.9.30.1/staging_dir/toolchain-mipsel_gcc-4.3.3+cs_uClibc-0.9.30.1/usr/bin/../lib/gcc/../../lib/gcc/mipsel-openwrt-linux-uclibc/4.3.3/../../../../mipsel-openwrt-linux-uclibc/sys-include: not a directory
I tried also to do it with Makefile
I did something wrong. I find that the SDK was 32 bit and I have 64bit OS then I downloaded 64bit SDK and everything work well.
I'm running Windows 7 with cygwin installed and trying to have a play around with some of the newer C++ features. I'm aware that in order to enable these features I have to pass g++ the -std=c++0x flag, however that gives me the following error:
cc1plus: error: unrecognized command line option "-std=c++0x"
The command line I'm issueing that gives rise to that error is:
g++-3 hello.cpp -std=c++0x -o hello
The reason for the g++-3 is because windows has trouble with the symbolic link. I've used g++ in the cygwin terminal and the result is the same anyway.
Any ideas?
You need to be using a version of GCC which supports C++ 2011 features.
This page has a list of compilers and which features each one supports. If I were you, I'd try to use GCC 4.7 if at all possible.
Whatever I try to compile in Cygwin I get the following output:
checking for mingw32 environment... no
checking for EMX OS/2 environment... no
checking how to run the C preprocessor... gcc -E
checking for gcc... gcc
checking whether the C compiler (gcc ) works... no
configure: error: installation or configuration problem: C compiler cannot creat
e executables.
The last few lines of the logfile look like this:
configure:2810: checking for EMX OS/2 environment
configure:2822: gcc -c conftest.c 1>&5
configure: In function `main':
configure:2818: error: `__EMX__' undeclared (first use in this function)
configure:2818: error: (Each undeclared identifier is reported only once
configure:2818: error: for each function it appears in.)
configure: failed program was:
#line 2815 "configure"
#include "confdefs.h"
int main() {
return __EMX__;
; return 0; }
configure:2838: checking how to run the C preprocessor
configure:2859: gcc -E conftest.c >/dev/null 2>conftest.out
configure:2943: checking for gcc
configure:3056: checking whether the C compiler (gcc ) works
configure:3072: gcc -o conftest conftest.c -llib 1>&5
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: cannot find
-llib
collect2: ld returned 1 exit status
configure: failed program was:
#line 3067 "configure"
#include "confdefs.h"
main(){return(0);}
This is a fresh Cygwin install with G++ and a bunch of other devtools added. Any idea what I need to do to get this thing working?
Update 0: Nick, your link to http://www.geektimes.com/linux/troubleshooting/c-cant-create-executables.html was tried already - unfortunately this instructions are for redhat and do not seem to apply to cygwin.
Your Configure is wrong.
Usually autoreconf -f helps. If not you need to check the failing rule and fix it.
The '-llib' seems a bit unusual to me, but I'm far from an expert. Just out of curiosity is autoconf installed? I had some problems similar to this until I installed autoconf. It seems like the configure script is incorrectly generating a '-llib' value but it's hard to say why based on just the snippets posted.
When I've had this problem, it has been a link error caused by Cygwin looking for "library.o" instead of "library.obj" or "library.so" instead of "library.dll".