Search code examples
cmakevcpkg

Build package with customized port file using vcpkg


I installed OpenCV package using vcpkg, and since the OpenCV comes with vcpkg's own build configuration does not support libgtk, I got error when trying to run OpenCV with in WSL2 on windows 10. The solution I found OpenCV GTK+2.x error suggests to add -DWITH_GTK=ON to the cmake configuration. And I added that option to the portfile in $vcpkgRoot/port/opencv4/porfile.make. And I try to rebuild/update the OpenCV, but seems it does not work. I searched the documentation and could not find a clear description on how to use updated/customized portfile to rebuild the package. The only way that seems to work is to uninstall and install it again with the modified portfile.


Solution

  • If you used vcpkg install opencv and then used vcpkg remove opencv opencv4 will not be removed since the port opencv is just a redirection to opencv4. So if you want to remove opencv4 you need to use vcpkg remove opencv4 --recurse or vcpkg remove opencv opencv4. The same is true for e.g. openssl which needs to specific the platform e.g openssl-windows for correct removal.

    And you cannot use the upgrade command since this requires a change of the version in the CONTROL file.