4

I have installed msys2/mingw64 because I need the g++ compiler. Now, I want to compile some c++ oce which requires openblas. I have installed the package using pacman -S mingw-w64-x86_64-openblas. However, compiling the code fails with

fatal error: cblas.h: No such file or directory

Clearly, the include path does not contain the headers from openblas which are located at C:\msys64\mings64\include\openblas. This is easy to fix by passing -I<include path> as an additional argument to g++.

Now, I was wondering whether there is an automated way to include include files/headers of installed packages in the g++ include path. The same problem also holds for libraries.

For example, pacman might be able to atomatically append these paths onto some environment variable which g++ checks.

HerpDerpington
  • 333
  • 1
  • 3
  • 11

1 Answers1

3

How do I include include files/headers of installed packages in the g++ include path?

You can set environment variables CPLUS_INCLUDE_PATH for include directories and LIBRARY_PATH for library directories. More information can be found in Environment Variables Affecting GCC

Source: c++ - Add extra include/lib paths to MinGW - Stack Overflow answer by Piotr Dobrogost

DavidPostill
  • 153,128
  • 77
  • 353
  • 394
  • Will this also work for subdirectories of the paths given there? The problem would be that the openblas dir which contains the headers is a subdirectory of the "include" dir (`C:\msys64\mings64\include`). – HerpDerpington Apr 23 '22 at 13:28
  • 1
    @HerpDerpington It depends what is in the source file. If it says just `cblas.h` then you will needs to include the subdirectory in the environment variable. If it says `openblas\cblas.h` you won't need the subdirectory. – DavidPostill Apr 23 '22 at 14:33