I would like to prevent programmers from using my lib in another applications.
... presumably for copy-protection of some sort.
You didn't say whether the "permitted" application is built by you or by someone else.
If the former, linking your library statically into the application will make it very hard to reuse that library elsewhere.
If the latter, you could use some techniques, such as looking in /proc/self/exe
to find application name from within the library and exit if what you see there is not what you allow, but
- such techniques will likely cause grief to your customers, and
- will increase your support load (when they misfire under legitimate conditions), and
- will be trivially bypassed by a moderately sophisticated adversary.
Which is to say that generally that's a waste of time.