The rules on getting visa to Libya are fluid and you never know if this is going to be your day. The temper of the official at the consulate will be of more importance than fx. The best yapproach is applying for visa from back home. You will need an introductory letter or a stamp in Arabic from your own contry's embassy. Getting visas on the border posts is risky.
Most travellers have to return without getting one.
And don't even think about trying to get one at the airport in Tripoli. It is normally needed that an application for a visa is followed by a translation of your passport in Arabic, and all papers should be handed over to the Libyan officials no later than 2 weeks in advance of your planned arrival in Libya. What has proven helpful for independent travellers obtaining visa for Libya, is an official invitation from a Libyan citizen or from a company officials inside Libya. Your way around this trouble, is getting in contact with a tourist office in Libya, which will do most of the job for you, but you will have to book yourself on one of their trips. People from most Arab countries or from Malta can enter Libya with a passport only.