#Can someone help explain how to access object (.o) files?

25 messages · Page 1 of 1 (latest)

cosmic raft
#

I'm trying to learn more about object files in C, but it is hard to study them when I can't read .o files. Can someone explain to me how to access .o files in a compiler if it's possible?

urban pikeBOT
#

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.

zinc pond
#

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

cosmic raft
#

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?

zinc pond
#

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"?

cosmic raft
#

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

urban pikeBOT
#

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

river saffron
#

But you're just going to get a bunch of dissasembled machine code

dapper tendon
thick tulip
#

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