user280339
user280339

Reputation: 89

file format not recognized; treating as linker script. Error in text file?

I am running ubuntu, linux. I am trying to compile three files, a main.cpp and Token.h and Token.cpp files. I am trying to read in from a file called test1 that is a text file. Here is my input to the terminal

g++ test1 -std=c++11 main.cpp token.cpp token.h -Wall -o myprog

I get the following error-

/usr/bin/ld:test1: file format not recognized; treating as linker script
/usr/bin/ld:test1:2: syntax error
collect2: error: ld returned 1 exit status

I got rid of all the data in my main to make sure it wasn't that.

Please and thank you.

Upvotes: 3

Views: 7763

Answers (1)

Pavel P
Pavel P

Reputation: 16843

I am trying to read in from a file called test1 that is a text file.

Do you think that if you pass it to g++ you'll read from it? Can you clarify what you are trying to do?

To build your program try to use this:

g++ -std=c++11 main.cpp token.cpp -Wall -o myprog

g++ is the C++ compiler, it compiles/links your c++ code into executable programs. Once your program is compiled by g++ you can execute it and pass your file name to the program (assuming that your file is called test1):

./myprog test1

Upvotes: 1

Related Questions