fatal error: 'stdio.h' file not found when using CPPPotential

408 views
Skip to first unread message

Sun-Ting Tsai

unread,
Jul 26, 2022, 4:31:10 PM7/26/22
to hoomd-users
Dear all,

I am writing pair potential for HPMC and get this error:

In file included from code.cc:2: /Users/guest/opt/miniconda3/envs/patchy-mi/bin/../include/c++/v1/stdio.h:107:15: fatal error: 'stdio.h' file not found #include_next <stdio.h> ^~~~~~~~~ Error generating code. 1 error generated.

But I did find `/Users/guest/opt/miniconda3/envs/patchy-mi/bin/../include/c++/v1/stdio.h` in my system. 

There currently isn't much explanation in the HOOMD tutorial. Could anyone tell me why I got this error and whether I used the CPPPotential correctly (The potential I'm using is a direct copy from the tutorial)?

The attached files are the gsd file and the minimal test code.

Regards,
Sun-Ting
lattice.gsd
pair.py
randomize.ipynb

Tim Moore

unread,
Jul 26, 2022, 5:59:24 PM7/26/22
to hoomd...@googlegroups.com
This is not an error with the script, but rather the installation. How did you install HOOMD? And what version it is?

Tim

--
You received this message because you are subscribed to the Google Groups "hoomd-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hoomd-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hoomd-users/c6cc25a7-8a14-4adf-8529-f83826a65cc5n%40googlegroups.com.
--
Tim Moore

Sun-Ting Tsai

unread,
Jul 26, 2022, 6:29:40 PM7/26/22
to hoomd-users
Hi Tim,

The HOOMD version is 3.2.0. This is how I installed HOOMD and all the other required packages to the environment:

conda create -n patchy-mi 
conda activate patchy-mi 
conda install mamba -c conda-forge 
mamba install python numpy matplotlib jupyterlab notebook -c conda-forge 
mamba install pybind11 eigen cmake qhull pytest -c conda-forge 
pip install PySide6 
 
mamba install hoomd freud fresnel -c conda-forge 
mamba install signac signac-flow -c conda-forge 
mamba install gsd -c conda-forge 
mamba install coxeter -c conda-forge 
 
mamba install scikit-learn -c intel 
mamba install pytorch torchvision -c pytorch 
mamba install ipywidgets -c conda-forge 
conda deactivate

Best,
ST

Eric Jankowski

unread,
Jul 26, 2022, 6:45:53 PM7/26/22
to hoomd...@googlegroups.com
Try without conda deactivate, which undoes the environment variable setting that may be leading to this issue.

Sun-Ting Tsai

unread,
Jul 26, 2022, 7:22:18 PM7/26/22
to hoomd-users
Hi 

My notebook is run under the environment and without `conda deactivate`. I will also try to re-install HOOMD.

ST

Sun-Ting Tsai

unread,
Jul 27, 2022, 12:41:03 AM7/27/22
to hoomd-users
A quick update,

I have re-installed following the same installation step but still got the same error message. I've also run it on a different pc with the same installation step and failed too.
Now I did find that the code doesn't show error on cluster, specifically on greatlakes with sif image, so it could be the installation problem. However, I will need to do more tests to know which step in the installation is wrong. If you know how I can fix it please let me know, thanks!

Best,
ST

Trung Nguyen

unread,
Jul 27, 2022, 12:55:02 AM7/27/22
to hoomd...@googlegroups.com
Hi ST,

did the errors only show up with the builds with MacOS? Although you have /Users/guest/opt/miniconda3/envs/patchy-mi/bin/../include/c++/v1/stdio.h, it is the line 107 in that file with #include_next that causes the error. 

Maybe some discussion and comments on stackoverflow would be relevant to your case: https://stackoverflow.com/questions/51761599/cannot-find-stdio-h

Cheers,
-Trung



Sun-Ting Tsai

