Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems building AliceVision v3.2.0 for Win x64 #1817

Open
jpasfol opened this issue Jan 29, 2025 · 5 comments
Open

Problems building AliceVision v3.2.0 for Win x64 #1817

jpasfol opened this issue Jan 29, 2025 · 5 comments

Comments

@jpasfol
Copy link

jpasfol commented Jan 29, 2025

Hi all,

I'm trying to build the last version (currently v3.2.0) of AliceVision library for Windows x64. I've encountered an error when building the library with Visual Studio. That's my situation:

  • I've CUDA installed, several versions (11.2, 11.6, 12.6 and 12.8). I switch among them by setting the PATH environment variable. I' ve checked this by typing nvcc --version.

  • I have Visual Studio Community 2017, 2019 and 2022. Although I have realized that the 2022 version gives me CUDA compatibility problems, so I have ruled it out. Maybe I should use version 2022? But how do I need to configure my system to not to have problems with the OpenCV compilation with CUDA through VCPKG?

  • The only combination that has allowed me to compile OPENCV with CUDA is: CUDA 11.2 + VISUAL STUDIO 2019.

  • I'm taking into account that, for the compilation of the dependencies with VCPKG and for Alicevision himself, I'm using the Visual Studio terminal: Developer Command Prompt for VS <version>. With this I intend to make sure that all the environment variables are being configured correctly.

  • I'm not sure if I should use Visual Studio 2019 because in the instructions for the installation of Alicevision does not mention it ... only Visual 2022 + Powershell,Visual 2022 and Visual 2017.

  • With the vcpkg forked of Alicevision cloned with git within the repo itself that I have cloned from Alicevision (\Alicevision\vcpkg\), I have managed to compile all the dependencies with the command:

    vcpkg install boost-algorithm boost-accumulators boost-atomic boost-container boost-date-time boost-exception boost-filesystem boost-geometry boost-graph boost-json boost-log boost-program-options boost-property-tree boost-ptr-container boost-regex boost-serialization boost-system boost-test boost-thread boost-timer lz4 liblemon openexr alembic geogram eigen3 expat flann onnxruntime-gpu opencv[eigen,ffmpeg,webp,contrib,nonfree,cuda] openimageio[libraw,ffmpeg,freetype,opencv,gif,openjpeg,webp] ceres[suitesparse,cxsparse] cuda tbb assimp pcl clp --triplet x64-windows
    
  • However, when I launch Cmake to configure the entire Alicevision project from the folder``\AliceVision\build`:

    # Visual Studio 2019
    cmake .. -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%\scripts\buildsystems\vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows -G "Visual Studio 16 2019" -A x64 -T host=x64
    

    I get the following output:

    ...
    
    -- EIGEN:
    -- CERES: 2.1.0
    -- FLANN:
    -- CLP: 1.16.11
    -- COINUTILS: 2.10.14
    -- OSI: 0.107.9
    -- LEMON:
    
    ...
    

    The thing I see is that cmake is not correctly linking the libraries, although I think it is the way they show the versions...

  • Should I modify any CMakeLists.txt to alter the configuration or libraries that must be taken? I have seen that by default: trilean_option(ALICEVISION_USE_OPENCV "Enable use of OpenCV algorithms" OFF), I should turn it ON, I understand that OPENCV is practically a requirement for everything to work.

  • However, it doesn't warn me of any error, so I proceed to open the solution generated with Visual Studio 2019, I selected Release x64 and I make a Build of the entire solution. The program compiles but many errors jump, in the following style:

    Error LNK2019 unresolved external symbol "__declspec(dllimport) private: static unsigned int __cdecl boost::log::v2_mt_nt6::attribute_name::get_id_from_string(char const *)" (__imp_?get_id_from_string@attribute_name@v2_mt_nt6@log@boost@@CAIPEBD@Z) referenced in function "private: __cdecl aliceVision::system::Logger::Logger(void)" (??0Logger@system@aliceVision@@AEAA@XZ)	aliceVision_system	C:\Repos\AliceVision\build\src\aliceVision\system\Logger.obj	1
    
    Error	LNK2001	unresolved external symbol "__declspec(dllimport) public: static void __cdecl boost::log::v2_mt_nt6::record_view::public_data::destroy(struct boost::log::v2_mt_nt6::record_view::public_data const *)" (__imp_?destroy@public_data@record_view@v2_mt_nt6@log@boost@@SAXPEBU12345@@Z)	aliceVision_image	C:\Repos\AliceVision\build\src\aliceVision\image\cache.obj	1
    
    Error	C2338	You've instantiated std::aligned_storage<Len, Align> with an extended alignment (in other words, Align > alignof(max_align_t)). Before VS 2017 15.8, the member type would non-conformingly have an alignment of only alignof(max_align_t). VS 2017 15.8 was fixed to handle this correctly, but the fix inherently changes layout and breaks binary compatibility (*only* for uses of aligned_storage with extended alignments). Please define either (1) _ENABLE_EXTENDED_ALIGNED_STORAGE to acknowledge that you understand this message and that you actually want a type with an extended alignment, or (2) _DISABLE_EXTENDED_ALIGNED_STORAGE to silence this message and get the old non-conformant behavior. (compiling source file C:\Repos\AliceVision\src\aliceVision\lightingEstimation\lightingCalibration.cpp)	aliceVision_lightingEstimation	C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\type_traits	1271
    
  • I think the problem is that I'm mixing Visual Studio versions during the dependencies installation.

Please, could anyone describe the compilation flow that I have to follow together with the versions of CUDA, Visual Studio... that I have to dispose? I'm learning and I'm a little confused with what I must to do. Maybe the INSTALL.md is outdated.

Thank you very much in advance.

@atracsys-sbt
Copy link

atracsys-sbt commented Feb 18, 2025

I have had very similar difficulties to build AliceVision on Windows x64.

  1. I tried building the solution using the AliceVision's vcpkg fork and VS 2022 but Cuda 12.x gives errors (related to opencv indeed).
  2. Using Cuda 11.x requires VS 2019, which I installed and specifically chose as the compiler using a dedicated vcpkg triplet. This works fine to generate the solution, but the compilation is full of link errors.
  3. I tried manually generating the solution by compiling/targetting all the dependencies, but this takes a loooot of time as the dependencies (and their own dependencies) are numerous. And I have still not yet successfully compiled using this route.

I think the INSTALL.md should be revisited:

  • to include more specific version requirements (especially for Cuda);
  • to potentially add instructions to successfully compile with VS 2019 when it is installed along side other versions of Visual Studios;
  • to detail a successful path to compilation with VS 2022, if possible, as implied by the provided command lines to generate the final solution:
# Windows: Visual 2022 + Powershell
cmake .. -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT"\scripts\buildsystems\vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows -G "Visual Studio 17 2022" -A x64 -T host=x64

# Windows: Visual 2022
cmake .. -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%\scripts\buildsystems\vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows -G "Visual Studio 17 2022" -A x64 -T host=x64

Moreover, the CI seems broken, so we cannot retrieve snapshots.

In any case, building AliceVision on win64 seems trickier than suggested by the Install instructions.
Any help would be greatly appreciated.
Thank you.

@natowi
Copy link
Member

natowi commented Feb 18, 2025

This is how I did it a few releases ago:

Alicevision

Requires vcpkg and Visual Studio 2017 (run x64 Native Tools Command Prompt for VS 2017, as admin) Use the English language version only!

install vcpkg and install all vcpkg packages as described in the alicevision readme

cd [PATH-TO-FOLDER]

git clone --recursive https://github.com/alicevision/aliceVision.git

cd alicevision

mkdir build

cd build

set VCPKG_ROOT=C:\path\to\vcpkg

cmake .. -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%\scripts\buildsystems\vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows -G "Visual Studio 15 2017" -A x64 -T host=x64

DO NOT RENAME THE FOLDER OR CHANGE THE FOLDER PATH BEFORE BUILDING! (ABSOLUTE FILE PATHS ARE STORED!)

In file browser go to [PATH-TO-FOLDER]/aliceVision/build -> open alicevision.sln in VS2017

In VS2017 -> change from develop to release and x64

In Solution Explorer right-click on Solution 'aliceVision' (??? projects) -> Build This will take a few minutes

You can find the compiled files in [PATH-TO-FOLDER]\aliceVision\build\Windows-AMD64\Release


"Moreover, the CI seems broken, so we cannot retrieve snapshots."
Yes, now Github Actions CI is used. It works but making the build available is not implemented. https://github.com/alicevision/AliceVision/actions/workflows/continuous-integration.yml
Example: https://github.com/alicevision/AliceVision/actions/runs/13396074373/job/37415331865

@atracsys-sbt
Copy link

atracsys-sbt commented Feb 19, 2025

Thank you for your detailed reply.
So, I have followed to the best of my abilities what you described:

  1. I installed VS 2017 (and even removed all other versions)
  2. As per the current Install instructions, I cloned AliceVision's fork of vcpkg
  3. I opened the x64 Native Tools Command Prompt for VS 2017, as admin and in English, ran the boostrap and then entered the exact build line listed in the Install instructions:
    vcpkg install boost-algorithm boost-accumulators boost-atomic boost-container boost-date-time boost-exception boost-geometry boost-graph boost-json boost-log boost-program-options boost-property-tree boost-ptr-container boost-regex boost-serialization boost-system boost-test boost-thread boost-timer boost-format lz4 liblemon openexr alembic geogram eigen3 expat flann nanoflann onnxruntime-gpu opencv[eigen,ffmpeg,webp,contrib,nonfree,cuda] openimageio[opencolorio,pybind11,libraw,ffmpeg,freetype,opencv,gif,openjpeg,webp] openmesh ceres[suitesparse,cxsparse] cuda tbb assimp pcl clp libe57format --triplet x64-windows

It started to build and then failed with one of the first packages -- assimp -- provoking the following error:
error C2039: 'max': is not a member of 'std'
Addressing this error is apparently easy, by just adding #include <algorithm>, but I don't think starting to edit sources is the correct fix in our more global compilation issue.

@atracsys-sbt
Copy link

atracsys-sbt commented Feb 21, 2025

So I have finally sucessfully built AliceVision, below are all the steps I took. This is very close to the official INSTALL.md instructions, but with more explanations to (hopefully) prevent other people from making mistakes.

Following the requirements (CMake >= 3.11 and Git installed), using a terminal window cmd or Powershell (I used regular Powershell, not admin):

  1. Get AliceVision's fork of vcpkg:
git clone https://github.com/alicevision/vcpkg --branch alicevision_master
  1. Head into the newly created vcpkg folder and run the bootstrap:
cd vcpkg
.\bootstrap-vcpkg.bat
  1. I think most people would want to use Cuda in AliceVision, but Cuda 12 seems incompatible with the current version of the dependencies, so use Cuda 11.x (I used 11.8). Make sure that the environment variables are set accordingly (CUDA_PATH set to path\to\CUDA\v11.x and path\to\CUDA\v11.x\bin & libnvvp highest in the variable Path).

  2. Due to the conflict between Cuda 11.x and Visual Studio 2022, I recommend using Visual Studio 2019. If there are other versions of Visual Studio installed, the compilation with VS 2019 can be enforced by creating a custom vcpkg triplet named, for example, x64-windows-vs2019.cmake (no uppercase!) in vcpkg\triplets with the following content:

set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE dynamic)
set(VCPKG_PLATFORM_TOOLSET v142)

One can try to skip the Debug build by adding set(VCPKG_BUILD_TYPE release) to the triplet file, but apparently it is not supported by all dependencies, so some significant Debug build will unfortunately remain.

  1. Still from the vcpkg folder, store its root path (used later)
:: In cmd
set VCPKG_ROOT=%cd%
# In Powershell
`$VCPKG_ROOT = $PWD.Path
  1. Build the dependencies by executing the following command:
