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

could only build with change in /usr/include/graphviz/types.h #33

Open
cg-pasdzierny opened this issue Aug 20, 2023 · 8 comments
Open

Comments

@cg-pasdzierny
Copy link

hello,
I am pretty sure my fix is wrong but without changing

 line 49 #include <cgraph.h>

to
line 49 #include <graphviz/cgraph.h>

my build stopped with "cgraph.h not found".

I am using red hat rhel 7 with gcc 11.2.1 and graphviz-devel 2.30.1

Thanks, Martin.

@winterz
Copy link
Member

winterz commented Aug 20, 2023

which branch are you using?
please try master

@cg-pasdzierny
Copy link
Author

thanks for the reply.
I was using master via git.

@cg-pasdzierny
Copy link
Author

@winterz
Copy link
Member

winterz commented Aug 21, 2023

strange.
I don't see any files in the master branch that contain the line '#include <cgraph.h>'
which file do you see with that line?

@cg-pasdzierny
Copy link
Author

cg-pasdzierny commented Aug 23, 2023

hello,
as the title of this thread indicates it was
/usr/include/graphviz/types.h
which is a graphviz file.

I guess sth went wrong with the include paths passed to the compiler when it happened:

In file included from .../kdab-state-machine-editor/KDStateMachineEditor/src/core/layout/graphvizlayout/gvutils.h:19,
                 from .../kdab-state-machine-editor/KDStateMachineEditor/src/core/layout/graphvizlayout/gvutils.cpp:17:
/usr/include/graphviz/types.h:49:10: fatal error: cgraph.h: No such file or directory
   49 | #include <cgraph.h>
      |          ^~~~~~~~~~
compilation terminated.
make[2]: *** [src/core/CMakeFiles/kdstatemachineeditor_core.dir/build.make:398: src/core/CMakeFiles/kdstatemachineeditor_core.dir/layout/graphvizlayout/gvutils.cpp.o] Error 1
 

I attach both the cmake log and the complete make log file.
kdab-make-230823-030341.log
kdab-cmake-230823-030326.log

As written I managed to sucessfully build by changing the referred graphviz file, but of course that is wrong as it would break other graphviz based builds expecting graphviz devel files as they are ;)

@winterz
Copy link
Member

winterz commented Aug 25, 2023

you're right. sorry.

maybe we need to increase the minimum required graphviz version beyond 2.30.1 ?

another possibility is to pass -DWITH_INTERNAL_GRAPHVIZ=True to CMake, which will download and build version 2.48 for you. no idea if that still works

and yet another possibility is to add vcpkg support

@ferdnyc
Copy link

ferdnyc commented Jan 6, 2024

@winterz @cg-pasdzierny

It looks to me like the FindGraphviz.cmake discovery code is just wrong.

As written, it will discover the include path for a /usr/include/graphviz/cgraph.h as /usr/include/:

find_path(
GRAPHVIZ_INCLUDE_DIR
NAMES graphviz/graph.h graphviz/cgraph.h
HINTS ${_GRAPHVIZ_INCLUDE_DIR} ${_GRAPHVIZ_FIND_OPTS}
)

...But the Graphviz pkg-config data has the include path as /usr/include/graphviz. IOW, it expects that the graphviz subdirectory will be on the include path, as @cg-pasdzierny discovered:

$ pkg-config --cflags libcgraph        
-I/usr/include/graphviz

(This is with Graphviz 8.1.0 installed on Fedora 39, but I doubt it's changed anytime recently.)

@ferdnyc
Copy link

ferdnyc commented Jan 6, 2024

Looks to me like it should be,

find_path( 
  GRAPHVIZ_INCLUDE_DIR 
  NAMES cgraph.h graph.h 
  HINTS ${_GRAPHVIZ_INCLUDE_DIR}
  PATH_SUFFIXES graphviz
  ${_GRAPHVIZ_FIND_OPTS} 
)

(EDIT: Changed to look for cgraph.h first, as the less generic name.)

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