my problem that I simply can't compile Hello World programm with g++
#include <iostream>
using namespace std;
int main(void) {
cout << "Hello World!" << endl;
return 0;
}
Compiler gave me message:
evgeny@debian:~/Documents/Programming$ g++ test.cpp -o test
In file included from /usr/include/c++/4.9/clocale:42:0,
from /usr/include/x86_64-linux-gnu/c++/4.9/32/bits/c++locale.h:41,
from /usr/include/c++/4.9/bits/localefwd.h:40,
from /usr/include/c++/4.9/ios:41,
from /usr/include/c++/4.9/ostream:38,
from /usr/include/c++/4.9/iostream:39,
from test.cpp:1:
/usr/include/locale.h:29:25: fatal error: bits/locale.h: No such file or directory
#include <bits/locale.h>
^
compilation terminated.
I've installed libstdc++-developer, tried to use -I/way-to-the-missing-lib, different architecture keys etc., but it doesn't work as well.
Architecture info Linux debian 3.16.0-4-amd64 #1 SMP Debian 3.16.43-2+deb8u5 (2017-09-19) x86_64 GNU/Linux
OS Debian 8.9
g++ version g++ (Debian 4.9.2-10) 4.9.2
installed packages list:
evgeny@debian:~$ dpkg --list | grep c++
ii lib32stdc++-4.9-dev 4.9.2-10 amd64 GNU Standard C++ Library v3 (development files)
ii lib32stdc++6 4.9.2-10 amd64 GNU Standard C++ Library v3 (32 bit Version)
ii libflac++6:amd64 1.3.0-3 amd64 Free Lossless Audio Codec - C++ runtime library
ii libgpgme++2 4:4.14.2-2+deb8u2 amd64 c++ wrapper library for gpgme
ii libsigc++-2.0-0c2a:amd64 2.4.0-1 amd64 type-safe Signal Framework for C++ - runtime
ii libstdc++-4.9-dev:amd64 4.9.2-10 amd64 GNU Standard C++ Library v3 (development files)
ii libstdc++6:amd64 4.9.2-10 amd64 GNU Standard C++ Library v3
ii libx32stdc++-4.9-dev 4.9.2-10 amd64 GNU Standard C++ Library v3 (development files)
ii libx32stdc++6 4.9.2-10 amd64 GNU Standard C++ Library v3 (x32)
Any ideas? I hope solution is obvious, thank you in advance.
If you use -m32
(which in 2017 is a strange thing to do, since most Linux are 64 bits), you need 32 bits libraries, such as lib32stdc++-7-dev
package (or lib32stdc++-6-dev
; it depends upon your version of g++
) on Debian.
BTW, naming your executable test
is very poor taste, it collides with the standard (perhaps builtin) test(1) .
I recommend compiling for your native architecture (probably x86-64) with all warnings and debug info, eg using
g++ -Wall -Wextra -g test.cpp -o mytest
and of course, the resulting executable mytest
is likely to be 64 bits. You could check with the file mytest
command.
BTW, your g++
4.9 is quite old. Why don't you upgrade it? You could install GCC5 or GCC6, eg with aptitude install g++-6
; in october 2017 the current version of GCC is GCC7
Today you'll better learn at least C++11 (don't lose your time learning something older). Older standards are obsolete. So it is better to use at least GCC6 if you want a good support of that standard.
Of course, you need the C++ standard library development package. On my Debian/Sid it is libstdc++-6-dev
The build-essential
metapackage is for building essential utilities coded in C, not in C++.
You need to explicitly install several C++ related packages (and you don't tell which you have installed).
If you know some Debian package coded in C++ (eg fish
), you might use the aptitude build-dep
command on it; it would install properly all the packages needed to build it, and that would include necessary C++ stuff. So you could try aptitude build-dep fish
In october 2017 the stable version of Debian is Debian stretch 9.2; if you use an older variant, you should consider upgrading your distribution.
你能在'/usr/inlcude/bits'目录下找到locale.h文件吗,编译错误提示文件丢失。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.