.\vcpkg install boost-algorithm boost-accumulators boost-atomic boost-container boost-date-time boost-exception boost-geometry boost-graph boost-json boost-log boost-program-options boost-property-tree boost-ptr-container boost-regex boost-serialization boost-system boost-test boost-thread boost-timer boost-format lz4 liblemon openexr alembic geogram eigen3 expat flann nanoflann onnxruntime-gpu opencv[eigen,ffmpeg,webp,contrib,nonfree,cuda] openimageio[opencolorio,pybind11,libraw,ffmpeg,freetype,opencv,gif,openjpeg,webp] openmesh ceres[suitesparse,cxsparse] cuda tbb assimp pcl clp libe57format --triplet x64-windows-vs2019

This will build more than 200 packages, which will take a while ( 3-4 hours, probably more if Debug build is performed for all dependencies).

  1. Using the same terminal, get the actual AliceVision source (I prefer to change directory though and not to clone it inside the vcpkg folder). This will checkout the default branch develop, not the master. I was only able to successfully build on the develop branch.
cd ..
git clone https://github.com/alicevision/AliceVision.git --recursive
  1. Go inside AliceVision, create a build folder and move into it:
cd AliceVision
mkdir build
cd build
  1. Generate the solution using CMake, based on the vcpkg dependencies. I added the OpenCV use to the configuration, otherwise I am missing the aliceVision_lightingEstimation lib during build. Make sure the triplet name is correct.
