Linked libraries

In our project we have multiple contracts that use same libraries imported from OZ (SafeMath, SafeERC20..). At deploy I try to deploy the library first and then link the library to the contracts but due tot the fact that libraries have only internal function and, as far as I understand, if functions are internal the library can't be linked and the code is just injected in the contract.

Is there any solution to this ?

There's no need to fix anything. If a library only has internal functions, it does not need to be deployed. These functions cannot be called externally anyway and all of your contracts that call them internally have them compiled into their own bytecode.

Ok, I got that, but why to have SafeMath library for example and redeploy every time you deploy a contract?

I don't understand the question. SafeMath only has internal functions so you do not have to deploy it at all.

By the way, if you are using Solidity 0.8.x, overflow checks are already built into the language so you do not have to use SafeMath at all.