MingW c++ compile Error Win 7 x64 - c++

I'm trying to compile a simple C++ HelloWorld example on my Win 7 x64 machine with the mingw compiler.
I downloaded the automated installer here: http://sourceforge.net/project/showfiles.php?group_id=2435
After setting the required paths in the system environment variables i was trying to get the compiler to work with a simple HelloWorld example. Sadly, it always crashes with the following error dialog (i am using a german windows, so the translation may not be perfect):
cc1plus.exe - Application error
The application could not be started correctly (0xc000003b).
Click "OK" to close the application.
Below the verbose compile output
W:\Timo\workspace\c++\HelloWorld>gcc HelloWorld.cpp -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=d:/workspace/mingw/bin/../libexec/gcc/mingw32/4.5.2/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.5.2/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --ena
ble-shared --enable-libgomp --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-libs --disable-werror -
-build=mingw32 --prefix=/mingw
Thread model: win32
gcc version 4.5.2 (GCC)
COLLECT_GCC_OPTIONS='-v' '-mtune=i386' '-march=i386'
d:/workspace/mingw/bin/../libexec/gcc/mingw32/4.5.2/cc1plus.exe -quiet -v -iprefix d:\workspace\mingw\bin\../lib/gcc/mingw32/4.5.2/ He
lloWorld.cpp -quiet -dumpbase HelloWorld.cpp -mtune=i386 -march=i386 -auxbase HelloWorld -version -o C:\Users\afro\AppData\Local\Temp\c
czfrXM3.s
Thanks in advance.
Timo

I've found the problem. The file i tried to compile was saved on my NAS-Server which requires a login to access the files. I was able to access the file via console, the compiler obviously did not. After moving the source files on my local hdd, the compiler started working.

Related

caffe installation: gcc error namespace "std" has no member "isnan"

