In this paper, we consider the fluid dynamics of a flapping wing interacting with a boundary layer developed at a no-slip flat wall. Direct numerical simulations are carried out via implementing the non-iterative immersed boundary-lattice Boltzmann method, over a Reynolds number range of 10≤Re≤1000, for a fixed Strouhal number of St = 0.3 and for a given symmetric plunging and pitching flapping motion. The interactions between the wing and the boundary layer are modulated by varying the mean distance of the wing to the wall H0. The results indicate that the presence of the boundary layer at the wall amplifies the fluctuations in both lift and drag due to the boundary layer separation, in contrast to the pure ground effect. This separation also leads to the decrease in both average lift and average drag over one flapping cycle when H0 is low. When it comes to the flow patterns in the wake, it generally gets more complex for a low H0 and/or a high Re. Secondary vortices can be observed for Re≥500 in the present configuration, which either evolve by themselves or interact with the vortices in the wake while being convected downstream and dissipated via viscosity. In the end, a dynamic mode decomposition analysis is performed to explore further the flow structures in the wake. One observes the sheltering effect of the boundary layer that the vortices in the wake are prevented from penetrating the boundary layer, while this effect will not hold if the vortex intensity is sufficiently high, such as the low order mode of the case for Re≥1000 in this study.