This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Linux C++ Help


>>>>> "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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]