If you want to avoid a Google penalty, the safest way to build links is through white hat link building techniques.
These kinds of links are highly regarded by Google. Building links in accordance with the search engine’s standards will be rewarded by the algorithm.