Open source is a term for software published under a license that does not give any property rights to the developers. From the perspective of innovation economics open source is a puzzle. Individual users and firms are allowed to change the software according to one’s needs but are not allowed to raise any license fees. Contributors are not paid and do not hold patents or other property rights in the software but nonetheless they voluntarily spend much time and effort to produce software that everyone can use at no cost. Thus, the source code constitutes a public good in the classical sense. This paper considers how social approval, feedback from others in form of regard, respect, appreciation, admiration and esteem, affects individual’s willingness to contribute to a public good. Several authors suggest that individual contributors derive a private benefit from engaging in open source communities. Social approval provides a private benefit stemming from the public display of one’s ability and reliable feedback. If the gain from social approval outweighs the cost people will contribute to the development of open source software. It has to be sure, however, that the benefit of the rewards is concentrated on those, who give the rewards. Put bluntly, rewards lead to the provision of the public good if those who give rewards are the ones who receive rewards. In this paper we study an evolutionary model of a public good game with rewards played on a network. Giving rewards to contributors transforms the game but gives rise to a second-order dilemma. By allowing for coevolution of strategies and network structure the adaptive dynamics operate on both structure and strategy. Agents learn with whom to interact and how to act and can overcome the second-order dilemma. More specifically, the network represents social distance which changes as agents interact. Through the change in social distance agents learn (not necessarily consciously) with whom to interact, which we model using reinforcement dynamics. We consider different learning speeds and analyze their impact on the long-run frequency of contributions to the public good. We find that for certain parameter constellations a social institution, prescribing prosocial behavior and thus solving the second-order dilemma, can emerge from a population of selfish agents. Due to the dynamic structure of the network the institution has an endogenous punishment mechanism ensuring that defectors will be excluded from the benefits of the institution. Evolutionary models with local interactions on static networks have been explored analytically (see Eshel et al. (1998) for a circle network, Albin and Foley (2001) and Nowak and May (1993) for a two-dimensional lattice, and Watts (1999, chapter 8) for small-world networks). Dynamic networks have recently been discussed by Skyrms and Pemantle (2000), Alexander (2007) and Jun and Sethi (2009), and reinforcement learning has been studied by Brenner (2006) and Arthur (1991). We build on this literature by combining evolutionary games, dynamic networks and reinforcement learning.