# The NAMES of find\_path cause cannot open file

**URL:** https://discourse.cmake.org/t/the-names-of-find-path-cause-cannot-open-file/5457
**Category:** Usage
**Tags:** os:windows
**Created:** [April 13, 2022, 2:35pm UTC](https://discourse.cmake.org/t/the-names-of-find-path-cause-cannot-open-file/5457 "2022-04-13T14:35:57Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![alice](https://discourse.cmake.org/user_avatar/discourse.cmake.org/alice/32/1615_2.png) [@alice](https://discourse.cmake.org/u/alice)
#### Post date: [April 13, 2022, 2:35pm UTC](https://discourse.cmake.org/t/the-names-of-find-path-cause-cannot-open-file/5457/1 "2022-04-13T14:35:57Z")

</div>

Continuing the discussion from [window env variable and cmake path](https://discourse.cmake.org/t/window-env-variable-and-cmake-path/5410/4):

`Arguments following NAMES cannot include a directory, they must be file names only. `  
And I follow this. I will happen cannot open file error.

The below is the problem:  
D:\libpqxx\include\pqxx\pqxx.h

```auto
find_path(_PQXX_INCLUDE
	NAMES pqxx
	PATHS "D:/libpqxx/include"
        PATH_SUFFIXES pqxx)

```

The error  
 ![image](https://discourse.cmake.org/uploads/default/original/2X/7/77fb72e4dd7bdce5dbdba4ddcac633abb359be5a.png)

> <https://github.com/jtv/libpqxx/blob/master/include/pqxx/version>

```auto
#include "pqxx/internal/compiler-internal-pre.hxx"
#include "pqxx/internal/compiler-public.hxx"

```

---

<div class="post-metadata">

### Author: ![jtxa](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jtxa/32/1535_2.png) [@jtxa](https://discourse.cmake.org/u/jtxa)
#### Post date: [April 13, 2022, 5:42pm UTC](https://discourse.cmake.org/t/the-names-of-find-path-cause-cannot-open-file/5457/2 "2022-04-13T17:42:25Z")

</div>

Please check first the content of your `_PQXX_INCLUDE` variable (e.g. inside the cache file) to see if the find was correct.  
I assume that you need to specify the correct file name for the find, which is: `pqxx.h` and not just `pqxx`

---

<div class="post-metadata">

### Author: ![alice](https://discourse.cmake.org/user_avatar/discourse.cmake.org/alice/32/1615_2.png) [@alice](https://discourse.cmake.org/u/alice)
#### Post date: [April 14, 2022, 1:53am UTC](https://discourse.cmake.org/t/the-names-of-find-path-cause-cannot-open-file/5457/3 "2022-04-14T01:53:43Z")

</div>

I can search the library(cache file is correct). But I can’t include the library.

So I rewrite the find\_path. It work and can find library.

```auto
find_path(_PQXX_INCLUDE
	NAMES pqxx/pqxx
	PATHS "D:/libpqxx/include" )

```

\_PQXX\_INCLUDE=D:/libpqxx/include/pqxx/pqxx.h

---

<div class="post-metadata">

### Author: ![jtxa](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jtxa/32/1535_2.png) [@jtxa](https://discourse.cmake.org/u/jtxa)
#### Post date: [April 14, 2022, 6:50am UTC](https://discourse.cmake.org/t/the-names-of-find-path-cause-cannot-open-file/5457/4 "2022-04-14T06:50:12Z")

</div>

Please delete your build directory (or at least the cache file).  
The variable needs to be a directory, not a file, and this is not the result of this `find_path` command. It probably was already set by earlier experiments or you have another find with the same variable.

---

<div class="post-metadata">

### Author: ![alice](https://discourse.cmake.org/user_avatar/discourse.cmake.org/alice/32/1615_2.png) [@alice](https://discourse.cmake.org/u/alice)
#### Post date: [April 15, 2022, 2:22pm UTC](https://discourse.cmake.org/t/the-names-of-find-path-cause-cannot-open-file/5457/5 "2022-04-15T14:22:01Z")

</div>

I have delete build folder for the two method.  
Sorry I cannot understand what do you mean. Do you have the example？  
Thanks you.

---

<div class="post-metadata">

### Author: ![jtxa](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jtxa/32/1535_2.png) [@jtxa](https://discourse.cmake.org/u/jtxa)
#### Post date: [April 15, 2022, 5:12pm UTC](https://discourse.cmake.org/t/the-names-of-find-path-cause-cannot-open-file/5457/6 "2022-04-15T17:12:24Z")

</div>

```auto
find_path(_PQXX_INCLUDE
  NAMES "pqxx/pqxx.h"
  PATHS "D:/libpqxx/include"
)

```

This will find the path, which you need to add to your include directory. Which is in fact `D:/libpqxx/include`

I assume this is just an example to understand the find command. If you know the path already and hardcode it, then you don’t need to search for it in the first place.
