3

I'm new to Linux and I need some help!

I am trying to compile the code taken from this post to the linux-kernel mailing list.

I have pasted the file into Libre Office and saved it as pairing_tool.c (Not as pairing_tool.c.odt. I have renamed the file to pairing_tool.c.)

But when I use this command line: gcc -o pairing_tool pairing_tool.c in the terminal, I get many errors.

  • What did I do wrong?
  • Should I paste the text into a special text editor?

Also just to be clear, I've used the text included only in between

#include <linux/input.h>

and

return 0;
}

So I haven't put the comments. I think it is good this way, is it?

  • If you are at all curious as to why using Libre Office did not work, then all you have to do is (1) create the file again by pasting into Libre Office and then saving it as (for example) trythis.c. (2) Open trythis.c with the gedit text edit. I think you will immediately understand why you had so many compile errors. – irrational John Jun 6 '12 at 0:41
5

Yes, you should use a text editor, for example gedit which is installed in Ubuntu by default. LibreOffice Writer is a text processor and it saves its files with some additional markup which C compiler does not understand.

To run gedit, press the Super (Win logo) key and type "gedit".

Apart from saving the program in plain text format, you will also need to install the C compiler and stuff, which you can do with

sudo apt-get install build-essential

(although I think you already managed to install it)

Btw, I can confirm that the program compiles nicely and even runs after that :)

  • oki ;) solved!! – simon Jun 5 '12 at 18:43
0

C source code fila is a ASCII text file with c extension. In Libre office I have saved fila as txt. Editor adds txt extension so I have changed it to c, then I can compile file with no errors using gcc

0

You've discovered the basic computing concept that the file name and extension actually has no bearing whatsoever on the file contents, or the type of information encoded in the file. You can rename cats.png as cats.doc all you want, but that does NOT make it a Word document containing an informational report on feline companions. It will still be an image file in the PNG format, it's just named incorrectly to look like a Word document. Your OS will probably be confused if you double-click on it, but the contents of the file are unchanged and the word processor app that launches when you double-click will probably give you an error dialog.

You did exactly the same thing. You took a Libre Office document file, which is basically a Word document (actually Word can open it as well, these days) with all the formatting information, table of contents, and whatever else may be included, and then renamed it to ".c", leaving all that information intact. The compiler expects plain textual data, with none of that other information.

File extensions are a useful convention to give the user hints as to what might be inside, and also to give the OS hints as to which program to use to view the file content. But they mean nothing more. That's why you needed to actually create a plain-text document, using a plain-text editor, rather than use a Word Processor and rename the file to lie to your OS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.