So the buildings get paid?
Marx did work under the assumption of the "Labor theory of value" [1], which states that only labor adds value to raw products, and that only humans are paid. So the price of a consumer product may be broken down into labor costs, raw material, R&D, long term investments etc. But each of the non labor points can be broken up further and in the end you end with only labor.
19th century economists did then follow this thought to construct the market backwards, that is some were trying to model markets based not on utility of a product and demand, but purely on labor costs.
No, the person who invested in the building and bought the machinery and raw material gets reimbursed and paid the opportunity cost of their investment, aka normal profits (as opposed to economic profits). I think the labor theory of value is one of Marx's main errors; it sort of works for agriculture because food does actually grow out of the ground, land was owned without being built, and in the 19th century the vast bulk of the expense involved was labor based, but this didn't translate well to industrial production at all.
I sort of agree, that the labor theory of value is one of the main problems of Marx's analysis. Sort of, because I think the premise that only people accept money and you always end up with profits or wages is essentially tautological. However, it is not a very useful way to think about (modern) markets, since one is too busy to trace back flows of money to actually understand their behavior.
19th century economists did then follow this thought to construct the market backwards, that is some were trying to model markets based not on utility of a product and demand, but purely on labor costs.
[1]https://en.wikipedia.org/wiki/Labor_theory_of_value