I'm trying to install (py)caffe on ubuntu 17.10
However when I do make all I get the following error:
./include/caffe/common.hpp(84): error: namespace "std" has no member "isnan"
./include/caffe/common.hpp(85): error: namespace "std" has no member "isinf"
2 errors detected in the compilation of "/tmp/tmpxft_00004921_00000000-19_nesterov_solver.compute_61.cpp1.ii".
Makefile:594: recipe for target '.build_release/cuda/src/caffe/solvers/nesterov_solver.o' failed
or when I use cmake instead
/home/thijser/caffe/include/caffe/common.hpp(84): error: namespace "std" has no member "isnan"
/home/thijser/caffe/include/caffe/common.hpp(85): error: namespace "std" has no member "isinf"
2 errors detected in the compilation of "/tmp/tmpxft_00004e32_00000000-7_math_functions.cpp1.ii".
CMake Error at cuda_compile_1_generated_math_functions.cu.o.Release.cmake:282 (message):
Error generating file
/home/thijser/caffe/build/src/caffe/CMakeFiles/cuda_compile_1.dir/util/./cuda_compile_1_generated_math_functions.cu.o
Note that I'm not just going for sudo apt-get install caffe as doing so does not also install pycaffe, any solution that also installs pycaffe is also valid. I understand that isnan in std likely comes via boost or that this somehow involves a discrepancy between c++ versions? I'm not much of a c++ expert so I'm not sure how that works, I use gcc4.9 for this as nvcc doesn't like later versions of gcc. I know that caffe works on other people's machines and on a older version of ubuntu I had installed so that suggests it's all a configuration issue.
Anybody know how to fix this?
edit using verbose mode on cmake I was able to find out that it doing the following as it happened
/usr/bin/cmake -E remove /home/thijser/caffe/build/src/caffe/CMakeFiles/cuda_compile_1.dir/util/cuda_compile_1_generated_math_functions.cu.o.depend.tmp /home/thijser/caffe/build/src/caffe/CMakeFiles/cuda_compile_1.dir/util/cuda_compile_1_generated_math_functions.cu.o.NVCC-depend
-- Generating /home/thijser/caffe/build/src/caffe/CMakeFiles/cuda_compile_1.dir/util/./cuda_compile_1_generated_math_functions.cu.o
/usr/bin/nvcc /home/thijser/caffe/src/caffe/util/math_functions.cu -c -o /home/thijser/caffe/build/src/caffe/CMakeFiles/cuda_compile_1.dir/util/./cuda_compile_1_generated_math_functions.cu.o -ccbin /usr/bin/cc -m64 -DCAFFE_VERSION=1.0.0 -Xcompiler ,\"-fPIC\",\"-Wall\",\"-Wno-sign-compare\",\"-Wno-uninitialized\",\"-O3\",\"-DNDEBUG\" -gencode arch=compute_61,code=sm_61 -Xcudafe --diag_suppress=cc_clobber_ignored -Xcudafe --diag_suppress=integer_sign_change -Xcudafe --diag_suppress=useless_using_declaration -Xcudafe --diag_suppress=set_but_not_used -DUSE_LMDB -DUSE_LEVELDB -DUSE_OPENCV -DWITH_PYTHON_LAYER -Xcompiler -fPIC -DNVCC -I/home/thijser/caffe/include -I/home/thijser/caffe/src -I/usr/include -I/usr/include/hdf5/serial -I/usr/include/opencv -I/usr/include/x86_64-linux-gnu -I/usr/include/python2.7 -I/usr/local/lib/python2.7/dist-packages/numpy/core/include -I/home/thijser/caffe/build/include -I/home/thijser/caffe/build
/home/thijser/caffe/include/caffe/common.hpp(84): error: namespace "std" has no member "isnan"
/home/thijser/caffe/include/caffe/common.hpp(85): error: namespace "std" has no member "isinf"
testing against the following code:
https://ideone.com/Yxvt5m
$ gcc -std=c++11 test.cpp which is the same as g++ test.cpp
gave me
test.cpp: In function ‘int main()’:
test.cpp:7:15: error: ‘__builtin_isnan’ is not a member of ‘std’
cout << std::isnan(42.0) << std::isinf(42.0);
^
test.cpp:7:15: note: suggested alternative:
<built-in>: note: ‘__builtin_isnan’
test.cpp:7:35: error: ‘__builtin_isinf_sign’ is not a member of ‘std’
cout << std::isnan(42.0) << std::isinf(42.0);
^
test.cpp:7:35: note: suggested alternative:
<built-in>: note: ‘__builtin_isinf_sign’
suggesting an configuration issue on my machine, however clang++ test.cpp did not give any error suggesting that maybe we could use that to install caffe?
$ gcc --version
gcc (Ubuntu 4.8.5-4ubuntu6) 4.8.5
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$gcc -xc++ -E -v -
Using built-in specs.
COLLECT_GCC=gcc
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.5-4ubuntu6' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.5 (Ubuntu 4.8.5-4ubuntu6)
COLLECT_GCC_OPTIONS='-E' '-v' '-mtune=generic' '-march=x86-64'
/usr/lib/gcc/x86_64-linux-gnu/4.8/cc1plus -E -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE - -mtune=generic -march=x86-64 -fstack-protector -Wformat -Wformat-security
ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/4.8"
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/include/c++/4.8
/usr/include/x86_64-linux-gnu/c++/4.8
/usr/include/c++/4.8/backward
/usr/lib/gcc/x86_64-linux-gnu/4.8/include
/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
Edit: thanks to #EliahKagan 's suggestions in the askubuntu chat I found that adding in the line CXXFLAGS += g++ -D_GLIBCXX_USE_C99_MATH -std=c++11 to the makefile solves this issue, however it inimitably throws the next error of
thijser#AI-core-Regain:~/caffe/build$ make all
[ 0%] Building CXX object src/caffe/CMakeFiles/caffeproto.dir/__/__/include/caffe/proto/caffe.pb.cc.o
In file included from /home/thijser/caffe/build/include/caffe/proto/caffe.pb.cc:5:
/home/thijser/caffe/build/include/caffe/proto/caffe.pb.h:7:10: fatal error:
'string' file not found
#include <string>
^~~~~~~~
1 error generated.
In my case, I also met this error when I built caffe on ubuntu 17.10, but I finally found solution:
Let add the following to:
/usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h
/* #undef _GLIBCXX_USE_C99_MATH */
#define _GLIBCXX_USE_C99_MATH 1
After a long and detailed discussion with several of the people on the chat.askubuntu.com room #EliahKagan found out that there is a python3-caffe-cuda package which allows on to import caffe in python3. Note that this won't solve this issue for anyone in the future who has python2 but for me it works. In other words sudo apt-get install caffe and then using python3 rather then python2.7 worked for me.
Also note that we found that the underlying issue appears to be that gcc/g++ isn't finding the standard libraries (std) however it seems that clang and later version of gcc (gcc7)can find these libraries however these do not work with the current version of nvcc.
I am pretty sure you should set the right C++ standard. std::isnan is part of C++11 and newer GCCs use this version by default. Older ones still default to C++98.

Homebrew gcc can't find omp.h on OS X

