darbyjohnston / DJV

Professional media review software for VFX, animation, and film production
https://darbyjohnston.github.io/DJV/
BSD 3-Clause "New" or "Revised" License
686 stars 59 forks source link

Project fails to build properly #505

Open JamarleyHub opened 4 months ago

JamarleyHub commented 4 months ago

I've tried to build the project from 3 different sources and it does not seem to work. First I had to add

#include <cstdint>

to both ./OpenEXR/src/OpenEXR/OpenEXR/IlmImf/ImfDwaCompressor.cpp and ./OpenEXR/src/OpenEXR/OpenEXR/IlmImf/ImfMisc.cpp

due to errors:

path/to/build/DJV/DJV-Release/OpenEXR/src/OpenEXR/OpenEXR/IlmImf/ImfDwaCompressor.cpp:1013:38: error: ‘uintptr_t’ does not name a type
 1013 |                 if (reinterpret_cast<uintptr_t>(_rowPtrs[comp][y]) & _SSE_ALIGNMENT_MASK)

and

path/to/build/DJV/DJV-Release/OpenEXR/src/OpenEXR/OpenEXR/IlmImf/ImfDwaCompressor.cpp:745:31: error: ‘uintptr_t’ does not name a type
  745 |         if ((reinterpret_cast<uintptr_t>(rowBlockHandle + i) & _SSE_ALIGNMENT_MASK) == 0)

And after that it spits out an error regarding RapidJSON:

path/to/build/DJV/DJV-install-Release/include/rapidjson/document.h:319:82: error: assignment of read-only member ‘rapidjson::GenericStringRef<CharType>::length’
  319 |     GenericStringRef& operator=(const GenericStringRef& rhs) { s = rhs.s; length = rhs.length; }

I presume the build problems are not fixable on your end, since they are third party libraries, right? I found that the bug regarding the assignment has been fixed so maybe this just needs to be updated on your end?

JamarleyHub commented 4 months ago

So after a bit of fiddling I finally got the project to build: First obviously you need to include

#include <cstdint> 

in both ImfDwaCompressor.cpp and ImfMisc.cpp

Next you need to remove line 319 in rapidjson/document.h It looks like this:

GenericStringRef& operator=(const GenericStringRef& rhs) { s = rhs.s; length = rhs.length; }

It's just an assignment operator anyway, no harm in removing it.

For that (if you have followed the steps on the website) you need to open the file

./DJV-Release/DJV-install-Release/include/rapidjson/document.h

After that you still get two more errors to fix, saying that

./DJV-install-Release/include/rapidjson/document.h:885:83: error: macro "RAPIDJSON_ENABLEIF" passed 2 arguments, but takes just 1
  885 |         explicit GenericValue( T b, RAPIDJSON_ENABLEIF( internal::IsSame<bool, T> ) )

and

./DJV-install-Release/include/rapidjson/document.h:892:75: error: macro "RAPIDJSON_STATIC_ASSERT" passed 2 arguments, but takes just 1
  892 |                 RAPIDJSON_STATIC_ASSERT( internal::IsSame<bool, T>::Value );

To fix those errors you need to go into line 885 and 892 of the same documents.h respectively and set a few parentheses like so:

// Old line 885:
// explicit GenericValue( T b, RAPIDJSON_ENABLEIF( internal::IsSame<bool, T> ) )
// Fixed line:
explicit GenericValue( T b, RAPIDJSON_ENABLEIF( (internal::IsSame<bool, T>) ) )

// ...

// Old line 892:
// RAPIDJSON_STATIC_ASSERT( internal::IsSame<bool, T>::Value );
// Fixed line:
RAPIDJSON_STATIC_ASSERT( (internal::IsSame<bool, T>::Value) );

Save and exit the file. The project should now compile and run properly.