While finding the primitive by parts, I got $0=2\sin(x) \cos(x)$. Is it the same as if I had a constant diference? I was trying to find the $\cos^2(x)$ by using only primitization(?) by parts, i.e., $\int u \,dv = uv-\int v \,du$.
When I tried with $dv = \cos(x)$ (with $dv=1\,dx$, I managed to do it), and after a second prim. by parts with $dv=\sin(x) \, dx$.
$$\int \cos^2(x) \,dx=2\sin(x)\cos(x)+\int \cos^2(x) \,dx$$
I've seen in some other posts similar problems (unfortunately I can't find them right now), and the answer to those is a short word: 'constant'. 
So we should view $\int f(x) \,dx=\{g(x)+c: g'(x)=f(x), c \in \mathbb{R}\}$ as a set including all the functions whose derivative is $f(x)$ and are distinguished only by the addition of a constant. 
!However, in my case I get a function of $x$, not a constant !
I've checked my calculations, and I don't find my mistake.
Any help would be appreciated.
Edit:
$\int \cos^2(x) \, dx = \cos(x)\sin(x)-\int \sin^2(x) \,dx=\cos(x)\sin(x) -( -\cos(x)\sin(x)-\int \cos(x) \cos(x) \, dx$
 A: You probably dropped a sign.  We start with $u=\cos x,\  dv = \cos x dx,\  v=\sin x,\  du=-\sin x dx$ and get $$\int \cos ^2 xdx=\cos x \sin x -\int \sin x(-\sin x dx)\\=\cos x \sin x +\int \sin^2 dx$$  Now if you try again with $u=\sin x,\  dv = \sin x dx,\  v=-\cos x,\  du=\cos x dx$ it all cancels out $$\cos x \sin x +\int \sin^2 dx=\cos x \sin x -\cos x \sin x + \int \cos^2 x dx$$  If you integrate by parts twice and in the second step you integrate the term you differentiated the first time, this is guaranteed to happen.
A: Here's how I would evaluate that integral by using integration by parts:
\begin{align}
\int \cos^2 x\,dx & = \int (\cos x) (\cos x\,dx) = \int u\,dv = uv - \int v\,du \\[10pt]
& = \cos x \sin x - \int (\sin x)(-\sin x\,dx) \\[10pt]
& = \cos x \sin x + \int\left( 1 - \cos^2 x \right) \,dx \\[10pt]
& = \cos x \sin x + x - \int \cos^2 x\,dx
\end{align}
So you have
$$
\int\cos^2x\,dx = \cos x\sin x + x - \int \cos^2 x\,dx.
$$
Adding the integral to both sides, you get
$$
2\int\cos^2 x\,dx = \cos x\sin x + x + \text{constant}.
$$
Dividing both sides by $2$, you get
$$
\int \cos^2 x\, dx = \frac 1 2 (\cos x \sin x + x) + \text{constant}.
$$