unread,
Jul 27, 2022, 1:09:41 PM7/27/22
to hoomd-users
Thanks Trung,

so I looked into my system and did find that there is no /usr/include. However, the stackoverflow method doesn't work on my system because I also don't have `Packages/macOS_SDK_headers_for_macOS_10.14.pkg` in `/Library/Developer/CommandLineTools`.

On the other hand, the `usr/include` folder does exist in `/Library/Developer/CommandLineTools`. Unfortunately, I don't know how to either build a `/usr/include` or change the installation of HOOMD to look for `/Library/Developer/CommandLineTools/usr/include` instead of `/usr/include`.

By the way, I am testing on Apple M1 systems, MacOS 12.4. Really thanks for all of your help, at least I can test my code on Linux.

Sun-Ting

Sun-Ting Tsai

unread,
Jul 27, 2022, 1:37:45 PM7/27/22
to hoomd-users
Hi all,

not sure if this is the right way to fix it. I just found that I can add a symbolic link to `/usr/local/include`. In short, this is what I did:

`sudo ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include /usr/local`

Then the error disappears. I will need some tests to make sure the program works properly though.

ST

Joshua Anderson

unread,
Aug 1, 2022, 8:05:51 AM8/1/22
to hoomd...@googlegroups.com
Sun-Ting,

No, creating symlinks is not an acceptable solution. HOOMD's conda-forge build should provide the correct dependencies so that it finds the needed header files with the correct ABI in your conda environment. We need to rebuild the conda-forge package to fix this problem.

I reproduced the behavior you describe with these steps:
1. Install mambaforge in a clean directory.
2. $ ~/mambaforge/bin/mamba install hoomd pytest
3. $ ~/mambaforge/bin/pytest --pyargs hoomd.hpmc.pytest

The full error message provides helpful information (below). The `-internal-isystem /Users/joaander/mambaforge/lib/clang/14.0.6/include` is where stdio.h should be found. In my installation, mambaforge/lib/clang/14.0.6 doesn't exist. There is a /mambaforge/lib/clang/14.0.4/include, but it only contains omp.h. HOOMD *should* be using clang 13 instead of 14 and pulling the include files from mambaforge/lib/clang/13.0.1 which is present on my system and contains stdio.h

Tim and I need to look at the version pinnings in our conda-forge recipe and correct them to install clang, libclang, and libllvm versions. Issue: https://github.com/conda-forge/hoomd-feedstock/issues/67

