The simple answer is that it depends on a lot of factors. For starters, it would depend on the nature of the economy of the country. A country that is dependent on a mineral like oil or gold for most of its income tends to benefit from high prices of such minerals, but the consumers of such minerals are affected adversely. For a consumer of oil, high oil prices have a negative impact on the economy as it pushes up the cost of various factors of production, raises prices and also makes the country less competitive in the global market. Higher factor prices also impact profitability of industries negatively as companies are not always able to pass on the higher costs to the consumers completely. Lower profitability in turn has an impact on share prices of such companies assuming they are listed. Gold is usually seen as a hedge against poor economic performance and its prices tend to move negatively in relation to share prices, although this relationship may not hold true at all times. When markets are doing well, people tend to invest more in capital markets and they generally move away from gold during such periods. On the other hand, when markets are not doing well, gold is seen as a safe haven and investors flock to it.
These are some examples illustrating the relationship between these variables. In reality, it is a little more complex due to the interaction between a large number of variables including those listed above. I hope this helps.
Both the commodities Gold and Crude oil have positive relation with each other and almost follow the same pattern (ups and downs). However, their is a negative correlation between gold prices and stock markets price indices. But this negative correlation dose not persist over the long-run. If you decomposed both time series (gold prices and Stock market indices) with the help of wavelets techniques at different investment horizons you can see that the this relationship is changing at various investment horizons. Overall, gold has weak correlation with stock markets prices indices.
While, the crude oil has weak positive correlation with stock markets prices indices. on the other hand gold has strong positive correlation with dollar depreciation if dollars loosing its value it would have a positive effect on gold prices. which makes gold investment as an perfect hedge against dollar movement.
See, Baur and Lucey, 2010; Baur and Mcdormmt, 2010, Juan C Robredo, 2014.