Building PCL on Windows

Mike1485

Well-known member
Jun 15, 2021
164
70
United Kingdom
www.ghsastro.co.uk
I am trying to build PCL on a Windows laptop. I have had no problem on a Mac but cannot get things working on a Windows machine.

The environment variables are all set fine and MakefileGenerator is running fine (A small tweak required to MakeGenUtility.js as described on this thread https://pixinsight.com/forum/index.php?threads/creating-and-compiling-a-new-pcl-module.16816/ ). I have opened the PCL.vcxproj in VS2019 as administrator and then tried to build the project. I am getting multiple errors "Cannot open include file: 'pcl/<filename>.h': No such file or directory". I have checked the environment variables are correctly specified and also checked in the project properties that "Additional Include Directories" includes $(PCLINCDIR) and this has a subdirectory "pcl" which contains all the relevant .h files. So I am stumped! Any help would be greatly appreciated.
 
Last edited:

pfile

PTeam Member
Nov 23, 2009
7,792
488
can you briefly say what you had to do? i have zero experience with windows so it would be interesting to know.
 

Mike1485

Well-known member
Jun 15, 2021
164
70
United Kingdom
www.ghsastro.co.uk
Briefly I think this is what I did (apologies that I will be teaching you to suck eggs in much of this but hopefully it will be helpful generally). Also this is all from memory so sorry if I have mis-remembered what I did or missed an important step!

Here goes ...

Download the PCL source code from The Official PCL Repository at GitLab

You will need to add some extra subdirectories within the PCL directory, ie: two subdirectories of PCL: bin and lib; then two subdirectories of bin: bin32 and bin64; and two subdirectories of lib: lib32 and lib64 (probably don't actually need the xxx32 subdirectories). You end up with a structure like this:

PCL
--bin
----bin32
----bin64
--include
----various sub directories of include
--lib
----lib32
----lib64
--linux
--src
----various subdirectories of src

Create a command line script file (.scp) file within PixInsight along the following lines:

export PCLDIR=C:\Users\mike\PixInsight\PCL
export PCLBINDIR32=C:\Users\mike\PixInsight\PCL\bin\bin32
export PCLBINDIR64=C:\Users\mike\PixInsight\PCL\bin\bin64
export PCLBINDIR=C:\Users\mike\PixInsight\PCL\bin\bin64
export PCLLIBDIR32=C:\Users\mike\PixInsight\PCL\lib\lib32
export PCLLIBDIR64=C:\Users\mike\PixInsight\PCL\lib\lib64
export PCLLIBDIR=C:\Users\mike\PixInsight\PCL\lib\lib64
export PCLINCDIR=C:\Users\mike\PixInsight\PCL\include
export PCLSRCDIR=C:\Users\mike\PixInsight\PCL\src

You will also need to set these 9 environment variables in Windows - how to do this in Windows 11 is well explained here.

Now an awkward bit - you need to find the MakeGenUtility.js file here: C:/Program Files/PixInsight/src/scripts/MakefileGenerator/MakGenUtility.js. You need to amend this file at line 135 as follows.

Replace:

JavaScript:
if ( dirPath.indexOf( '/' ) != 0 )
With:

JavaScript:
#ifeq __PI_PLATFORM__ MSWINDOWS
   if ( dirPath.indexOf( '/' ) != 2 || dirPath.indexOf( ':' ) != 1 )
#else
   if ( dirPath.indexOf( '/' ) != 0 )
#endif
You will also need to delete the file: MakefileGenerator.xsgn in the same directory. The code signature will no longer be valid due to the change you have just made!

Now in PixInsight run the .scp file you just created.

Then in Pixinsight run the MakefileGenerator script (Script>Development>MakefileGenerator)

In Project directory edit box enter the path for the pcl directory which using the example structure above would be: C:\Users\mike\PixInsight\PCL\src\pcl. Leave project identifier blank. Project type - set to PixInsight Class Library (PCL). Then click Run.

This will place a Visual Studio project in C:\Users\mike\PixInsight\PCL\src\pcl\windows\vc16\PCL.vcxproj.

Download MS Visual Studio from visual studio.microsoft.com. I used VS 2019 rather than the latest version VS 2022. When installing make sure you check to include VC/C++.

Now fire up MS Visual Studio. Make sure you run as administrator (right click and from the context sensitive menu choose More...).

Load the PCL.vcxproj project into Visual Studio. In the second line of menu items at the top of VisualStudio select Solution Configuration: Release (not Debug), and Solution Platform: x64 (not x86). Then select Build>Build Solution.

Cross your fingers and hope it all works!

I hope that is helpful.
 
  • Like
Reactions: pfile