:: In cmd
cmake .. -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%\scripts\buildsystems\vcpkg.cmake -DALICEVISION_USE_OPENCV=ON -DVCPKG_TARGET_TRIPLET=x64-windows-vs2019 -G "Visual Studio 16 2019" -A x64 -T host=x64
#  In Powershell
cmake .. -DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT"\scripts\buildsystems\vcpkg.cmake -DALICEVISION_USE_OPENCV=ON -DVCPKG_TARGET_TRIPLET=x64-windows-vs2019 -G "Visual Studio 16 2019" -A x64 -T host=x64

One can also change the installation and bundle destinations by adding to the command above -DCMAKE_INSTALL_PREFIX=C:\path\to\install and -DALICEVISION_BUNDLE_PREFIX=C:\path\to\bundle respectively. The installation will contain the whole AliceVision package (all binaries including static libs as well as the includes, share files, etc). The bundle will contain only what's necessary to run AliceVision (executables, dlls, etc.) akin to what's included in Meshroom.

  1. Open the AliceVision.sln generated in the build folder with Visual Studio 2019. Select "Release" as build type and build the solution. It should take around 20-30 min. Once done, the binaries should be in build\Windows-AMD64. Build the "INSTALL" project to package the whole library in CMAKE_INSTALL_PREFIX, or build the "Packaging\bundle" project to bundle only the executables and dlls in ALICEVISION_BUNDLE_PREFIX.

@natowi
Copy link
Member

natowi commented Feb 23, 2025

@atracsys-sbt Thanks for sharing! It would be great if you could contribute this to https://github.com/alicevision/AliceVision/blob/develop/INSTALL.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants