Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gcc to compile c file that ends with ".C" (Capital C)

Tags:

c

gcc

A weird behaviour when I shell:

bush@ubuntu:~/CPPWorkspace/Ex12$ gcc users/dubi/justPrnit.C

Returns an error:

gcc: error trying to exec 'cc1plus': execvp: No such file or directory

But when I change justPrnit.C to justPrnit.c (with little 'c') it compiled successfully.

What's that?

like image 908
Bush Avatar asked Dec 01 '25 08:12

Bush


1 Answers

error trying to exec 'cc1plus'

Because .C is assumed to be a C++ source file (cc1plus is the C++ parser backend of GCC - by the way, it seems that your local installation of GCC lacks g++ - are you using the default [incomplete] setup?).

To solve this, use the -x switch to force the language:

gcc -x c users/dubi/justPrnit.C

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!