0

I am trying to compile a C program in the terminal.

This is my command:

gcc -1 string -o syncing.c -o syncing

This is my result:

clang: error: no input files

I know that -1... indicates the library I used, syncing.c is the C file I am trying to compile.

What am I doing wrong with my command or is it something else?

I am only using standard libraries.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
GhostMember
  • 91
  • 1
  • 2
  • 9
  • The error message indicates [Clang](https://en.wikipedia.org/wiki/Clang), not [GCC](https://en.wikipedia.org/wiki/GNU_Compiler_Collection) (`"clang: error: no input files"`). It is apparently common to [alias the executable `gcc` to the Clang compiler](https://stackoverflow.com/questions/38840601/how-can-i-ignore-an-error-when-using-gcc-compile-option-werror#comment131019685_38840601) or frontend. – Peter Mortensen Nov 08 '22 at 16:44
  • What system, setup, or even educational institution or system make it common to alias the executable "`gcc`" to the [Clang](https://en.wikipedia.org/wiki/Clang) compiler? For instance, is it some common "distribution" of Clang or software where Clang is a part of it? For instance, could it be Python/[Anaconda](https://en.wikipedia.org/wiki/Anaconda_(Python_distribution)) that also installs a compiler, effectively "overwriting" the existing "`gcc`" executable? – Peter Mortensen Nov 08 '22 at 16:56
  • Starting points (but it ***isn't*** on any of those): *[Clang command line argument reference](https://clang.llvm.org/docs/ClangCommandLineReference.html)*, *[index of options, etc.](https://clang.llvm.org/docs/genindex.html)*, *[Diagnostic flags in Clang](https://clang.llvm.org/docs/DiagnosticsReference.html#wreturn-stack-address)*, and *[Clang man page](https://linux.die.net/man/1/clang)*. – Peter Mortensen Nov 08 '22 at 17:08
  • Here is a hint regarding the aliasing of executable `gcc` to the [Clang](https://en.wikipedia.org/wiki/Clang) compiler: *[Why does the `gcc` command on macOS execute `clang`?](https://www.quora.com/Why-does-the-gcc-command-on-MacOS-execute-clang?share=1)*. Due to [licensing issues](https://www.quora.com/Is-Apple-supporting-Clang-in-order-to-destroy-GCC/answer/Mario-Ray-Mahardhika-1)? – Peter Mortensen Nov 08 '22 at 18:32
  • Is `-1` (the number) a typo of `l` (the letter)? Under *"Linker flags"* on *"[Clang command line argument reference](https://clang.llvm.org/docs/ClangCommandLineReference.html)"* there is [-l](https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-l-arg) ("l" as in [lowercase](https://en.wiktionary.org/wiki/lowercase#Adjective), not the number). Would that make sense in a Clang context? – Peter Mortensen Nov 08 '22 at 19:20
  • Trying this on [Ubuntu 18.04](https://en.wikipedia.org/wiki/Ubuntu_version_history#Ubuntu_18.04_LTS_.28Bionic_Beaver.29) (Bionic Beaver) (yes, I know) with Clang 6.0.0 results in the ***same*** last error "`clang: error: no input files"`. But also in the error line "`clang: error: unknown argument: '-1'`". – Peter Mortensen Nov 08 '22 at 19:31
  • Use of the word *"terminal"* may also hint at Mac: the proper noun (or whatever it is called) "[Terminal](https://en.wikipedia.org/wiki/Terminal_(macOS)#Terminal)", a macOS application. (Though it is also *"GNOME Terminal"*.) But perhaps it would be more likely that "command-line" was used instead(?). – Peter Mortensen Nov 08 '22 at 19:57

1 Answers1

3

Please read up on how to use GCC, GCC command-line options and also official command-line documentation. You are telling it that syncing.c is your output file. But you want it to be your input file.

Also, I am not so sure on the -1 there. You might want to have a look at this on how to include/link external libraries. Here are more examples on that.

You probably meant something like:

gcc syncing.c -lstring -o syncing
Domi
  • 22,151
  • 15
  • 92
  • 122
  • The first link is weird. Opening it results in the browser prompting for a file location, not opening it as a normal HTML page (the content is actually HTML). At least in Firefox 106.0.2 (*"[Always ask you where to save files](https://pmortensen.eu/world2/2022/06/29/setting-up-firefox-on-a-new-system/)"* is enabled, but that shouldn't really matter for *.html* files). E.g., is there a special character in the file part of the URL? – Peter Mortensen Nov 06 '22 at 20:20
  • *[https://pages.cs.wisc.edu/~beechung/](https://pages.cs.wisc.edu/~beechung/)* opens normally. – Peter Mortensen Nov 06 '22 at 20:42
  • Is the web server sending something weird? – Peter Mortensen Nov 06 '22 at 21:29
  • 1
    @PeterMortensen Thanks for the feedback. After 9 years, documentation has evolved. I added some hopefully slightly more future-proof links now. Hopefully that helps – Domi Nov 07 '22 at 06:43
  • Thanks. Though, looking at the question again, it is probably [not about GCC, but Clang](https://stackoverflow.com/questions/20296282/compiling-a-c-program-issue-in-the-terminal/20296301#comment131282271_20296282). – Peter Mortensen Nov 08 '22 at 16:45
  • -1 [could be a typo](https://stackoverflow.com/questions/20296282/compiling-a-c-program-issue-in-the-terminal/20296301#comment131285580_20296282). – Peter Mortensen Nov 08 '22 at 19:21
  • What is the correct command line, then? Incl. the two fixes? – Peter Mortensen Nov 08 '22 at 19:33