#Can someone help explain how to access object (.o) files?
25 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
So you need a header file that has the function names and argument types inside the associated object file.
If you have that, include that header file, then just add he object file to your compilation.
gcc myfile.c otherfile.o
So otherfile.o is the name of the file you are creating, or is it related to the .h file?
I made a .c file (side.c) that prints out a name, and I included an h file (side.h) of the same name in there that declares the function I defomed in side.c
side.c
#include "side.h"
void PrintName(char* name){
printf("Hello, my name is %s\n", name);
}```
side.h
```void PrintName(char* name);```
I tried using your command and it says side.o: no such file or directory
Do I need to include -o?
Otherfile.o is the outside object file you are trying to access
Perhaps I am misunderstanding the question
What do you mean by "access an object file"?
Being able to create one then print out its contents
I think I figured it out though
gcc -c -o side.o side.c
c stands for compile I believe, and by using -c it doesn't do the linker phase and it only creates an object file instead of the executable.
!solved
Thank you and let us know if you have any more questions!
This thread is now set to auto-hide after an hour of inactivity
If you want to view an object file's contents you can use objdump
But you're just going to get a bunch of dissasembled machine code
hexdump a.out , through this you can acess the file but its in hexcodes 🙂
To learn about object files in C....,,, you basically want to learn assembly
since assembly is basically a compiled program in human readable format.
I'd recommend
chapter 3
I'd actually recommend that entire book. But chapter 3 teachers you x86 AT&T syntax assembly.
....... the book assumes you know C