FlashMcQueen
FlashMcQueen

Reputation: 665

How to link a library by its exact name with gcc?

I am trying to generate a dynamic library target.so and to do this I need to link it dynamically to a library in which the version number appears at the end:

/path/to/library/lib_with_version_number.so.28

If the name of the library was only,

/path/to/library/lib_without_version_number.so

I can use

-L/path/to/library/ -l_without_version_number

(because I don't wan't to have the complete library path when I run ldd command).

My question is: How to do the same with the version number?

Upvotes: 3

Views: 686

Answers (1)

Mike Kinghan
Mike Kinghan

Reputation: 61337

If you have an unavoidable need to link a library libfoo.a or libbar.so.x.y.z by exactly that name, rather than by following the usually wiser -lfoo convention, you can do so by using the -l: option instead, e.g.

-l:libfoo.a -l:libbar.so.x.y.z

This choice makes no difference to the behaviour of the -L option.

Upvotes: 4

Related Questions