Intel® MPI Library
Get help with building, analyzing, optimizing, and scaling high-performance computing (HPC) applications.
2226 Discussions

Fatal error: mpi.h: no such file or directory

MaxAmer
Novice
8,050 Views

Hello all,

I have just installed the oneAPI basic and HPC toolkits for compiling some parallelised cpp code.

 

I have added the "mpi/<version>/bin" and the "mpi/<version>/include" routes to the path, however when I try to compile the code with make using the mpicxx compiler I get the error mentioned in the subject:

 

Fatal error: mpi.h: no such file or directory

#include "mpi.h"  (inside one of the .cpp files of the code)

compilation terminated

 

I am not very used to compiling cpp code, and it is my first time using intel compilers, so this might be a very basic and easy to solve issue but I have no idea how to approach it.

Any insight is appreciated, thank you!

 

Max.

 

 

Labels (1)
0 Kudos
1 Solution
MaxAmer
Novice
7,986 Views

Update!

I had mistakenly assumed that setting the environment variables with ". /opt/intel/oneapi/setvars.sh" was all good and done, but I did not remember that the environment must be reloaded each session.

So what I did is source the setvars.h to the bashrc so I don't have to load it each time and now it compiled without issues.

Happy to have solved it by myself even though this is probably a very basic mistake!

 

View solution in original post

0 Kudos
4 Replies
ShivaniK_Intel
Moderator
8,012 Views

Hi,

 

Thanks for posting in the Intel forum.

 

Could you please provide us with the details of the OS, and output of lscpu command?

 

Let us know the Intel mpi version you have been using by running the below command.

 

mpirun --version

 

Could you also please provide us with the command line you have been using to compile the code?

 

Thanks & Regards

Shivani


0 Kudos
MaxAmer
Novice
8,005 Views

Hi Shivani,

 

- OS is Ubuntu 22.04.2 LTS

- lscpu output:

Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 46 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 32
On-line CPU(s) list: 0-31
Vendor ID: GenuineIntel
Model name: 13th Gen Intel(R) Core(TM) i9-13900KS
CPU family: 6
Model: 183
Thread(s) per core: 2
Core(s) per socket: 24
Socket(s): 1
Stepping: 1
CPU max MHz: 6000,0000
CPU min MHz: 800,0000
BogoMIPS: 6374.40
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni p
clmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow v
nmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb intel_pt sha_ni xsaveopt xsavec xgetbv1 xsaves split_lock_detect avx_vnni dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp hwp_pkg
_req hfi umip pku ospke waitpkg gfni vaes vpclmulqdq tme rdpid movdiri movdir64b fsrm md_clear serialize pconfig arch_lbr ibt flush_l1d arch_capabilities
Virtualization features:
Virtualization: VT-x
Caches (sum of all):
L1d: 896 KiB (24 instances)
L1i: 1,3 MiB (24 instances)
L2: 32 MiB (12 instances)
L3: 36 MiB (1 instance)
NUMA:
NUMA node(s): 1
NUMA node0 CPU(s): 0-31
Vulnerabilities:
Itlb multihit: Not affected
L1tf: Not affected
Mds: Not affected
Meltdown: Not affected
Mmio stale data: Not affected
Retbleed: Not affected
Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl
Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Spectre v2: Mitigation; Enhanced IBRS, IBPB conditional, RSB filling, PBRSB-eIBRS SW sequence
Srbds: Not affected
Tsx async abort: Not affected

 

- mpirun --version output:

Intel(R) MPI Library for Linux* OS, Version 2021.9 Build 20230307 (id: d82b3071db)
Copyright 2003-2023, Intel Corporation.

 

- The code I'm using is an open-source code called Sparta, following the user guide I compile it with Make, using a Makefile to specify the compiler. It compiles a bunch of files but to summarise, first, it compiles each file individually with:

mpicxx -O3 -DSPARTA_GZIP -DSPARTA_BIGBIG -c ../write_grid.cpp

mpicxx -O3 -DSPARTA_GZIP -DSPARTA_BIGBIG -c ../write_surf.cpp

...

And in the end, it compiles all output files into one executable with:

mpicxx -O write_grid.o write_surf.o -o ../spa_mpi_big_intel

 

I think I solved the "cannot find mpi.h" error by myself by adding to the /.bashrc:

export CPATH=/opt/intel/oneapi/mpi/2021.9.0/include:$CPATH

 

But now on the last step of compiling everything into a single executable, I get the following error:

/usr/bin/ld: cannot find -lmpicxx: No such file or directory
/usr/bin/ld: cannot find -lmpifort: No such file or directory
/usr/bin/ld: cannot find -lmpi: No such file or directory

 

I understood that mpicxx automatically resolved the libraries it needed, but seeing this error I tried to solve it by adding to the /.bashrc:

export LD_LIBRARY_PATH=/opt/intel/oneapi/mpi/2021.9.0/lib/release:$LD_LIBRARY_PATH

However, this has not resolved the issues with the three -lmpi***

 

I hope this is enough information and I made myself clear!

(I also wanted to add that it seems weird to me that I get an error for the -lmpifort library as the code is written in cpp, so I don't get why fortran should come up, maybe one of the multiple files of the code is written in fortran, but it seemed weird).

 

Thank you!

Max

0 Kudos
MaxAmer
Novice
7,987 Views

Update!

I had mistakenly assumed that setting the environment variables with ". /opt/intel/oneapi/setvars.sh" was all good and done, but I did not remember that the environment must be reloaded each session.

So what I did is source the setvars.h to the bashrc so I don't have to load it each time and now it compiled without issues.

Happy to have solved it by myself even though this is probably a very basic mistake!

 

0 Kudos
ShivaniK_Intel
Moderator
7,962 Views

Hi,


Glad to know that your issue is resolved. If you need any additional information, please post a new question as this thread will no longer be monitored by Intel.


Thanks & Regards

Shivani



0 Kudos
Reply