google/pik

compilation issue with MSYS2 under Windows 10

rcanut opened this issue · 18 comments

Hello,

I can not compile PIK successfully with MSYS2 under Windows 10.( I have quite many errors).

Could you post the latest cpik and dpik binaries for Windows 10?

Many thanks!
Cheers,
Raphael

Hi, thanks for your interest. We currently don't provide Windows binaries. However, I can help fix some of the compile errors if you paste (a summary of) them here :)

Update, I gather from encode.ru that the issue is with: "git submodule init && git submodule update".
What's the exact error?
It may help to clone Brotli and https://github.com/mm2/Little-CMS and place them in third_party.

Hello,

Many thanks for your answer and your help.

Actually, I managed to compile git submodule init and git submodule update with the Git shell.But when I run make -j8 with MSYS2 under Windows 10, I have quite many errors, inherent to MSYS2 and Windows 10 I think, and it will be very complicated to compile under this environment I think... So I'll wait or I'll ask for now on the encode.ru forum that someone kind and skilled enough posts PIK binaries for Windows 10.

Many thanks again!
Cheers,
Raphael

For me, it works if, in os_specific.cc, I wrap the #define NOMINMAX in an #ifndef, as it seems to be already defined in a global header. Have you made sure to install mingw-w64-i686-clang or mingw-w64-x86_64-clang (depending on your target)? We currently only support Clang (as you can guess from the current build flags).

I think we also need to specify the .exe extension in the target names in the Makefile, otherwise we end up e.g. with both cpik.exe and cpik, where cpik is stripped and cpik.exe is not. Not a huge deal but still a bit odd.

It seems that the resulting executable crashes because of the %zu specifier for size_t in printf, which is not supported by the Microsoft runtime. A possible workaround would be to replace them with %lu and cast the size_ts to unsigned long.

If I do that, I get a failed assertion in write_bits.h. I will try to look into it later.

Hi, we currently only support clang6+ as the compiler. Please try to compile using that if possible.

What are the problems when compiling a program gnu?
I had a problem with SIMD.
When I chose the command SIMD_ENABLE = 0 this command SIMD_TARGET is AVX2 or SSE4. Older versions had NONE.
To compile google the PIK I had to delete the data in targets.h

#if SIMD_ENABLE & SIMD_AVX2
#define SIMD_TARGET AVX2
#elif SIMD_ENABLE & SIMD_SSE4
#define SIMD_TARGET SSE4
#elif SIMD_ENABLE & SIMD_PPC8
#define SIMD_TARGET PPC8
#elif SIMD_ENABLE & SIMD_ARM8
#define SIMD_TARGET ARM8
#else
#define SIMD_TARGET NONE
#endif

used comand eg -DSIMD_ENABLE=0, -DSIMD_TARGET=NONE and changed

#define SIMD_ENABLE 0 // (SIMD_SSE4 | SIMD_AVX2)

The program now compiles correctly in addition to af_edge_preserving_filter.cc
I compiled file af_epf.cctest.

Create image PIK:
cpik.exe image_21447.png output1.pik --distance 1.0 -v --print_profile 1 --num_threads 0

Read zu bytes (zuxzu px); compressing �I8HcĎMc└ˇD��i<MőZ�ˇ��l$LˇD��Y@H�»˛H�ppˇ��$PM�»éÉ, zu threads.
Compressed to zu bytes (0.00 MB/s).
Average butteraugli iters: 0.00
Total layer size header zd
Total layer size sections zd
Total layer size quant zd
Total layer size order zd
Total layer size cmap zd [ 0.00 zd zd zd 0.000]
Total layer size DC zd [ 31.00 zd zd zd 0.000]
Total layer size AC zd [ 64.00 zd zd zd 0.000]
Total image size zd [ 95.00 zd zd zd 0.000]

Print profile doesn't work

CPU does not support all enabled targets => exiting.

