  We follow the formation and evolution of bars in N-body simulations of disc
galaxies with gas and/or a triaxial halo. We find that both the relative gas
fraction and the halo shape play a major role in the formation and evolution of
the bar. In gas-rich simulations, the disc stays near-axisymmetric much longer
than in gas-poor ones, and, when the bar starts growing, it does so at a much
slower rate. Due to these two effects combined, large-scale bars form much
later in gas-rich than in gas-poor discs. This can explain the observation that
bars are in place earlier in massive red disc galaxies than in blue spirals. We
also find that the morphological characteristics in the bar region are strongly
influenced by the gas fraction. In particular, the bar at the end of the
simulation is much weaker in gas-rich cases. In no case did we witness bar
destruction.
  Halo triaxiality has a dual influence on bar strength. In the very early
stages of the simulation it induces bar formation to start earlier. On the
other hand, during the later, secular evolution phase, triaxial haloes lead to
considerably less increase of the bar strength than spherical ones. The shape
of the halo evolves considerably with time. The inner halo parts may become
more elongated, or more spherical, depending on the bar strength. The main body
of initially triaxial haloes evolves towards sphericity, but in initially
strongly triaxial cases it stops well short of becoming spherical. Part of the
angular momentum absorbed by the halo generates considerable rotation of the
halo particles that stay located relatively near the disc for long periods of
time. Another part generates halo bulk rotation, which, contrary to that of the
bar, increases with time but stays small.