I've spent hours trying different solutions but nothing has worked so far.
I've installed gcc via Homebrew, and linked gcc to the Homebrew gcc. gcc -v returns this:
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/5.3.0/libexec/gcc/x86_64-apple-darwin14.5.0/5.3.0/lto-wrapper
Target: x86_64-apple-darwin14.5.0
Configured with: ../configure --build=x86_64-apple-darwin14.5.0 --prefix=/usr/local/Cellar/gcc/5.3.0 --libdir=/usr/local/Cellar/gcc/5.3.0/lib/gcc/5 --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-5 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl --with-system-zlib --enable-libstdcxx-time=yes --enable-stage1-checking --enable-checking=release --enable-lto --with-build-config=bootstrap-debug --disable-werror --with-pkgversion='Homebrew gcc 5.3.0 --without-multilib' --with-bugurl=https://github.com/Homebrew/homebrew/issues --enable-plugin --disable-nls --disable-multilib
Thread model: posix
gcc version 5.3.0 (Homebrew gcc 5.3.0 --without-multilib)
However, when I try to compile I get
This is make_MWA_Tools.sh
using $CFITSIO =
building LFILE & read_mwac utilities
cc -g -O -Wall -D_FILE_OFFSET_BITS=64 -fopenmp -c mwac_utils.c
mwac_utils.c:3:10: fatal error: 'omp.h' file not found
#include <omp.h>
^
1 error generated.
make: *** [mwac_utils.o] Error 1
!!!!!!!!!!!!!!!!!!!!!!
build_lfiles/read_mwac make failed !
I've looked in gcc located under Cellar and found mop.h, but for some reason its not being included. Any help would be greatly appreciated.
Edit: I don't believe this is a duplicate question because I could not find another question that Installed gcc from Homebrew, linked 'gcc' to the homebrew gcc installation, and still couldn't find omp.h

msys and tdm-gcc: configure error - cannot run C compiled programs

