Execution of C in linux [closed] - c

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am programming in NDK for android and it got me thinking. I know C is platform independent language but compiler dependent. With that in mind how does the execution of a C program vary from Windows->Linux->Mac. I mean the source code produces .obj file and .exe file in windows. But how about Linux or Mac? What type of file extension does it follow in Linux and Mac. If someone could elaborate on this, I would be very happy.

On linux and MacOs (Unix System) the files have the extension .c and to execute this you should compile them with
gcc -o myprog myprog.c
after it a binary file .o will be product and after you can run it with the file : myprog
by using this line of command :
./myprog
see how linux work if you are interesting by this you can read about Linux things like POSIX
I hope I have explain you the best way. (sorry i'm french :( )

Related

Where is executable file after compiling a c program in ubuntu? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 3 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Improve this question
While compiling a C file in windows I get three files a .c file a .o file and a .exe file, now if i want to distribute my program I will give .exe file. But after compiling a .c in ubuntu I can't find the executable file which will run directly on other system by just clicking it.
The default file name is a.out, but you can specify another filename with gcc a.c -o my_executable.

Why does the assembly language code differs for the same C code from various PC with same processor ( intel x86_64 ) [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
Me and my friend used GCC to convert the same .c file to .s for our assignment. But we both got different assembly language code.
Me
OS :- Windows 10 using GCC 4.7.2
Friend
OS:- Ubuntu using GCC 4.7.2
The program you have written is compiled to run on two different OS. Both has its own set of syscalls and calling conventions. The compiled code will have different way of passing parameter, registers used for passing the values around and selected optimisation level.

Does .obj file contains machine code in binary language? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am confused about .obj files created using C language. Does they contain machine code and is the machine code in binary language, as it is known that the machine can understand only binary language. Moreover, my thinking of machine code is that it is a set of machine instructions in binary language (I may be wrong). Please explain.
An object file is a file containing object code, meaning relocatable format machine code that is usually not directly executable. .obj is the compiled object file that is used by the linker (along with the necessary library (.h) files) to create an executable. The executable is then loaded into the memory for execution using a loader.
Please read the following for more information-
What is compiler, linker, loader?

getch(); runtime error in c and codeblock [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I use codeblocks IDE and gcc compiler. I tried to write the simple program billing system.We I use the getch(); for character input there will be no error during building the project but at run time there will be error and shows the error message like this "Drawing operation was attempted when there was no current window."
What was the actual problem.
You have not mentioned in what platform you are compiling. If it's Linux you can not use getch() since conio.h is only for dos. But with this error message is most probably caused by incorrect integration of gcc with Code::Blocks. Try compling with gcc directly.
since you are using in windows with Code::Blocks with gcc I'm safely assumeing you are using cygwin toolchain, which is a linux like environment. So I recomend you to use system("pause") including the header stdlib.h

Running a program (written in C) in Linux [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I'm using Ubuntu.
I wrote a program in C which interacts with a Mysql Database
The compilation process goes smoothly (excepts several warnings) and I get the executable.
How do I run it in Ubuntu?
I mean, I use this command :
gcc -o magazzino main_magazzino.c -L/usr/include/mysql -lmysqlclient
How do I run magazzino?
if it is in the current directory, run ./magazzino
Usually:
./magazzino
The dot and slash are to tell the shell that you mean the executable in this current directory - otherwise it would search for the program in its $PATH and probably not find it. (Although it's possible to have the current directory in your PATH, this is a bad idea and not recommended for security reasons.)
Just use
/path/to/magazzino
And if your current_folder is same with where magazzino stored use
./magazzino
In the directory type in,
./magazzino

Resources