# Compilation errors related to PEGTL / Proj

**URL:** https://discourse.vtk.org/t/compilation-errors-related-to-pegtl-proj/5929
**Category:** Support
**Created:** [June 3, 2021, 7:33pm UTC](https://discourse.vtk.org/t/compilation-errors-related-to-pegtl-proj/5929 "2021-06-03T19:33:56Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![KBentley57](https://discourse.vtk.org/user_avatar/discourse.vtk.org/kbentley57/32/3506_2.png) [@KBentley57](https://discourse.vtk.org/u/KBentley57)
#### Post date: [June 3, 2021, 7:33pm UTC](https://discourse.vtk.org/t/compilation-errors-related-to-pegtl-proj/5929/1 "2021-06-03T19:33:56Z")

</div>

Hi all,

I’ve nearly got VTK compiling with most of the ThirdParty packages turned off. There’s a few errors that are keeping me from 100%, and I’m open to ideas on how to move past them.

The first is encountered in the IOMotionFX code. ThirdParty/pegtl/vtk\_pegtl.h claims it can’t find ThirdParty/pegtl/vtk\_pegtl.h. PEGTL is correctly found earlier in the process, and the include/library is set in the cache, so I’m sure it’s there, and available.

```
ThirdParty/pegtl/vtk_pegtl.h:22:23: fatal error: tao/pegtl/contrib/tracer.hpp: No such file or directory

```

22 | # define VTK\_PEGTL(x) \<tao/x\>

The other error stems from the external libproj module. A similar error -

```
ThirdParty/libproj/vtk_libproj.h:38:11: fatal error: proj_api.h: No such file or directory

```

38 | # include \<proj\_api.h\>  
| ^ ~~~~~~~~~~~

Again, the proj include/lib is set in the cache, and this one seems internal to the libproj directory itself.

Before I start digging into the CMake myself I thought I’d see if this had popped up before.

Thanks,

Kyle

---

<div class="post-metadata">

### Author: ![KBentley57](https://discourse.vtk.org/user_avatar/discourse.vtk.org/kbentley57/32/3506_2.png) [@KBentley57](https://discourse.vtk.org/u/KBentley57)
#### Post date: [June 3, 2021, 9:08pm UTC](https://discourse.vtk.org/t/compilation-errors-related-to-pegtl-proj/5929/2 "2021-06-03T21:08:07Z")

</div>

I’m narrowing the errors down to what I suspect are a few misplaced properties on targets. In the IOMotionFX.dir directory I can edit the link.txt file to add the path

`-IThirdParty/pegtl/vtkpegtl/include` to the CXX\_FLAGS inside the flags.txt and the IOMotionFX module builds fine.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [June 4, 2021, 12:49am UTC](https://discourse.vtk.org/t/compilation-errors-related-to-pegtl-proj/5929/3 "2021-06-04T00:49:45Z")

</div>

Hmm. We do test one CI run with external packages (including pegtl and proj) and they work fine. Are you using `master` or 9.0.1?

---

<div class="post-metadata">

### Author: ![KBentley57](https://discourse.vtk.org/user_avatar/discourse.vtk.org/kbentley57/32/3506_2.png) [@KBentley57](https://discourse.vtk.org/u/KBentley57)
#### Post date: [June 4, 2021, 2:33pm UTC](https://discourse.vtk.org/t/compilation-errors-related-to-pegtl-proj/5929/4 "2021-06-04T14:33:06Z")

</div>

I’m using the 9.0.1 from the release page on github. I can try master to see fi that resolves anything. Has there been a lot of time between that tag and HEAD?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [June 4, 2021, 3:21pm UTC](https://discourse.vtk.org/t/compilation-errors-related-to-pegtl-proj/5929/5 "2021-06-04T15:21:39Z")

</div>

It’ll be one year in 20 days.

---

<div class="post-metadata">

### Author: ![KBentley57](https://discourse.vtk.org/user_avatar/discourse.vtk.org/kbentley57/32/3506_2.png) [@KBentley57](https://discourse.vtk.org/u/KBentley57)
#### Post date: [June 4, 2021, 3:30pm UTC](https://discourse.vtk.org/t/compilation-errors-related-to-pegtl-proj/5929/6 "2021-06-04T15:30:13Z")

</div>

I’ve got master checkout and and building now. I’ll report back in a bit.

Thanks for all the help so far.

---

<div class="post-metadata">

### Author: ![KBentley57](https://discourse.vtk.org/user_avatar/discourse.vtk.org/kbentley57/32/3506_2.png) [@KBentley57](https://discourse.vtk.org/u/KBentley57)
#### Post date: [June 4, 2021, 6:02pm UTC](https://discourse.vtk.org/t/compilation-errors-related-to-pegtl-proj/5929/7 "2021-06-04T18:02:23Z")

</div>

Ben,

Master seemed to build fine, save for that one include. I’m building it as an external package, and here was the failure in the build-err.log

```
In file included from /home/bentleykw/src/SupportPackages/build/vtk/src/vtk/IO/MotionFX/vtkMotionFXCFGGrammar.h:22,
             from /home/bentleykw/src/SupportPackages/build/vtk/src/vtk/IO/MotionFX/vtkMotionFXCFGReader.cxx:40:
/home/bentleykw/src/SupportPackages/build/vtk/src/vtk-build/ThirdParty/pegtl/vtk_pegtl.h:22:23: fatal error: tao/pegtl/contrib/tracer.hpp: No such file or directory
 # define VTK_PEGTL(x) <tao/x>
                   ^

```

the solution I found was to add

`-I/home/bentleykw/src/SupportPackages/build/vtk/src/vtk/ThirdParty/pegtl/vtkpegtl/include`

to the end of /home/bentleykw/src/SupportPackages/build/vtk/src/vtk-build/IO/MotionFX/CMakeFiles/IOMotionFX.dir/flags.make, which I believe translates to

`${CMAKE_CURRENT_BINARY_DIR}/ThirdParty/pegtl/vtkpegtl/include`

I’m building with the cmake flags

```
 -DCMAKE_PREFIX_PATH=<INSTALL_DIR>
	    -DCMAKE_MODULE_PATH=${CMAKE_SOURCE_DIR}/cmake
	    -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>	
	    -DCMAKE_INSTALL_LIBDIR=lib		
	    -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
	    -DBUILD_STATIC_LIBS=FALSE
	        -DBUILD_SHARED_LIBS=TRUE	
		-DVTK_BUILD_DOCUMENTATION=FALSE
		-DVTK_USE_EXTERNAL=ON
		-DVTK_FORBID_DOWNLOADS=TRUE
		-DVTK_MODULE_USE_EXTERNAL_VTK_libharu=FALSE
		-DVTK_MODULE_USE_EXTERNAL_VTK_gl2ps=FALSE

```

I still think there’s probably a target or include directory that’s missing or misplaced in the IO/MotionFX dir somewhere, but that gets me going. All other dependencies are local.

Thanks,

Kyle

---

<div class="post-metadata">

### Author: ![KBentley57](https://discourse.vtk.org/user_avatar/discourse.vtk.org/kbentley57/32/3506_2.png) [@KBentley57](https://discourse.vtk.org/u/KBentley57)
#### Post date: [June 4, 2021, 8:08pm UTC](https://discourse.vtk.org/t/compilation-errors-related-to-pegtl-proj/5929/8 "2021-06-04T20:08:34Z")

</div>

Just to add a little bit more, in the ThirdParty/vtkpegtl CMakeListst.txt, the comment below raises a little suspicion as to why it’s not finding the headers.

```
# features used by the PEGTL
target_compile_features(pegtl
  INTERFACE
cxx_std_11)

# Not installing headers explicitly. This is not meant to be part of the VTK API.
```

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [June 7, 2021, 1:42pm UTC](https://discourse.vtk.org/t/compilation-errors-related-to-pegtl-proj/5929/9 "2021-06-07T13:42:46Z")

</div>

> [@KBentley57](#):
>
> Just to add a little bit more, in the ThirdParty/vtkpegtl CMakeListst.txt, the comment below raises a little suspicion as to why it’s not finding the headers.

It only answers it if the code trying to use it is outside of VTK. If that’s the case, yes, pegtl is not a public third party dependency of VTK. If it is code inside of VTK that is failing, something else is going wrong (though it works just fine in our CI with an external pegtl).

---

<div class="post-metadata">

### Author: ![waebbl](https://discourse.vtk.org/user_avatar/discourse.vtk.org/waebbl/32/5870_2.png) [@waebbl](https://discourse.vtk.org/u/waebbl)
#### Post date: [October 9, 2022, 2:22pm UTC](https://discourse.vtk.org/t/compilation-errors-related-to-pegtl-proj/5929/10 "2022-10-09T14:22:41Z")

</div>

I also encountered the issue described in the opening thread. On Gentoo Linux we’re restricting pegtl to versions \<3, because VTK didn’t build with \>=pegtl-3, but I never cared too much about digging into it. We had a PR, later reverted, which included a patch for this[1], however I never tested whether the patch works due to it’s immediate revert.

While packaging v9.2.2, I was trying whether I could update the dependency to versions \>=3 and found this error, using pegtl-3.2.5 or pegtl-3.2.1.

So it looks like VTK needs \>=pegtl-2.0.0 but is actually not compatible with \>=pegtl-3, or at least \>=pegtl-3.2. Building against 2.8.3, which is also available on Gentoo works.

Is your CI running against the same version as the internal pegtl library, i.e. 2.8.3? Or have you tried building against a newer version (\>=3) of an external pegtl?

If VTK is restricted to versions of pegtl \<3, is there a way in the cmake logic, to not only provide a minimum version, but also a maximum version?

[1] [sci-libs/vtk: fix build with new deps versions · gentoo/gentoo@4893345 · GitHub](https://github.com/gentoo/gentoo/commit/4893345530421b0d6168b5278d57d69fc08f7fdf#diff-99e1949b66fcf5231db010ded8e682ed19dc57b20590b95f4760868bd7dffe78)

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [October 10, 2022, 3:50pm UTC](https://discourse.vtk.org/t/compilation-errors-related-to-pegtl-proj/5929/11 "2022-10-10T15:50:47Z")

</div>

> [@waebbl](#):
>
> If VTK is restricted to versions of pegtl \<3, is there a way in the cmake logic, to not only provide a minimum version, but also a maximum version?

I think specifying `2.8...2.9999` might work. Would need testing.

> [@waebbl](#):
>
> Is your CI running against the same version as the internal pegtl library, i.e. 2.8.3? Or have you tried building against a newer version (\>=3) of an external pegtl?

Our external libraries CI is on Fedora 34, so it might not have pegtl 3. Looking, I see that even Fedora 38 has 2.8.3…not sure of the reason there (probably similar issues Gentoo is seeing?). Looks like it according to [this issue](https://bugzilla.redhat.com/show_bug.cgi?id=1902427).

---

<div class="post-metadata">

### Author: ![waebbl](https://discourse.vtk.org/user_avatar/discourse.vtk.org/waebbl/32/5870_2.png) [@waebbl](https://discourse.vtk.org/u/waebbl)
#### Post date: [October 10, 2022, 5:54pm UTC](https://discourse.vtk.org/t/compilation-errors-related-to-pegtl-proj/5929/12 "2022-10-10T17:54:31Z")

</div>

> [@ben.boeckel](#):
>
> I think specifying `2.8...2.9999` might work. Would need testing.

Thanks for your feedback.

I tested this and changed `VERSION 2.0.0` to `VERSION 2.0.0...2.9999` in the EXTERNAL section of `vtk_module_third_party` in `ThirdParty/pegtl/CMakeLists.txt`. This results in a warning

```auto
CMake Warning (dev) at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:447 (message):
  `find_package()` specify a version range but the module PEGTL does not
  support this capability. Only the lower endpoint of the range will be
  used.
Call Stack (most recent call first):
  CMake/FindPEGTL.cmake:38 (find_package_handle_standard_args)
  CMake/vtkModule.cmake:4572 (find_package)
  CMake/vtkModule.cmake:5172 (vtk_module_find_package)
  CMake/vtkModule.cmake:5043 (vtk_module_third_party_external)
  ThirdParty/pegtl/CMakeLists.txt:1 (vtk_module_third_party)
This warning is for project developers. Use -Wno-dev to suppress it.

-- Found PEGTL: /usr/include/tao (found suitable version "3.2.5", minimum required is "2.0.0") 

```

It looks like the `CMake/FindPEGTL.cmake` module has to be adapted as well to accept a version range, but should be possible to use this syntax.

> [@ben.boeckel](#):
>
> Our external libraries CI is on Fedora 34, so it might not have pegtl 3. Looking, I see that even Fedora 38 has 2.8.3…not sure of the reason there (probably similar issues Gentoo is seeing?). Looks like it according to [this issue](https://bugzilla.redhat.com/show_bug.cgi?id=1902427).

Being a header only library, it makes me wonder they couldn’t update. Thought this would be a lot easier on a binary distribution than in a source based distribution as the package only needs to be available on the package maintainers machine at build time. We also have only usbguard as the only other package in the main tree which needs pegtl, which has been [updated](https://github.com/USBGuard/usbguard/issues/441) to support pegtl-3.

I will test whether the patch I mentioned above will build and then see how to handle this further.

---

<div class="post-metadata">

### Author: ![waebbl](https://discourse.vtk.org/user_avatar/discourse.vtk.org/waebbl/32/5870_2.png) [@waebbl](https://discourse.vtk.org/u/waebbl)
#### Post date: [October 12, 2022, 5:17pm UTC](https://discourse.vtk.org/t/compilation-errors-related-to-pegtl-proj/5929/13 "2022-10-12T17:17:31Z")

</div>

> [@waebbl](#):
>
> I will test whether the patch I mentioned above will build and then see how to handle this further.

The patch does not easily build. It wants C++ 14 resp. C++ 17 features.

For now, I’m going to keep the restriction to \<pegtl-3 on the package.