so I'm trying to compile a preexisting C++ project with msys and tdm-gcc in Windows. I have done this successfully by installing tdm-gcc (latest version) via the installer, editing MinGW/msys/1.0/etc/fstab to give my tdm-gcc install as the mount location, then running msys to call the configure script, and make.
However, for this project I need to use an old version of tdm-gcc (4.6.1-tdm64-1) for binary compatibility. So I installed the required packages from the tdm-gcc sourceforge site (gcc core, gcc c++, binutils, mingw64-runtime, mingw32-make, libintl, libiconv, all of the version the readme says to use with 4.6.1), extracted to a new directory, and edited fstab to point to their location. Now while executing the configure I get this error: cannot run C compiled programs. The config file reads:
[omitted]
configure:3436: $? = 0
configure:3425: gcc -v >&5
Using built-in specs.
COLLECT_GCC=c:\TDM-GCC-4.6.1-64\bin\gcc.exe
COLLECT_LTO_WRAPPER=c:/tdm-gcc-4.6.1-64/bin/../libexec/gcc/x86_64-w64-mingw32/4.6.1/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../src/gcc-4.6.1/configure --build=x86_64-w64-mingw32 --enable- targets=all --enable-languages=c,c++,fortran,objc,obj-c++ --enable-libgomp --enable-lto --enable-libstdcxx-debug --enable-version-specific-runtime-libs --enable-fully-dynamic-string --with-gnu-ld --disable-werror --disable-nls --disable-win32-registry --prefix=/mingw64tdm --with-local-prefix=/mingw64tdm --with-pkgversion=tdm64-1 --with-bugurl=http://tdm-gcc.tdragon.net/bugs
Thread model: win32
gcc version 4.6.1 (tdm64-1)
configure:3436: $? = 0
configure:3425: gcc -V >&5
gcc.exe: error: unrecognized option '-V'
gcc.exe: fatal error: no input files
compilation terminated.
configure:3436: $? = 1
configure:3425: gcc -qversion >&5
gcc.exe: error: unrecognized option '-qversion'
gcc.exe: fatal error: no input files
compilation terminated.
configure:3436: $? = 1
configure:3456: checking whether the C compiler works
configure:3478: gcc conftest.c >&5
configure:3482: $? = 0
configure:3530: result: yes
configure:3533: checking for C compiler default output file name
configure:3535: result: a.exe
configure:3541: checking for suffix of executables
configure:3548: gcc -o conftest.exe conftest.c >&5
configure:3552: $? = 0
configure:3574: result: .exe
configure:3596: checking whether we are cross compiling
configure:3604: gcc -o conftest.exe conftest.c >&5
configure:3608: $? = 0
configure:3615: ./conftest.exe
./configure: line 3617: ./conftest.exe: Bad file number
configure:3619: $? = 126
configure:3626: error: in `/c/jagswm':
configure:3628: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
[omitted]
I've tried adding the tdm-gcc bin to my path, although I don't think that should matter if fstab is set.
Any advice would be greatly appreciated, thanks.
Try to disable your antivirus.
Worked for me while compiling GStreamer, probably because Avast was deleting the a.exe file.
Source: http://wiki.openttd.org/Compiling_on_Windows_using_MinGW#Compilation_and_installation_of_the_required_packages

C++11 not Working with Macports gcc47

I recently installed Macports on my Macbook Pro, and installed the gcc47 port. After adding alias g++="g++-mp-4.7" to my .profile and ensuring that I was using g++-4.7, I attempted to build one of my projects that makes use of C++11. However, I receive this error:
cc1plus: error: unrecognized command line option "-std=c++11"
I find this strange, since Macports built gcc with support for C++, so I would expect that C++11 should work without any problems. I have pasted the output from g++ -v below. Do you have any ideas as to why g++-mp-4.7 is not recognizing -std=c++11 as a valid option?
COLLECT_GCC=g++-mp-4.7
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin12/4.7.1/lto-wrapper
Target: x86_64-apple-darwin12
Configured with: ../gcc-4.7.1/configure --prefix=/opt/local --build=x86_64-apple-darwin12 --enable-languages=c,c++,objc,obj-c++,lto,fortran,java --libdir=/opt/local/lib/gcc47 --includedir=/opt/local/include/gcc47 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --datarootdir=/opt/local/share/gcc-4.7 --with-libiconv-prefix=/opt/local --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-4.7 --with-gxx-include-dir=/opt/local/include/gcc47/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt/local --with-ppl=/opt/local --with-cloog=/opt/local --enable-cloog-backend=isl --enable-stage1-checking --disable-multilib --enable-lto --with-as=/opt/local/bin/as --with-ld=/opt/local/bin/ld --with-ar=/opt/local/bin/ar --with-bugurl=https://trac.macports.org/newticket --disable-ppl-version-check --with-pkgversion='MacPorts gcc47 4.7.1_2'
Thread model: posix
gcc version 4.7.1 (MacPorts gcc47 4.7.1_2)
For future reference, if you install gcc_select you can do:
sudo port select gcc mp-gcc47
hash gcc
This should setup your Macports installed gcc; if you need to reset to Xcode's default, just rerun it with 'none'
EDIT: and Xcode 4.4.x comes with a decent build of Clang; if you install it and then from Preferences->Downloads: Command Line Tools click "Install"
Run clang as:
clang++ -std=c++11 -stdlib=libc++ ...
Note that if mp-gcc47 is not installed, you'll need to do this first:
sudo port install mp-gcc47
To get a full list of available gcc ports:
sudo port list | grep gcc | less
My problem was that since GNU Make executes commands in a different shell, alias g++="g++-mp-4.7" will have no effect on the commands executed by make.

Can't compile SQLCipher on Windows

I'm trying to compile SQLCipher. I've downloaded source code from http://sqlcipher.net/.
Then I'm doing from this post:
[http://groups.google.com/group/sqlcipher/browse_thread/thread/55c6296b56bf4533:][1]
[1]
I installed MinGW (set path to gcc: d:\MinGW\bin), OpenSSL and ActiveState Perl. I copyied file libeay32.dll to sqlcipher directory. Than I try execute this command:
./configure --disable-tcl CFLAGS="-DSQLITE_HAS_CODEC
-I/path/to/openssl/include" LDFLAGS="-leay32"
and I got error:
checking build system type... i686-pc-mingw32
checking host system type... i686-pc-mingw32
checking for gcc... gcc
checking for C compiler default output file name...
configure: error: C compiler cannot create executables
See 'config.log' for more details.
Config.log shows:
configure:2537: $? = 0
configure:2544: gcc -v >&5
Using built-in specs.
COLLECT_GCC=D:\MinGW\bin\gcc.exe
COLLECT_LTO_WRAPPER=d:/mingw/bin/../libexec/gcc/mingw32/4.5.2/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.5.2/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-libs --disable-werror --build=mingw32 --prefix=/mingw
Thread model: win32
gcc version 4.5.2 (GCC)
configure:2548: $? = 0
configure:2555: gcc -V >&5
gcc.exe: '-V' option must have argument
configure:2559: $? = 1
configure:2582: checking for C compiler default output file name
configure:2604: gcc -DSQLITE_HAS_CODEC -l/d/OpenSSL-Win32/bin -libeay32 conftest.c >&5
**d:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe: cannot find -ld:/OpenSSL-Win32/bin
d:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe: cannot find -libeay32**
collect2: ld returned 1 exit status
I don't know what is -leay32. I copied file libeay32.dll to sqlcipher directory. In D there is directory OpenSSL-Win32.
Thanks
Try this for your configure command:
./configure –disable-tcl CFLAGS=”-DSQLITE_HAS_CODEC –Ic:/path/to/openssl/include –Lc:/path/to/openssl/lib –leay32”
-leay32 is a library flag, so think of it like "-l eay32". It's referred to as "eay32" because the library flag ignores the "lib" of "libeay32".