E           RuntimeError: Error compiling JIT code:
E           
E                                   #include <stdio.h>
E                                   #include "hoomd/HOOMDMath.h"
E                                   #include "hoomd/VectorMath.h"
E           
E                                   // param_array (singlet class) or param_array_isotropic
E                                   // and param_array_constituent (union class) are
E                                   // allocated by the library
E                                   float *param_array;
E                                   
E           
E                                   using namespace hoomd;
E           
E                                   extern "C"
E                                   {
E                                   float eval(const vec3<float>& r_ij,
E                                       unsigned int type_i,
E                                       const quat<float>& q_i,
E                                       float d_i,
E                                       float charge_i,
E                                       unsigned int type_j,
E                                       const quat<float>& q_j,
E                                       float d_j,
E                                       float charge_j)
E                                       {
E                                   return -1;
E                                       }
E                                   }
E                                   
E           Compilation arguments:
E           -cc1
E           -triple
E           arm64-apple-macosx12.0.0
E           -Wundef-prefix=TARGET_OS_
E           -Werror=undef-prefix
E           -Wdeprecated-objc-isa-usage
E           -Werror=deprecated-objc-isa-usage
E           -emit-llvm
E           -disable-free
E           -clear-ast-before-backend
E           -disable-llvm-verifier
E           -discard-value-names
E           -main-file-name
E           _hoomd_llvm_code.cc
E           -mrelocation-model
E           pic
E           -pic-level
E           2
E           -mframe-pointer=non-leaf
E           -ffp-contract=on
E           -fno-rounding-math
E           -funwind-tables=2
E           -fcompatibility-qualified-id-block-type-checking
E           -fvisibility-inlines-hidden-static-local-var
E           -target-cpu
E           apple-m1
E           -target-feature
E           +v8.5a
E           -target-feature
E           +fp-armv8
E           -target-feature
E           +neon
E           -target-feature
E           +crc
E           -target-feature
E           +crypto
E           -target-feature
E           +dotprod
E           -target-feature
E           +fp16fml
E           -target-feature
E           +ras
E           -target-feature
E           +lse
E           -target-feature
E           +rdm
E           -target-feature
E           +rcpc
E           -target-feature
E           +zcm
E           -target-feature
E           +zcz
E           -target-feature
E           +fullfp16
E           -target-feature
E           +sha2
E           -target-feature
E           +aes
E           -target-abi
E           darwinpcs
E           -fallow-half-arguments-and-returns
E           -mllvm
E           -treat-scalable-fixed-error-as-warning
E           -debugger-tuning=lldb
E           -target-linker-version
E           609
E           -fcoverage-compilation-dir=/Users/joaander
E           -resource-dir
E           /Users/joaander/mambaforge/lib/clang/14.0.6
E           -D
E           HOOMD_LLVMJIT_BUILD
E           -I
E           /Users/joaander/mambaforge/lib/python3.9/site-packages/hoomd/include
E           -stdlib=libc++
E           -internal-isystem
E           /Users/joaander/mambaforge/bin/../include/c++/v1
E           -internal-isystem
E           /usr/local/include
E           -internal-isystem
E           /Users/joaander/mambaforge/lib/clang/14.0.6/include
E           -internal-externc-isystem
E           /usr/include
E           -O3
E           --std=c++14
E           -fdeprecated-macro
E           -fdebug-compilation-dir=/Users/joaander
E           -ferror-limit
E           19
E           -stack-protector
E           1
E           -fblocks
E           -fencode-extended-block-signature
E           -fregister-global-dtors-with-atexit
E           -fgnuc-version=4.2.1
E           -fcxx-exceptions
E           -fexceptions
E           -fmax-type-align=16
E           -vectorize-loops
E           -vectorize-slp
E           -D__GCC_HAVE_DWARF2_CFI_ASM=1
E           -o
E           _hoomd_llvm_code.ll
E           -x
E           c++
E           _hoomd_llvm_code.cc
E           
E           In file included from code.cc:2:
E           /Users/joaander/mambaforge/bin/../include/c++/v1/stdio.h:107:15: fatal error: 'stdio.h' file not found
E           #include_next <stdio.h>
E                         ^~~~~~~~~
E           Error generating code.
E           1 error generated.

------
Joshua A. Anderson, Ph.D.
Research Area Specialist, Chemical Engineering, University of Michigan

Joshua Anderson

unread,
Aug 8, 2022, 11:26:45 AM8/8/22
to hoomd...@googlegroups.com
Sun-Ting,

The *_2 builds (just posted) solve this problem:

hoomd                          3.3.0 cpu_py310hb920e00_2  conda-forge         
hoomd                          3.3.0 cpu_py38h49edaf1_2  conda-forge         
hoomd                          3.3.0 cpu_py39hb778b30_2  conda-forge

However, you must also install the `compilers` package. Without the `compilers` package, you will get the same error. Due to technical limitations in conda-forge, I cannot make `compilers` install automatically with hoomd. I will document this in the next release.

Note to others reading this: The `compilers` package is required on Mac only, not on Linux.

`$ mamba install hoomd compilers`

------
Joshua A. Anderson, Ph.D.
Research Area Specialist, Chemical Engineering, University of Michigan

Sun-Ting Tsai

unread,
Aug 8, 2022, 11:30:15 AM8/8/22
to hoomd-users
Got it. Thanks, Joshua!

Sun-Ting

Reply all
Reply to author
Forward
0 new messages