marti-vidal-i / UVMultiFit

Advanced visibility modelfitting for NRAO's CASA package
Other
0 stars 1 forks source link

clang error when running setup #1

Open Tang-SL opened 2 weeks ago

Tang-SL commented 2 weeks ago

Hello,

I am following the documentation to install UVMultiFit on my MacOS 14.0 laptop. The problem happens when I run python setup.py build_ext --inplace

The full error messages follow: /Users/tang/opt/anaconda3/envs/pypeit/lib/python3.10/site-packages/numpy/core/include/numpy/__multiarray_api.h:1483:1: warning: unused function '_import_array' [-Wunused-function] _import_array(void) ^ 1 warning generated. g++ -bundle -undefined dynamic_lookup -Wl,-rpath,/Users/tang/opt/anaconda3/envs/pypeit/lib -L/Users/tang/opt/anaconda3/envs/pypeit/lib -Wl,-rpath,/Users/tang/opt/anaconda3/envs/pypeit/lib -L/Users/tang/opt/anaconda3/envs/pypeit/lib build/temp.macosx-10.9-x86_64-cpython-310/_QuinnFringe.o build/temp.macosx-10.9-x86_64-cpython-310/_uvmultimodel.o -lgsl -lgslcblas -lfftw3 -o build/lib.macosx-10.9-x86_64-cpython-310/_uvmultimodel.cpython-310-darwin.so -Xlinker -export-dynamic ld: unknown options: -export-dynamic clang: error: linker command failed with exit code 1 (use -v to see invocation) error: command '/usr/bin/g++' failed with exit code 1

This seems to be a problem with gcc, but I am not familiar with C++, I'd appreciate your help.

Best, Shenli

diwen2 commented 2 days ago

I got around this problem by using gcc installed by MacPorts. You are using the compiler installed with Anaconda. The documentation (https://mural.uv.es/imarvi/docums/uvmultifit/#installation) asks you to install gsl with MacPorts, so installing everything with MacPorts is easier. sudo port install gcc14 In your ~/.bash_profile, add the following lines to use gcc14 instead of clang.

alias gcc='gcc-mp-14'
alias g++='g++-mp-14'
Tang-SL commented 2 days ago

Hi diwen2,

Thanks for this, I have reprocessed the steps and installed everyting with MacPorts and set the alias. But I am still getting the same error. I am not sure how can I get rid of clang?

Screenshot 2024-10-07 at 13 02 56
diwen2 commented 2 days ago

This means the alias did not work. After adding the alias to ~/.bash_profile, reload your bash profile by source ~/.bash_profile Then check your gcc version gcc --version You should then see something like gcc-mp-14 (MacPorts gcc14 14.2.0_1+stdlib_flag) 14.2.0 Copyright (C) 2024 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. If you still see clang for your gcc, you can define a symbolic link for gcc and g++ to link to your MacPorts gcc-mp-14 and g++-mp-14. sudo ln -s source_file symbolic_link

Tang-SL commented 2 days ago

Now I have made it link to gcc after defining the symbolic link. However, the compilation still failed, with an error saying that a file is missing.

Screenshot 2024-10-07 at 14 04 27
diwen2 commented 2 days ago

sudo port install fftw-3

Tang-SL commented 2 days ago

After installing fftw-3, I added include_dirs=['/opt/local/include'] and library_dirs=['/opt/local/lib'] in Extension of the setup.py to help it to find it. Now I am getting another error saying that

ld: unknown option: -export-dynamic
collect2: error: ld returned 1 exit status

I tried to remove -export-dynamic from the extra_link_args of EXtension in the setup file, then I get a different error saying that

g++: error: missing argument to '-Xlinker'

Screenshot 2024-10-07 at 14 38 41
diwen2 commented 2 days ago

You don't have to remove -export-dynamic. I kept it and it worked. The problem is that your installed compiler does not support x86 architecture. You said you had MacOS 14.0. I was assuming your laptop was with Apple Silicon. Is your laptop using an Intel processor instead? I have not tested installation with MacPorts on an Intel Mac. You would need gcc for your machine's architecture, which should be achievable with MacPorts, too. However, I don't have an Intel Mac to test the installation. Hopefully the author of the repository can help you.

Tang-SL commented 2 days ago

No, it's not an Intel one, it's with Apple M2 Pro.

diwen2 commented 2 days ago

So what is the error when putting back '-export-dynamic' like in the original setup.py?

Tang-SL commented 2 days ago

It says: ld: unknown option: -export-dynamic collect2: error: ld returned 1 exit status

The full error message is attached as a screenshot in my above comment.

diwen2 commented 2 days ago

I cannot reproduce your error. I don't know how exactly you added include_dirs=['/opt/local/include']and library_dirs=['/opt/local/lib']. I did not need those. I only modified the setup.py file on line 19 to include_gsl_dir = "/opt/local/include". Are you sure you are using gcc from MacPorts? The alias worked for me. I don't know if your symbolic link is set up correctly. Using the alias for gcc and g++, I have the following. which gcc-mp-14 /opt/local/bin/gcc-mp-14 which ld /opt/local/bin/ld gcc --version gcc-mp-14 (MacPorts gcc14 14.2.0_1+stdlib_flag) 14.2.0

Tang-SL commented 1 day ago

Yes, my outputs are exactly the same as yours.

Screenshot 2024-10-07 at 17 41 43