Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trouble with build #4

Open
Breluce opened this issue Apr 5, 2022 · 6 comments
Open

trouble with build #4

Breluce opened this issue Apr 5, 2022 · 6 comments

Comments

@Breluce
Copy link

Breluce commented Apr 5, 2022

Hi, I am trying to install this on a Mac but keep failing to build the -lkcorrect library. I follow all of the steps for setting the KCORRECT_DIR and library paths to the extracted tar file from kcorrect.org. I use the instructions included in the INSTALL document up through the kevilmake -k all command. I do get errors pertaining to missing IDL files, but I'm only installing for python so I disregard those.

However, when I run the python setup.py build command from the master file I end up with the following error output:

bash-3.2$ python setup.py build running build running build_py running build_ext building '_kcorrect' extension gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/bflucero/opt/anaconda3/include -arch x86_64 -I/Users/bflucero/opt/anaconda3/include -arch x86_64 -I/Users/bflucero/Desktop/research/kcorrect/include -I/Users/bflucero/opt/anaconda3/lib/python3.8/site-packages/numpy/core/include -I/Users/bflucero/opt/anaconda3/include/python3.8 -c src/_kcorrectmodule.c -o build/temp.macosx-10.9-x86_64-3.8/src/_kcorrectmodule.o In file included from src/_kcorrectmodule.c:10: In file included from /Users/bflucero/opt/anaconda3/lib/python3.8/site-packages/numpy/core/include/numpy/npy_3kcompat.h:21: In file included from /Users/bflucero/opt/anaconda3/lib/python3.8/site-packages/numpy/core/include/numpy/ndarrayobject.h:12: In file included from /Users/bflucero/opt/anaconda3/lib/python3.8/site-packages/numpy/core/include/numpy/ndarraytypes.h:1944: /Users/bflucero/opt/anaconda3/lib/python3.8/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-W#warnings] #warning "Using deprecated NumPy API, disable it with " \ ^ 1 warning generated. gcc -bundle -undefined dynamic_lookup -L/Users/bflucero/opt/anaconda3/lib -arch x86_64 -L/Users/bflucero/opt/anaconda3/lib -arch x86_64 -arch x86_64 build/temp.macosx-10.9-x86_64-3.8/src/_kcorrectmodule.o -L/Users/bflucero/Desktop/research/kcorrect/lib -lkcorrect -lm -o build/lib.macosx-10.9-x86_64-3.8/_kcorrect.cpython-38-darwin.so ld: library not found for -lkcorrect clang: error: linker command failed with exit code 1 (use -v to see invocation) error: command 'gcc' failed with exit status 1

I have attempted to modify the kevilmake script and uncomment the lines needed for Mac OS X but still no luck. If you could offer any guidance I'd really appreciate it!

@nirinA
Copy link
Owner

nirinA commented Apr 6, 2022

hi,
the error states that the library libkcorrect.so is not found at the following location /Users/bflucero/Desktop/research/kcorrect/lib
if you have successfully built it, it should be located at $KCORRECT_DIR/lib ; check if that is the case.

@Breluce
Copy link
Author

Breluce commented Apr 6, 2022

right, the pathname up to the extracted kcorrect tar is what i set the $KCORRECT_DIR path as. and the library $KCORRECT_DIR/lib folder contents are only 'kcorrect.py', 'Makefile', and the README after running the kevilmake command. so consequently, the setup.py isn't working correctly. is there something outside of the INSTALL file steps that i have to include before trying to build ?

@nirinA
Copy link
Owner

nirinA commented Apr 6, 2022

maybe, your OS installed the library somewhere else? i can't help much here as i know nothing about Mac OS.

to build kcorrect_python, the setup.py looks for kcorrect.h in $KCORRECT_DIR/include and libkcorrect.so in $KCORRECT_DIR/lib.
is there some error that outputs when you run kevimake?

@nirinA
Copy link
Owner

nirinA commented Apr 7, 2022

you may fill an issue at:

https://github.com/blanton144/kcorrect

if you really have trouble to build libkcorrect.so

@lrhunt
Copy link

lrhunt commented Apr 23, 2022

@Breluce I had the same issue and I just figure it out! I've copied and pasted all of my instructions here. This might not be the only way to do it, but it's what I've figured out. If you have any questions on this, feel free to reach out.

Installing K-Correct on new Mac

  1. Download k-correct version 4.3
    1. http://kcorrect.org/
  2. Open terminal in Rosetta?
    • Go to Finder > Applications and find your Terminal (this can also be other terminal app, like iTerm in my case)
    • Right-Click the App and Duplicate it and rename it "Terminal i386"
    • Right-Click "Terminal i386" > Get Info > Enable Open using Rosetta
    • Click to Open the Terminal, type arch to verify it says i386 now.
    • Right-Click the Terminal i386 in your Dock and click "Keep in Dock" for future use.
  3. Install homebrew for x86_64
  4. Install gcc@7 (I know this one works, newer versions have problems with declaring functions dynamically or something like that. I don’t remember. Newer version of gcc might work, but 11 will not. If you can find a way to make gcc ignore that error you might also be able to get it to work)
    • /usr/local/bin/brew install gcc@7
  5. Temporarily change the path to your new C compilers (probably don’t want to make this permanent. Just make sure this happens in your active window)
    • export CC=/usr/local/bin/gcc
    • export CXX=/usr/local/bin/g++
  6. Change .zsh file to include
    • setenv KCORRECT_DIR /usr/local/kcorrect
    • setenv PATH $KCORRECT_DIR/bin:$PATH
    • setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:$KCORRECT_DIR/lib
    • setenv IDL_PATH ${IDL_PATH}:+$KCORRECT_DIR/pro
  7. Follow note from Russel Jurek
    • kcorrect: kcorrect installs using a `kevilmake' script in the installation's bin directory. I had to tweak the kevilmake script in order to get it to compile. I changed the F77 compiler from g77 to gfortan, which negates the need to use the -lcc_dynamic compiler flag. Delete all mention of -lcc_dynamic in the compiler flags, otherwise you'll get errors and the library won't build. Don't forget to follow the instructions and comment in both sets of lines required to compile the kcorrect C library. Note that I've only confirmed that this will allow me to compile/create the kcorrect C library.
  8. There are two lines below that which the kevilemake script says need to be uncommented. You need to uncomment them, and edit them.
    • The two lines in the original script are
      • LD=libtool
      • X_LD_FLAGS="-dynamic -L/usr/lib -lc -lcc_dynamic"
    • Change them to
      • LD=CC
      • X_LD_FLAGS=" -dynamiclib -L/usr/lib -lc"
  9. Then go to KCORRECT_DIR and type “kevilmake -k”

Install kcorrect python

  1. Download kcorrect python
    1. https://github.com/nirinA/kcorrect_python
  2. Since you needed to compile in rosetta, you need your python architecture to be X86
    • If you use anaconda you can use the below command to install python 2.7
    • CONDA_SUBDIR=osx-64 conda create -n kcorrect python=3.8
    • This will create a new environment called correct
    • Use conda activate kcorrect to get into this environment
  3. Go into the kcorrect-python directory and type python setup.py build
  4. Type python setup.py install

@nirinA
Copy link
Owner

nirinA commented Apr 23, 2022

@lrhunt thanks for sharing.
i think i will put a note somewhere to point to this for mac users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants