How to compile C++、C source on M1max?

Compatibilty of m1max have troubled me hundreds of hours, please help, I am doing some urgent projects.

1、which gcc to install? show me the code when I do it, some error happens, gcc(version 4.2.1 installed by brew) cannot compile some source, such as "ecos". Moreover, I cannot compile many sources directly by python3 setup.py install (without accelerate) How to config the gcc? which version to use on m1max

2、sometimes I can compile source by brew. but extremely unconvenient, because I need to install packages on vitual environment (e.g. conda env)other than on base path. what should I do? can I install brew on vitual environment? or just use brew to build the source, then I install by pip on vitual env? or can I config the brew to install on only vitual environment? Just show me the code

3、to compile, do I also need to install g++? witch version

show me the code

How to compile C++、C source on M1max?
 
 
Q