I'm trying to get a program using the <filesystem> library running on Windows. I'm using MSYS2's (64 Bit) g++.
#include <iostream>
#include <filesystem>
int main()
{
std::cout << "Hello World\n";
std::cout << "Current path is " << std::filesystem::current_path() << '\n';
}
I'm building it with
g++ -std=c++17 -Wall -Werror -Wextra main.cpp -lstdc++fs
I get no console output from the compiler. It silently generates an a.exe. Executing the a.exe just does nothing. There is no output and no errors. $? (which is said to contain a program's return code) is 127 after running the program.
g++ -v prints:
Using built-in specs.
COLLECT_GCC=C:\msys64\mingw64\bin\g++.exe
COLLECT_LTO_WRAPPER=C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.1.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-9.1.0/configure --prefix=/mingw64 --with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/mingw64/x86_64-w64-mingw32/include --libexecdir=/mingw64/lib --enable-bootstrap --with-arch=x86-64 --with-tune=generic --enable-languages=c,lto,c++,fortran,ada,objc,obj-c++ --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-filesystem-ts=yes --enable-libstdcxx-time=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --disable-isl-version-check --enable-lto --enable-libgomp --disable-multilib --enable-checking=release --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --enable-plugin --with-libiconv --with-system-zlib --with-gmp=/mingw64 --with-mpfr=/mingw64 --with-mpc=/mingw64 --with-isl=/mingw64 --with-pkgversion='Rev3, Built by MSYS2 project' --with-bugurl=https://sourceforge.net/projects/msys2 --with-gnu-as --with-gnu-ld
Thread model: posix
gcc version 9.1.0 (Rev3, Built by MSYS2 project)
What could be wrong?
(I get a Hello World output and $? is 0, if I comment out the line with the std::filesystem::current_path() call, so the compiler is working.)
Thanks to the commenters for dropping some ideas that finally led me to finding a solution.
TL;DR
If you have various MinGW-based tool sets installed (e.g. Cygwin, MinGW, MSYS, Git Bash), use the shell shipped with the set. Only carefully add the mingw*/bin paths to PATH; rather stick to the default PATH setup of the respective shell. Click here, if you want to have convenient context menu shortcuts for the MSYS shell.
A Story about a million MinGWs
The problem was due to my weird local setup. Over the time I accumulated various versions of MinGW spread all over my computer. If I needed a utility, say diff, I would google it and download something from somewhere (often sourceforge), install it to somewhere and add the bin folder to my PATH. This strategy worked for most things.
Toolsets I've installed over the time, including but not restricted to:
MinGW (32 and 64)
Cygwin
MSYS
Git (+ Git Bash)
For some long time now I have mostly been using the Git Bash for everything. Lately I wanted to get the newest g++ compiler and stuff and found that MSYS2 has a package manager (pacman) and pretty up to date packages so I installed it. And added it to the PATH, then used the Git Bash.
However, each toolset coming with its own shell does its own PATH magic and has its own MinGW copy. So I made my Git Bash use the MSYS2 g++, but applications executed from the Git Bash still used DLLs from Git Bash's MinGW copy. I don't know for sure, but I think it's very probably that this was the problem.
For finding out, I used the following in the Git Bash:
# because of my PATH adjustment, I got the right g++
$ which g++
/c/msys64/mingw64/bin/g++
# my program uses DLLs from /mingw64, though
$ ldd a.exe
ntdll.dll => /c/Windows/SYSTEM32/ntdll.dll (0x77060000)
kernel32.dll => /c/Windows/system32/kernel32.dll (0x76e40000)
KERNELBASE.dll => /c/Windows/system32/KERNELBASE.dll (0x7fefcc00000)
msvcrt.dll => /c/Windows/system32/msvcrt.dll (0x7fefcf70000)
libgcc_s_seh-1.dll => /mingw64/bin/libgcc_s_seh-1.dll (0x61440000)
libwinpthread-1.dll => /mingw64/bin/libwinpthread-1.dll (0x64940000)
libstdc++-6.dll => /mingw64/bin/libstdc++-6.dll (0x6fc40000)
USER32.dll => /c/Windows/system32/USER32.dll (0x76f60000)
GDI32.dll => /c/Windows/system32/GDI32.dll (0x7fefddb0000)
LPK.dll => /c/Windows/system32/LPK.dll (0x7fefd540000)
USP10.dll => /c/Windows/system32/USP10.dll (0x7fefdbe0000)
# with cygpath I can find out that this is actually the Git Bash's installation
$ cygpath -w /mingw64
C:\Program Files\Git\mingw64
MSYS2 comes with its own shell, which sets up its PATH correctly so the application works. In the MSYS2 shell:
$ ./a.exe
Hello World
Current path is "E:\\temporary\\2019_07_25-gpp_filesystem_test"
For the unlikely event someone got into a similar trouble and would like to use the MSYS2 shell more easily in various folders, check out this repo with a reg script setting up convenient context menu shortcuts for the MSYS2 shell: https://github.com/njzhangyifei/msys2-mingw-shortcut-menus
Related
I'm trying to get a program using the <filesystem> library running on Windows. I'm using MSYS2's (64 Bit) g++.
#include <iostream>
#include <filesystem>
int main()
{
std::cout << "Hello World\n";
std::cout << "Current path is " << std::filesystem::current_path() << '\n';
}
I'm building it with
g++ -std=c++17 -Wall -Werror -Wextra main.cpp -lstdc++fs
I get no console output from the compiler. It silently generates an a.exe. Executing the a.exe just does nothing. There is no output and no errors. $? (which is said to contain a program's return code) is 127 after running the program.
g++ -v prints:
Using built-in specs.
COLLECT_GCC=C:\msys64\mingw64\bin\g++.exe
COLLECT_LTO_WRAPPER=C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.1.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-9.1.0/configure --prefix=/mingw64 --with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/mingw64/x86_64-w64-mingw32/include --libexecdir=/mingw64/lib --enable-bootstrap --with-arch=x86-64 --with-tune=generic --enable-languages=c,lto,c++,fortran,ada,objc,obj-c++ --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-filesystem-ts=yes --enable-libstdcxx-time=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --disable-isl-version-check --enable-lto --enable-libgomp --disable-multilib --enable-checking=release --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --enable-plugin --with-libiconv --with-system-zlib --with-gmp=/mingw64 --with-mpfr=/mingw64 --with-mpc=/mingw64 --with-isl=/mingw64 --with-pkgversion='Rev3, Built by MSYS2 project' --with-bugurl=https://sourceforge.net/projects/msys2 --with-gnu-as --with-gnu-ld
Thread model: posix
gcc version 9.1.0 (Rev3, Built by MSYS2 project)
What could be wrong?
(I get a Hello World output and $? is 0, if I comment out the line with the std::filesystem::current_path() call, so the compiler is working.)
Thanks to the commenters for dropping some ideas that finally led me to finding a solution.
TL;DR
If you have various MinGW-based tool sets installed (e.g. Cygwin, MinGW, MSYS, Git Bash), use the shell shipped with the set. Only carefully add the mingw*/bin paths to PATH; rather stick to the default PATH setup of the respective shell. Click here, if you want to have convenient context menu shortcuts for the MSYS shell.
A Story about a million MinGWs
The problem was due to my weird local setup. Over the time I accumulated various versions of MinGW spread all over my computer. If I needed a utility, say diff, I would google it and download something from somewhere (often sourceforge), install it to somewhere and add the bin folder to my PATH. This strategy worked for most things.
Toolsets I've installed over the time, including but not restricted to:
MinGW (32 and 64)
Cygwin
MSYS
Git (+ Git Bash)
For some long time now I have mostly been using the Git Bash for everything. Lately I wanted to get the newest g++ compiler and stuff and found that MSYS2 has a package manager (pacman) and pretty up to date packages so I installed it. And added it to the PATH, then used the Git Bash.
However, each toolset coming with its own shell does its own PATH magic and has its own MinGW copy. So I made my Git Bash use the MSYS2 g++, but applications executed from the Git Bash still used DLLs from Git Bash's MinGW copy. I don't know for sure, but I think it's very probably that this was the problem.
For finding out, I used the following in the Git Bash:
# because of my PATH adjustment, I got the right g++
$ which g++
/c/msys64/mingw64/bin/g++
# my program uses DLLs from /mingw64, though
$ ldd a.exe
ntdll.dll => /c/Windows/SYSTEM32/ntdll.dll (0x77060000)
kernel32.dll => /c/Windows/system32/kernel32.dll (0x76e40000)
KERNELBASE.dll => /c/Windows/system32/KERNELBASE.dll (0x7fefcc00000)
msvcrt.dll => /c/Windows/system32/msvcrt.dll (0x7fefcf70000)
libgcc_s_seh-1.dll => /mingw64/bin/libgcc_s_seh-1.dll (0x61440000)
libwinpthread-1.dll => /mingw64/bin/libwinpthread-1.dll (0x64940000)
libstdc++-6.dll => /mingw64/bin/libstdc++-6.dll (0x6fc40000)
USER32.dll => /c/Windows/system32/USER32.dll (0x76f60000)
GDI32.dll => /c/Windows/system32/GDI32.dll (0x7fefddb0000)
LPK.dll => /c/Windows/system32/LPK.dll (0x7fefd540000)
USP10.dll => /c/Windows/system32/USP10.dll (0x7fefdbe0000)
# with cygpath I can find out that this is actually the Git Bash's installation
$ cygpath -w /mingw64
C:\Program Files\Git\mingw64
MSYS2 comes with its own shell, which sets up its PATH correctly so the application works. In the MSYS2 shell:
$ ./a.exe
Hello World
Current path is "E:\\temporary\\2019_07_25-gpp_filesystem_test"
For the unlikely event someone got into a similar trouble and would like to use the MSYS2 shell more easily in various folders, check out this repo with a reg script setting up convenient context menu shortcuts for the MSYS2 shell: https://github.com/njzhangyifei/msys2-mingw-shortcut-menus
I am on Win10. I installed MinGW in Anaconda through
$ conda install -c anaconda mingw
But when I check with $ g++ -v
I see Thread model: win32, which does not support C++11 Thread class. As results when I run $ g++ myprogram.cpp -std=c++11 I got error
error: 'thread' is not a member of 'std'
Outside of Anaconda, I installed MinGW with installer from https://sourceforge.net/projects/mingw-w64/
When installing, choose "posix", and I got what I need.
So my question is, how to make this happen in Anaconda? I want to either
Set Anaconda's C++ compiler to the one outside (the one I installed with installer)
or, install a MinGW with posix in Anaconda.
I tried to find solutions online, the following helped me sorted out my questions. But I couldn't find a solution yet.
Troubles with POSIX program using threads with gcc
https://coderwall.com/p/rzkw6q/compile-c-code-with-c-11-threads
https://docs.conda.io/projects/conda-build/en/latest/resources/compiler-tools.html
The full output is as below. I appreciate for your help!
$ g++ -v
Using built-in specs.
COLLECT_GCC=C:\ProgramData\Anaconda3\Scripts\g++.bat\..\..\MinGW\bin\g++.exe
COLLECT_LTO_WRAPPER=c:/programdata/anaconda3/mingw/bin/../libexec/gcc/x86_64-w64-mingw32/4.7.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../build/gcc/src/configure --target=x86_64-w64-mingw32 --prefix=/c/bb/vista64-mingw32/mingw-x86-x86_64/build/build/root --with-sysroot=/c/bb/vista64-mingw32/mingw-x86-x86_64/build/build/root --enable-languages=all,obj-c++ --enable-fully-dynamic-string --disable-multilib
Thread model: win32
gcc version 4.7.0 20111220 (experimental) (GCC)
I downloaded the toolchain “gcc-arm-none-eabi-6-2017-q2-update-win32-sha1.exe” (Windows) from https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads and installed it on my Windows 10 PC.
The installation folder contains a release.txt in “../share/doc/gcc-arm-none-eabi/” which tells:
This release includes the following items:
newlib and newlib-nano :
git://sourceware.org/git/newlib-cygwin.git commit 0d79b021a4ec4e6b9aa1a9f6db0e29a137005ce7
And also the readme.txt in “../share/doc/gcc-arm-none-eabi/” contains:
C Libraries usage *
This toolchain is released with two prebuilt C libraries based on
newlib: one is the standard newlib (libc.a) and the other is
newlib-nano (libc_nano.a) for code size.
Now I want exactly rebuild all the libc.a and libc_nano.a contained in “../arm-none-eabi/lib/thumb”
At the moment I can build on Ubuntu with “gcc-arm-none-eabi-6-2017-q2-update-linux.tar.bz2”
$ # Downloaded newlib-cygwin (with corresponding hash) into folder newlib-cygwin
$ mkdir build
$ cd build
$ ../newlib-cygwin/configure --target=arm-none-eabi --disable-newlib-supplied-syscalls
$ make
How do I have to configure the newlib to build the exact copies of libc.a and for libc_nano.a contained in gcc-arm-none-eabi-6-2017-q2-update-linux.tar.bz2?
$ # Downloaded newlib-cygwin (with corresponding hash) into folder newlib-cygwin
$ mkdir build
$ cd build
$ ../newlib-cygwin/configure --target=arm-none-eabi --???
$ make
If i understand you correctly, a more detailed question is:
What configure options did 'GNU Arm Embedded Toolchain' developers used when building newlib libraries shipped in gcc-arm-none-eabi-6-2017-q2-update-linux.tar.bz2 archive?
These ones for newlib:
--target=arm-none-eabi --enable-newlib-io-long-long --enable-newlib-register-fini --enable-newlib-retargetable-locking --disable-newlib-supplied-syscalls --disable-nls
And these ones for newlib-nano:
--target=arm-none-eabi --enable-newlib-reent-small --disable-newlib-fvwrite-in-streamio --disable-newlib-fseek-optimization --disable-newlib-wide-orient --enable-newlib-nano-malloc --disable-newlib-unbuf-stream-opt --enable-lite-exit --enable-newlib-global-atexit --enable-newlib-nano-formatted-io --disable-nls
How I got it? Let's walk through the process:
These packages are build on launchpad, where from you find all the builds that took place on lanuchpad. I picked gcc-arm-none-eabi 6-2017q2-1 from 2017-10-24. There i can find the buildlog. I grepped the buildlog with | grep "^+ " | grep "configure " | grep 'src/newlib' and i was left with:
+ /<<PKGBUILDDIR>>/src/newlib/configure --target=arm-none-eabi --prefix=/<<PKGBUILDDIR>>/install-native --infodir=/<<PKGBUILDDIR>>/install-native/share/doc/gcc-arm-none-eabi/info --mandir=/<<PKGBUILDDIR>>/install-native/share/doc/gcc-arm-none-eabi/man --htmldir=/<<PKGBUILDDIR>>/install-native/share/doc/gcc-arm-none-eabi/html --pdfdir=/<<PKGBUILDDIR>>/install-native/share/doc/gcc-arm-none-eabi/pdf --enable-newlib-io-long-long --enable-newlib-register-fini --enable-newlib-retargetable-locking --disable-newlib-supplied-syscalls --disable-nls
+ /<<PKGBUILDDIR>>/src/newlib/configure --target=arm-none-eabi --prefix=/<<PKGBUILDDIR>>/build-native/target-libs --disable-newlib-supplied-syscalls --enable-newlib-reent-small --disable-newlib-fvwrite-in-streamio --disable-newlib-fseek-optimization --disable-newlib-wide-orient --enable-newlib-nano-malloc --disable-newlib-unbuf-stream-opt --enable-lite-exit --enable-newlib-global-atexit --enable-newlib-nano-formatted-io --disable-nls
A bit of Sherlock Holmes and i deduced that the second line is newlib configured to build as newlib-nano (--enable-newlib-reent-small), the first is newlib configured to build as full newlib.
To answer your topic question, to recompile newlib and newlib-nano the same way pass the options I have posted above to newlib ./configure script.
Hints about how the compiler was configured are found in:
$COMPILER_PATH/arm-none-eabi/include/newlib.h
$COMPILER_PATH/arm-none-eabi/include/newlib-nano/newlib.h
The #defines there have a close correspondence to the options that were passed to 'configure', when newlib was built.
I figured it would be useful to give the default configuration of the ARM built newlib/newlib-nano as of 2023 (for GCC 10):
For Newlib:
--enable-newlib-io-long-long
--enable-newlib-io-c99-formats
--enable-newlib-reent-check-verify
--enable-newlib-register-fini
--enable-newlib-retargetable-locking
--disable-newlib-supplied-syscalls
--disable-nls
For Newlib-nano:
--disable-newlib-supplied-syscalls
--enable-newlib-reent-check-verify
--enable-newlib-reent-small
--enable-newlib-retargetable-locking
--disable-newlib-fvwrite-in-streamio
--disable-newlib-fseek-optimization
--disable-newlib-wide-orient
--enable-newlib-nano-malloc
--disable-newlib-unbuf-stream-opt
--enable-lite-exit
--enable-newlib-global-atexit
--enable-newlib-nano-formatted-io
--disable-nls
Ref: https://community.arm.com/support-forums/f/compilers-and-libraries-forum/53310/gcc-arm-none-eabi-what-were-the-newlib-compilation-options
I recently installed gcc 4.9.2 and found a problem when linking with libs.
The output for search path:
install: /usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/
programs: =/usr/libexec/gcc/x86_64-unknown-linux-gnu/4.9.2/:/usr/libexec/gcc/x86_64-unknown-linux-gnu/4.9.2/:/usr/libexec/gcc/x86_64-unknown-linux-gnu/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../x86_64-unknown-linux-gnu/bin/x86_64-unknown-linux-gnu/4.9.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../x86_64-unknown-linux-gnu/bin/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../x86_64-unknown-linux-gnu/bin/
libraries: =/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../x86_64-unknown-linux-gnu/lib/x86_64-unknown-linux-gnu/4.9.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../x86_64-unknown-linux-gnu/lib/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../x86_64-unknown-linux-gnu/lib/../lib64/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../x86_64-unknown-linux-gnu/4.9.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../lib64/:/lib/x86_64-unknown-linux-gnu/4.9.2/:/lib/x86_64-linux-gnu/:/lib/../lib64/:/usr/lib/x86_64-unknown-linux-gnu/4.9.2/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib64/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../x86_64-unknown-linux-gnu/lib/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../:/lib/:/usr/lib/
Really, the problematic thing is this:
/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib64/
I need to change the order of these two libs(so that lib64 has higher search priority), because both dirs have the libstdc++.so.6, and I need to use the one in lib64 folder.
How do I do it?
Please don't:
1, suggest that I change LD_LIBRARY_PATH to explicitly include libstdc++.so.6 as I'm sure there are other things in x86_64-linux-gnu folder that are older versions of that in the lib64 folder - I upgraded g++ from an older version.
2, suggest that I explicitly include that lib64/libstdc++.so.6 in the g++ -L option.
Thanks a lot.
/************************EDIT FOR MORE INFO************************/
Upon the request below, here're some more details about configuration and installation(I downloaded 4.9.2 source from gcc.gnu.org, extracted it and started in the 4.9.2 top level folder):
mkdir ../gcc-build &&
cd ../gcc-build &&
../gcc-4.9.2/configure \
--prefix=/usr \
--libdir=/usr/lib \
--enable-shared \
--enable-threads=posix \
--enable-__cxa_atexit \
--disable-multilib \
--with-system-zlib \
--enable-languages=c,c++ &&
make
You could have a new (or modify the existing) GCC specs file, documentation is here.
AFAIK, the specs file is in your "install" dir, so for you would be in /usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/specs (which you could create if it does not exist).
AFAIK there is some built-in default, but you could configure your system to have an explicit one.
Read also about the debugging options of GCC. You may want to use -dumpspecs to get the built-in default spec.
Details may be highly specific to your system, especially if you compiled GCC from its source code.
I am not familiar enough with specs files to give a reliable solution for your particular issue. You might ask on gcc-help#gcc.gnu.org for details.
NB: I would tend to believe that configuring a gcc with --prefix=/usr (and not a non-system prefix like the default --prefix=/usr/local/ or some --prefix=/opt/ etc...) is a mistake (or at least use also --program-suffix=-4.9). You are likely to mix up your gcc with the system gcc; If you want to replace your system gcc (which is probably dangerous) you should configure your new gcc with the same arguments as your system gcc had. Notice that /usr/bin/gcc -v tells you how was your system gcc configured (to be done before overwriting it).
When compiling a recent GCC 4.9 on some older system I generally would recommend to configure it with --prefix=/usr/local/ and --program-suffix=-4.9 then add /usr/local/bin/ to your $PATH, and use make CC=gcc-4.9 CXX=g++-4.9 for building programs with it.
I'm trying to get crosstool-ng working with both C and C++. Even though I've selected C++ while using menuconfig, it doesn't seem to get built. The gcc compiler works as expected but not g++
I'm not sure what I'm doing wrong so any help would be appreciated.
I followed the steps found here:
Building embedded ARM systems with Crosstool-NG
$ arm-unknown-linux-gnueabi-cpp main.cpp -o test
arm-unknown-linux-gnueabi-cpp: main.cpp: C++ compiler not installed on this system
NOTE: there is no arm-unknown-linux-gnueabi-g++ found on in the bin directory.
I've tried cross-tool version 1.16.0 and 1.15.3
arm-unknown-linux-gnueabi-cpp -v
Using built-in specs.
Target: arm-unknown-linux-gnueabi
Configured with: /opt/crossArm/.build/src/gcc-4.3.2/configure --build=i686-build_pc-linux-gnu --host=i686-build_pc-linux-gnu --target=arm-unknown-linux-gnueabi --prefix=/opt/crossArm/.build/arm-unknown-linux-gnueabi/buildtools --with-local-prefix=/home/jgarvin/x-tools/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi/sysroot --disable-libmudflap --with-sysroot=/home/jgarvin/x-tools/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi/sysroot --enable-shared --with-pkgversion='crosstool-NG 1.16.0' --with-float=soft --enable-__cxa_atexit --with-gmp=/opt/crossArm/.build/arm-unknown-linux-gnueabi/buildtools --with-mpfr=/opt/crossArm/.build/arm-unknown-linux-gnueabi/buildtools --enable-target-optspace --disable-libgomp --disable-libmudflap --disable-nls --disable-multilib --enable-languages=c
Thread model: posix
gcc version 4.3.2 (crosstool-NG 1.16.0)
Code
#include<iostream>
using namespace std;
int main(){
cout<<"Hello World"<<endl;
return 0;
}
In my build.log file I see C++ option turned on
[DEBUG] CT_CC_SUPPORT_CXX=y
I also see it in the config.log:
configure:3030: $? = 0
configure:3019: gcc -v >&5
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/4.6/lto-wrapper
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu
From, http://briolidz.wordpress.com/2012/02/07/building-embedded-arm-systems-with-crosstool-ng/
Refine your configuration by running the menuconfig interface:
$ ./ct-ng menuconfig
In this step, navigate to the C Compiler menu. Then you can select C++ or de-select Java, Fortran, etc. Since crosstool-ng is just a bunch of scripts and patch files, it is very rare that a development build breaks things. You can always pull from the hg repository.
hg clone http://crosstool-ng.org/hg/crosstool-ng
cd crosstool-ng
./bootstrap
make
sudo make install
This will have the latest fixes. I have built arm cross compilers with C++ support many times using this method [including Canadian crosses for Mingw and i386 from an x86_64 host].
EDIT: I see that the wordpress link recommends a local install of ct-ng. The commands above do a full install, putting things in /usr/local. Also, it seems the OP did try to set menuconfig's C++ option. Try altering the sjlj value, use the latest version of ct-ng and install it. This produces an ARM Linux C++ cross-compiler on Ubuntu for me. The build.log output can be helpful in determining if ct-ng decided some configuration was impossible.
Finally, the mailing list crossgcc#sourceware.org doesn't require subscription afaik. The archives at http://sourceware.org/ml/crossgcc/ can be helpful. If you still have issues, I am sure someone on the mailing list will be able to help you.
EDIT: With the latest ct-ng installed try,
$ ct-ng arm-cortex_a15-linux-gnueabi #Alternate arm-yem-linux-gnueabi
$ ct-ng menuconfig # Tweak for your processor, gcc version, etc.
$ ct-ng build # Go have a coffee (or work on something else).
Sorry, your host compiler was made with Linaro. I was reading too much into your edit.
I was having similar issue. It turns out that I was looking at the wrong bin directory under .build. The final version of the toolchain was installed under ~/x-tools instead...
If you are still looking for an answer on compiling c++ on arm platform:
Install crosstool-ng:
tar xjf <ct-ng archive>
cd crosstool-ng-<numversion>
# reset of LD_LIBRARY_PATH is required to avoid issues with crosstool-ng
unset LD_LIBRARY_PATH
./configure prefix=<installDir>
#example ./configure prefix=/opt/cross-rpi
make
make install
#required to make sure you get the right on in case
export PATH=<installDir>/bin:$PATH
#check what version is on now.
which ct-ng
Now create and launch the configuration:
mkdir chain-build #the directory hosting the build files of your cross compil chain
cd chain-build
ct-ng menuconfig
Set options are relevant to the arm platform amongst other:
Paths and misc Options
Configure the maximum log level to see to WARN instead of INFO which totally clutters the logs and in my opinion makes them hard to use, way too much noise for the usual use case.
Target options Operating System
Target Architecture
arm
System
linux
Binary utilities
- Select the last version of binutils
C compiler
GCC : Select Show linaro Versions then select the lastest linaro gcc (more stable than non linaro, from experience)
C++ : Check it
Now build your toolchain
ct-ng build
# once done check the content of the bin dir
ls <yourChainInstallDir>/x-tools/arm-unknown-linux-gnueabi/bin
You should get something like this:
of all to compile c++ code you should only need g++. To check if g++ (for arm) works ok type
arm-unknown-linux-gnueabi-g++ -v
You should get something similar to this:
Using built-in specs.
COLLECT_GCC=x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-g++
COLLECT_LTO_WRAPPER=/opt/cross1.19/x-tools/arm-unknown-linux-gnueabi/libexec/gcc/arm- unknown-linux-gnueabi/4.8.2/lto-wrapper
Target: arm-unknown-linux-gnueabi
[...]
blahblah
[...]
gcc version 4.8.2 20130603 (prerelease) (crosstool-NG 1.19.0)
Once you get this message you should be ok.
The only other thing to watch out for is if you got all of the libraries needed to compile your code.
e.g. for instance on Raspberry-pi (using Raspbian), some of the libs have to be manually imported from /lib and /usr/lib (put then in your LD_LIBRARY_PATH).
Sometimes the includes for gcc or g++ are not copied in the include directory of the toolchain (when using crosstool-ng, got the issue a couple of times), so you need to get the includes from your /usr/include directory.