dtamayo / reboundx

A library for adding additional forces to the REBOUND N-body integration package
GNU General Public License v3.0
80 stars 60 forks source link

Errors compiling C examples #67

Closed sabaronett closed 3 years ago

sabaronett commented 3 years ago

Not sure if it's related, but I encounter errors when compiling problem.c for any of the C examples/*; I'm able to run ./rebound only after a second make in a row outputs the binary; see make_errors.txt.

Originally posted by @sabaronett in https://github.com/dtamayo/reboundx/issues/63#issuecomment-865401885

sabaronett commented 3 years ago

From @hannorein (https://github.com/dtamayo/reboundx/issues/63#issuecomment-865410915)

derivatives.o: file not recognized: File truncated

That's a strange error. And it only shows up at the linking stage. I do not know what that could mean. ...

sabaronett commented 3 years ago

Updated stdout/stderr from compile attempt w/ reboundx 3.4.0, comp_err.txt.

dtamayo commented 3 years ago

hm, thanks for this bug report! I can't reproduce this locally. It makes a difference for linking etc. whether you install REBOUND and REBOUNDx from a local directory you cloned from GitHub (e.g., pip install -e .), or whether you've installed it from PyPI (pip install rebound). Which are you using for both REBOUND and REBOUNDx?

dtamayo commented 3 years ago

I guess if you're running the REBOUNDx C examples you have the directory cloned, but what about REBOUND?

dtamayo commented 3 years ago

It seems like you don't have the default setup REBOUNDx expects in order to find REBOUND, I.e., with the rebound and reboundx folders in the same directory. Have you set the REB_DIR environment variable? See the top of

https://reboundx.readthedocs.io/en/latest/c_quickstart.html#c-quickstart

sabaronett commented 3 years ago

Hmm, I didn't think about that. The PyPI versions of REBOUND/REBOUNDx are installed /home/stanley/miniconda3/envs/rebx-3.4.0, but I don't think either of those get called when I run/compile the C examples.

I've also cloned the GH repos of REBOUND to ~/github/hannorein/rebound and REBOUNDx to ~/github/dtamayo/reboundx, and have the following in my .bashrc:

# Separate REBOUND/REBOUNDx Directories
export REB_DIR=~/github/hannorein/rebound

The latter path gets invoked when I try to compile.

dtamayo commented 3 years ago

OK. Does it work for you if you do

make clean && make

(I.e. don't use -j option)

hannorein commented 3 years ago

It could be that the corrupted file error occurs because different files were compiled with different compilers.

dtamayo commented 3 years ago

I don't see the derivatives.o file not recognized error in his txt file. I'm not sure if it's the same issue (?)

dtamayo commented 3 years ago

I can reproduce your error if I use -j. It might just be that we haven't been clever enough with the makefile to tell it how to to compile in parallel and it's trying to compile reboundx without first compiling rebound

sabaronett commented 3 years ago

Ha, make clean && make works. I think you hit the bullseye there. I've developed a bad habit of using make -j for all the work in Athena++ I've been doing, where compilation can take 5+ minutes.

Thanks for the tip! I'll close the issue.

dtamayo commented 3 years ago

Thanks Stanley. Yeah it's fast enough that we've never thought carefully about how to parallelize compilation. I can imagine that's important for Athena++! I'm excited to hear about your work with that

sabaronett commented 3 years ago

I'll remember to share with you whatever publication(s) come out of that work when the time comes!