That depends. The prime contractor is not required to give preliminary notice, but subcontractors and laborers who have not contracted directly with the owner must give notice of any unpaid lien to the owner before filing a lien. Any materials supplier who provides preliminary notice will have the same lien rights as as a general contractor.
The filing deadlines depend on the level and status of the claimant. You must also first provide notice to the property owner.
Original contractors have 6 months from the date on which the entire debt becomes due to file a mechanic's lien. Laborers must file within 30 days of the date on which the labor was last provided on the project. Everyone else must file their lien claim within 4 months after the date on which the last provided labor, materials or equipment to the job.