  In this paper, we shall consider spherically symmetric spacetime solutions
describing the interior of stellar compact objects, in the context of
higher-order curvature theory of the f(R) type. We shall derive the non--vacuum
field equations of the higher-order curvature theory, without assuming any
specific form of the $\mathrm{f(R)}$ theory, specifying the analysis for a
spherically symmetric spacetime with two unknown functions. We obtain a system
of highly non-linear differential equations, which consists of four
differential equations with six unknown functions. To solve such a system, we
assume a specific form of metric potentials, using the Krori-Barua ansatz. We
successfully solve the system of differential equations, and we derive all the
components of the energy-momentum tensor. Moreover, we derive the non-trivial
general form of $\mathrm{f(R)}$ that may generate such solutions and calculate
the dynamic Ricci scalar of the anisotropic star. Accordingly, we calculate the
asymptotic form of the function $\mathrm{f(R)}$, which is a polynomial
function. We match the derived interior solution with the exterior one, which
was derived in \cite{Nashed:2019tuk}, with the latter also resulting in a
non-trivial form of the Ricci scalar. Notably but rather expected, the exterior
solution differs from the Schwarzschild one in the context of general
relativity. The matching procedure will eventually relate two constants with
the mass and radius of the compact stellar object. We list the necessary
conditions that any compact anisotropic star must satisfy and explain in detail
that our model bypasses all of these conditions for a special compact star
$\textit {Her X--1 }$, which has an estimated mass and radius \textit {(mass =
0.85 $\pm 0.15M_{\circledcirc}$\,\, and\, \,radius $= 8.1 \pm 0.41$km)}.
