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?
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
AFAIK, Some part of C compilation phases can be multi-threaded.
For example, At least Preprocessing and Parsing (creating AST) is only related its source file itself so each file can be parallelized.
Is there any reason that GCC has no multi-threaded compile option?
You can build C/C++ in paralell if you use and setup a proper build system, which handles this for you.
Basically in C/C++ every .c/.cpp file is complied to an .o file. All these .o files are then linked to the resulting binary.
A build system (make for instance) can be used, to build all the .o files in paralell.
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
Basically what I want is to create an object file (maybe x64 ELF one) with assembly code which could then be linked with other object files in order to create one executable. Also I would like to export some addresses from this object and also to import some from the other object files it will link to.
I'll be happy if it can target linux x64 (I'm using OpenSuse now) and can be used with some default linker (like 'ld' maybe).
I want to make a compiler using 'C' language.
Just generate assembly code, and use the assembler to convert to object format.
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 :( )
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
What is the basis difference between an executable file and a non-executable file? is it just that the bytes of an executable are arranged in a meaningful order which a CPU can understand as instructions?
An executable file contains an operating system specific header indicating that the file is meant to hold executable instructions, as well as the instructions themselves. Typically though not universally certain file extensions are either common by convention or required to indicate that a file is executable in addition to the file having a valid header.
If the operating system is told to execute a file, it will check the file header and possibly file extension and, if those match the rules for executability (after possibly checking security concerns as well), the operating system will load the file into memory and attempt to execute the instructions therein.
There's a good overview on Wikipedia
http://en.wikipedia.org/wiki/Executable_and_Linkable_Format
http://en.wikipedia.org/wiki/EXE
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 often find myself wanting to compile an example file included in a larger makefile-based open source c project. Is there a uniform best way to proceed?
I can't just compile the one file using gcc because there are all sorts of headers and dependencies that the c file requires which are scattered about the project. Here is a concrete example:
HOCR (google cache here), is an open source Hebrew language optical character recognition program that is primarily GTK based. I need a command-line only version. Amongst the source code (downloadable here), there is a command-line only example c file: examples/hocr/hocr-cmd.c that does exactly what I want.
How do I compile the example file?
In the base directory I can run ./configure, make and make install but as far as I can tell this doesn't actually compile the example file.
Also, in addition to the main Makefile I see a number of Makefile.am and Makefile.in files. Are these relevant? Is there a general guiding principle to proceed? This is not the first time I've gotten stuck here.
For those who are interested, I am running Ubuntu 10 Lucid on VirtualBox Virtual Machine.
Somewhere in Makefile there is a target that builds either the specific file or the files in the directory. Find that target and make it. Additionally, there may be a separate Makefile in that directory or one of its parents that is used for building them.
.am and .in files are for autotools, which is the step before ./configure. You should not need to modify them in normal use.