Score:0

I Can't Compile C++ Program

in flag

When I run the command gcc CCC.Cpp I get this error:

CCC.Cpp: file not recognized: file format not recognized
Collect2: error: ld returned 1 exit status"

This is the content of CCC.Cpp file:

#include <iostream>
using namespace std;
int main(){cout << "CCC";return 0;}

Error message

muru avatar
us flag
Please don't post screenshots of command output. Copy the text here and use code formatting: https://askubuntu.com/editing-help#code. Also add the output of `cat -A CCC.Cpp`.
Knud Larsen avatar
by flag
Please install the C++ compiler : `sudo apt install g++` ..... and use g++ for C++ code. ...... ...... https://unix.meta.stackexchange.com/questions/4086/psa-please-dont-post-images-of-text
FedKad avatar
cn flag
Rename your file to `CCC.cpp` and use the command `g++` instead.
hr flag
Related: [Compiling C source file without .c suffix](https://askubuntu.com/questions/380558/compiling-c-source-file-without-c-suffix)
Score:1
zw flag

You have to rename the file from CCC.Cpp to CCC.cpp first and then compile your application by G++ (C++ compiler).

Reproducible way:

sudo apt-get install g++

mv CCC.Cpp CCC.cpp
g++ CCC.cpp -o CCC
./CCC

Also you should not use root account for daily non-administrative task.

FedKad avatar
cn flag
After installing `g++` and renaming the source file, you can use just `make CCC` instead of the `g++ ...` command.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.