Menu

#48 Compilation failure against libharu 2.4.x: too few arguments to function HPDF_Page_Create3DAnnot

v1.0_(example)
open
nobody
None
1
2023-11-03
2022-09-16
Atri
No

When building against libharu 2.4.2, mathgl fails to compile with the above mentioned error. In more details, here is a snippet from the build log:

[  265s] /home/abuild/rpmbuild/BUILD/python3.8_build/src/prc.cpp: In function 'void mgl_write_prc(HMGL, const char*, const char*, int)':
[  265s] /home/abuild/rpmbuild/BUILD/python3.8_build/src/prc.cpp:962:62: error: invalid conversion from 'HPDF_U3D' {aka '_HPDF_Dict_Rec*'} to 'HPDF_BOOL' {aka 'int'} [-fpermissive]
[  265s]   962 |                 annot = HPDF_Page_Create3DAnnot (page, rect, u3d );
[  265s]       |                                                              ^~~
[  265s]       |                                                              |
[  265s]       |                                                              HPDF_U3D {aka _HPDF_Dict_Rec*}
[  265s] /home/abuild/rpmbuild/BUILD/python3.8_build/src/prc.cpp:962:49: error: too few arguments to function '_HPDF_Dict_Rec* HPDF_Page_Create3DAnnot(HPDF_Page, HPDF_Rect, HPDF_BOOL, HPDF_BOOL, HPDF_U3D, HPDF_Image)'
[  265s]   962 |                 annot = HPDF_Page_Create3DAnnot (page, rect, u3d );
[  265s]       |                         ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
[  265s] In file included from /home/abuild/rpmbuild/BUILD/python3.8_build/src/prc.cpp:36:
[  265s] /usr/include/hpdf.h:478:1: note: declared here
[  265s]   478 | HPDF_Page_Create3DAnnot    (HPDF_Page       page,
[  265s]       | ^~~~~~~~~~~~~~~~~~~~~~~
[  265s] make[2]: *** [src/CMakeFiles/mgl.dir/build.make:765: src/CMakeFiles/mgl.dir/prc.cpp.o] Error 1

From looking at the libharu source code, HPDF_Page_Create3DAnnot (now) has a different signature with seven input parameters. Something like the following works — as in solves the compilation issue — but I am not sure if this is the right fix:

Index: mathgl-8.0.1/src/prc.cpp
===================================================================
--- mathgl-8.0.1.orig/src/prc.cpp
+++ mathgl-8.0.1/src/prc.cpp
@@ -959,7 +959,7 @@ void MGL_EXPORT mgl_write_prc(HMGL gr, c
        HPDF_U3D_SetDefault3DView(u3d, "DefaultView");

        //  Create annotation
-       annot = HPDF_Page_Create3DAnnot (page, rect, u3d );
+       annot = HPDF_Page_Create3DAnnot (page, rect, HPDF_FALSE, HPDF_FALSE, u3d, NULL);

        //  Enable toolbar
        HPDF_Dict action = (HPDF_Dict)HPDF_Dict_GetItem (annot, "3DA", HPDF_OCLASS_DICT);

Discussion

  • Anonymous

    Anonymous - 2022-09-19
    Post awaiting moderation.
  • Stefan Brüns

    Stefan Brüns - 2022-09-19

    This should be made conditional, based on HPDF_VERSION_MAJOR/MINOR, available from hpdf_version.h.

     
  • Atri

    Atri - 2022-09-21

    Following Stefan's advice, here is what I ended up doing, so that mathgl builds against libharu older as well as newer than or at version 2.4.0:

    Index: mathgl-8.0.1/src/prc.cpp
    ===================================================================
    --- mathgl-8.0.1.orig/src/prc.cpp
    +++ mathgl-8.0.1/src/prc.cpp
    @@ -36,6 +36,7 @@
     #include <hpdf.h>
     #include <hpdf_u3d.h>
     #include <hpdf_annotation.h>
    +#include <hpdf_version.h>
     #endif // MGL_HAVE_PDF
    
    
    @@ -959,7 +960,12 @@ void MGL_EXPORT mgl_write_prc(HMGL gr, c
            HPDF_U3D_SetDefault3DView(u3d, "DefaultView");
    
            //  Create annotation
    -       annot = HPDF_Page_Create3DAnnot (page, rect, u3d );
    +       annot
    +#if HPDF_VERSION_ID >= 20400
    +       = HPDF_Page_Create3DAnnot (page, rect, HPDF_FALSE, HPDF_FALSE, u3d, NULL);
    +#else
    +       = HPDF_Page_Create3DAnnot (page, rect, u3d);
    +#endif
    
            //  Enable toolbar
            HPDF_Dict action = (HPDF_Dict)HPDF_Dict_GetItem (annot, "3DA", HPDF_OCLASS_DICT);
    
     
  • Orion Poplawski

    Orion Poplawski - 2022-10-06

    FYI - I've filed https://github.com/libharu/libharu/pull/247 to request that hpdf_version.h be re-added to hpdf.h. No idea if it will be accepted or not. Directly including it though would still be required to support 2.4.0-.2.

     
  • Dmitrij S. Kryzhevich

    With libharu of 2.4.3 #include <hpdf_version.h> is not required.

     

    Last edit: Dmitrij S. Kryzhevich 2022-10-17
  • Mr.Smith1974

    Mr.Smith1974 - 2023-11-03

    I have the same error. What needs to be done for the compilation to complete successfully?

     

Anonymous
Anonymous

Add attachments
Cancel