This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Linux C++ Help
- From: Momchil Velikov <velco at fadata dot bg>
- To: "Jayanta Narayan Choudhuri" <sss at cal dot vsnl dot net dot in>
- Cc: <gcc-help at gcc dot gnu dot org>
- Date: 06 Dec 2002 14:59:25 +0200
- Subject: Re: Linux C++ Help
- References: <001201c29d0d$31da9720$01c809c0@sssdom.com>
>>>>> "Jayanta" == Jayanta Narayan Choudhuri <sss@cal.vsnl.net.in> writes:
Jayanta> 1. gcc -o x.exe jnc.c # WORKS
Jayanta> 2. gcc -o x.exe jnc.cpp # FAILS even though jnc.c
Jayanta> & jnc.cpp are identical
But are compiled as different languages, C++ does NOT implicitly
declare ``int strlen (...)''.
Jayanta> 3. g++ -o x.exe jnc.cpp # also FAILS
For the same reason.
Jayanta> 4. g++ -o x.exe gplus.cpp # also fails though I used the
Jayanta> recommended headers of C++
Same reason.
the above errors are NOT linking errors, too.
Adding ``#include <string.h>'' or ``#include <cstring>'' fixes the
above compilations.
Also, you should link C++ programs with the C++ compiler driver
``c++'' (or ``g++'') or, alternatively, specify the C++ libraries,
i.e., either
c++ -o xx jnc.cpp
or
gcc -o xx jnc.cpp -lstdc++
~velco