Compilation failure against libharu 2.4.x: too few arguments to function...
A library for scientific data visualization
Brought to you by:
abalakin
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);
Anonymous
This should be made conditional, based on HPDF_VERSION_MAJOR/MINOR, available from hpdf_version.h.
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:
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.
With libharu of 2.4.3
#include <hpdf_version.h>
is not required.Last edit: Dmitrij S. Kryzhevich 2022-10-17
I have the same error. What needs to be done for the compilation to complete successfully?