This can only happen if SIMD_ENABLE != 0. targets.h is currently overriding your -DSIMD_ENABLE=0.
We can fix the code to skip the reassignment. In the meantime, you can change
#define SIMD_ENABLE (SIMD_SSE4 | SIMD_AVX2) to
#define SIMD_ENABLE SIMD_NONE.

Read zu bytes (zuxzu px);

Oh, a format string problem. %zu is the correct specifier but it wasn't supported before MSVC 2013. Any way to update the compiler/toolchain?

Print profile doesn't work

Yes, that's correct. It is currently disabled, you can re-enable it by removing the " && 0" in profiler.h.

Thanks for the answer
I don't know what were the creator's assumptions, but for sse42 I have to add af_epf.cc twice for sse42 and none. Am I doing it correctly?
-DSIMD_TARGET=NONE -DSIMD_ENABLE=0 -DCV_CPU_COMPILE_SSE=1 -DCV_CPU_COMPILE_SSE2=1 -DCV_CPU_BASELINE_COMPILE_SSE=1 -DCV_CPU_BASELINE_COMPILE_SSE2=1 -DCV_CPU_BASELINE_FEATURES=0,CV_CPU_SSE,CV_CPU_SSE2

-DSIMD_TARGET=SSE4 -DSIMD_ENABLE=4 -DCV_CPU_COMPILE_SSE4_2=1 -DCV_CPU_BASELINE_COMPILE_SSE4_2=1 -DCV_CPU_BASELINE_FEATURES=0,CV_CPU_SSE4_2 -msse4.2 -maes

One more thing what Google recommends in OpenCV 4.0.0 beta cvconfig.in.

for sse42 I have to add af_epf.cc twice for sse42 and none.

af_epf.cctest should automatically be included multiple times (once for each SIMD_ENABLE bit, and 0) from af_edge_preserving_filter.cc. Why do you need to add it multiple times?

OK. How to compile af_edge_preserving_filter.cc is message.
af_edge_preserving_filter.cc:53:24: fatal error: af_epf.cctest: No such file or directory 53 | #define SIMD_ATTR_IMPL "af_epf.cctest"

You have af_epf.cctest in the same folder as af_edge_preserving_filter.cc, right? Does it help to add that directory to the compiler's include path?

You have af_epf.cctest in the same folder as af_edge_preserving_filter.cc, right?

Yes. I have af_edge_preserving_filter.cc in disc D:\

Does it help to add that directory to the compiler's include path?

No. I add #define SIMD_ATTR_IMPL "d:\af_epf.cctest"

Absolute paths are non-portable and expressly forbidden inside macros used with #include. But if it works for you at the moment, OK.

Happy New Year
I created once again Google PIK.

I used GCC 9.0.0 20181228
I added new OpenCV 20181228 / MINGW{mutex,thread,condition_variable} 20181227/ lodePNG 20181228
I added the definition ROI_DETECTOR_OPENCV / __OPENCV_BUILD and changed the links
#include <opencv2 / core.hpp>
#include <opencv2 / objdetect.hpp>
#include <opencv2 / imgproc.hpp>

I used only definition in opencv_modules.hpp
#define HAVE_OPENCV_CORE
#define HAVE_OPENCV_IMGPROC
#define HAVE_OPENCV_OBJDETECT
i delete all function with cvconfig.h except DirectX
I added PIK_ENABLE_ASSERT and PIK_CRASH_ON_ERROR

Now I don't have the %zu symbols.
PNM: no color_space hint given, assuming sRGB.
Read 6220817 bytes (1920x1080 px); compressing with maximum Butteraugli distance 1.000000, 0 threads.
Loading Haar Cascade: ./haarcascades/haarcascade_frontalface_default.xml
Loading Haar Cascade: ./haarcascades/haarcascade_profileface.xml
Loading Haar Cascade: ./haarcascades/haarcascade_eye.xml
Fine-Tuned 0 ROI-blocks (0.0%).
Compressed to 563578 bytes (0.04 MB/s).
Total clocks during analysis: 17609186
Total clocks measured: 432755870875

Happy belated new year :) FYI the OpenCV/haar features are no longer needed and we have a much improved/simplified cmake build.