There is a problem for me. I am storing my files on sdcard because the device is unrooted. When I type in Termux 'clang filename.c' or 'clang filename.c -o filename', and enter, I have as result '$', no more. But I noticed that if there is an error in code, I have an error message.
It seems strange but one time the code were compiled.
I don't understand what is the problem.
Can you share the source code of your program.
Runtime error are such type of error which can't be detected by compilers, and such error can be noticed while running the program
I reinstalled Termux, clang and nano to write files. I wrote and saved a file in rb and a file in C. Note that I wrote in the Termux path and here is the result.I can run easily Ruby files but for c I don't reach out the expected result.
Setting up ruby (2.6.5) ...
$ nano simple.rb
$ ruby simple.rb
hello
$ nano simple.c
$ nano simple.c
$ clang nano.c
clang-8: error: no such file or directory: 'nano.c'
clang-8: error: no input files
$ clang simple.c
$ clang simple.c -o simple
$ ls
a.out downloads simple simple.c simple.rb storage
$ clang simple.c
$ clang -o simple.c
clang-8: error: no input files
It works! So, if I understand, after the clang action, A compiled file is created, and I need to open it with prompting it, the same name of file without the ".c" at the end of the name. And to make this I need to type "./filename". Right?
Partially.
Look, C is a compiled langauge, and Clang is a compiler unlike Python or Ruby which are interpreted language.
When you type the command clang simple.c , clang takes the source code and compiles it into machine code into a.out (a.out is default output name) and to run the program you must execute the binary like this $ ./a.out
And you can name the output binary anything you like by simply passing the -o flag, the syntax is like this :
Is it possible to make this for an unrooted device?
Yes ofcourse. But still Root gives you more flexibility
There is a problem for me. I am storing my files on sdcard because the device is unrooted. When I type in Termux 'clang filename.c' or 'clang filename.c -o filename', and enter, I have as result '$', no more. But I noticed that if there is an error in code, I have an error message.
It seems strange but one time the code were compiled.
I don't understand what is the problem.
Maybe it had Runtime Errors
I don't understand
Can you share the source code of your program.
Runtime error are such type of error which can't be detected by compilers, and such error can be noticed while running the program
I tried even the simplest code as hello world. It's running perfectly with Dcoder app.
But not compiling with Clang?
Exactly
What error does it give?
No error but doesn't compile
there must be something to identify the problem, without knowing the bug I can't help you to debug it.
Here is a pasted text from Termux
$ gcc -o mult.c
clang-8: error: no input files
$ clang -o mult.c
clang-8: error:
Ah, seems your source code is not in Termux home path. You should copy your
mult.c
file to Termux home directoryHow can I make this?
Copy - paste
$ clang -o condition.c
clang-8: error: no input files
$ cd
$ ls
Filename eaain herbe.rb
conditiond.c eaain.c termux-sudo
downloads essain.c
$ pwd
/data/data/com.termux/files/home
$
And this is in the path, right?
Ah now I understand.
Just Remove
-o
and it should work fine.Do this
clang condition.c
I reinstalled Termux, clang and nano to write files. I wrote and saved a file in rb and a file in C. Note that I wrote in the Termux path and here is the result.I can run easily Ruby files but for c I don't reach out the expected result.
Setting up ruby (2.6.5) ...
$ nano simple.rb
$ ruby simple.rb
hello
$ nano simple.c
$ nano simple.c
$ clang nano.c
clang-8: error: no such file or directory: 'nano.c'
clang-8: error: no input files
$ clang simple.c
$ clang simple.c -o simple
$ ls
a.out downloads simple simple.c simple.rb storage
$ clang simple.c
$ clang -o simple.c
clang-8: error: no input files
C is a compiled language and It seems
simple.c
is compiled.Just Run the binary
simple
with$ ./simple
It works! So, if I understand, after the clang action, A compiled file is created, and I need to open it with prompting it, the same name of file without the ".c" at the end of the name. And to make this I need to type "./filename". Right?
Partially.
Look, C is a compiled langauge, and Clang is a compiler unlike Python or Ruby which are interpreted language.
When you type the command
clang simple.c
, clang takes the source code and compiles it into machine code intoa.out
(a.out
is default output name) and to run the program you must execute the binary like this$ ./a.out
And you can name the output binary anything you like by simply passing the
-o
flag, the syntax is like this :$clang <SOURCE_CODE> -o <OUTPUT_NAME>
@koouty , seems like you're new to C , I would recommend watching some Beginners' Tutorial and Reading some tutorials available on internet.
Many many thanks.
If any need any further help you can just DM me
👍