Question on Multiple Files

Hi everyone!
I have doubts regarding the explanation of multiple files inside the book.

Assumption 1

  1. main.m, BNRPerson.m are compiled into machine codes separately (2 set machine codes).
  2. machine codes of main.m and BNRPerson.m are linked to any libraries separately to form 2 set of executable codes. (2 set executable codes)
  3. each set of executable code is stored inside main.m and BNRPerson.m respectively.

Assumption 2

  1. main.m, BNRPerson.m are compiled into one set of machine code. (1 set machine code)
  2. machine code of main.m and BNRPerson.m are linked to any libraries to form 1 set of executable codes. (1 set executable code)
  3. Both main.m and BNRPerson.m contain the same set of executable code in their respective file.

May I know which assumption is right?
Please enlighten me.

Thanks in advance!

Hello!

Here’s how it works:

  1. main.m and BNRPerson.m each compile into separate machine code files. These are called object files.
  2. these object files are linked against any necessary libraries and produce one single combined executable file.

… I don’t think I understood part 3 of your respective assumptions, so I don’t know what to say about that. What do you mean by these statements about executable code storage?

Hi Mikey!

Actually for the third point, I just wish to know where does the executable file stores.
Is it inside the main.m or BNRPerson.m or inside both main.m and BNRPerson.m

Thanks!

The executable file is stored neither in main.m nor in BNRPerson.m - they are just source files.

The executable file is stored in its own file, as Mikey explained in point 2.

You can get to the executable file itself in several ways, but the easiest way is from Xcode:

(The following should work in Xcode 6.3.2)

Under the Products Group in the Navigation area, select a product and bring up the contextual menu and select Show in Finder. For a command line tool, this fill take you to the executable file; for an application, this will take you to the application package (bundle) which contains the executable file in the folder named MacOS under the folder named Contents.

Hi ibex10,

OK. I got it. Thanks! :slight_smile: