In this paper, for a wireless communication system with energy harvesting and rateless error correction codes, the joint optimization of transmit power, modulation scheme and code rate to maximize the long-term average achievable transmission rate under the constraint of available energy is studied. The method is given first to determine the codeword length (or code rate) for a signal-to-noise ratio (SNR) under the constraint of a pre-defined decoding error probability. Then the formula of the actual transmission rate is deduced with a specific modulation and code rate, and the optimization problem to maximize the long-term average actual transmission rate is constructed under the constraints of available harvested energy and the decoding complexity of the rateless code. Since energy harvesting and channel fading are both stochastic processes, the optimization problem is difficult to solve. By using the Lyapunov optimization framework, the original long-term optimization problem is transformed into a per time slot one. Then an efficient numerical method is proposed to obtain the solution to the problem. The proposed algorithm is verified by simulation, and the results show that the proposed algorithm can achieve a higher average actual transmission rate than the comparison algorithms aiming at optimizing the channel capacity.