5

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.

1 Answer 1

4

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

2
  • 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). Commented Apr 23, 2022 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
    Commented Apr 23, 2022 at 14:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .