I guess you are trying to do the following:
$ g++ test.cpp -c -o test.o
$ g++ test.o -o program
To run your program type
$ ./program
afterwards.
Question
Here is my C++ code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main () {
std::ifstream ifs ("strength_classes.txt", std::ifstream::in);
char c = ifs.get();
while (ifs.good()) {
std::cout << c;
c = ifs.get();
}
ifs.close();
return 0;
}
I then compile it in the tutorial by running the following, but it outputs the error:
Laptop:Downloads Stu$ c++ -c test.cpp
Laptop:Downloads Stu$ g++ -o test.o
clang: error: no input files
Solution
I guess you are trying to do the following:
$ g++ test.cpp -c -o test.o
$ g++ test.o -o program
To run your program type
$ ./program
afterwards.
OTHER TIPS
g++ -o test.o
This is wrong. The -o
flag is supposed to indicate the filename of the resulting executable, which you're accidentally stating as test.o
and then failing to provide inputs.
Write:
g++ -o myBinary test.o
then execute:
./myBinary