wolfpld / tracy

Frame profiler
https://tracy.nereid.pl/
Other
8.99k stars 624 forks source link

error: capstone.h: No such file or directory #547

Open andrewrk opened 1 year ago

andrewrk commented 1 year ago

Tracy v0.9.1

[nix-shell:~/Downloads/tracy/profiler/build/unix]$ make
g++ -c  -I../../../imgui -I/nix/store/3jypdd47qjqvrv3p69vpw2iaddz3s51q-dbus-1.14.4-dev/include/dbus-1.0 -I/nix/store/wsjsjx85d0km8si2ghx1636q4n17p7nc-dbus-1.14.4-lib/lib/dbus-1.0/include -O3 -flto -s -march=native -std=c++17 -DNDEBUG -DIMGUI_ENABLE_FREETYPE ../../../server/TracySourceView.cpp -o obj/release/o/o/o/../../../server/TracySourceView.o
../../../server/TracySourceView.cpp:5:10: fatal error: capstone.h: No such file or directory
    5 | #include <capstone.h>
      |          ^~~~~~~~~~~~

the nix packages I have in this environment are:

      capstone
      cmake
      dbus
      freetype
      glfw
      gtk3-x11
      libxkbcommon
      ninja
      pkg-config
      tbb

capstone (4.0.2) is included.

andy@ark ~> nixos-version 
22.11.2912.d70f5cd5c3b (Raccoon)
andy@ark ~> uname -a
Linux ark 5.15.96 #1-NixOS SMP Sat Feb 25 11:06:46 UTC 2023 x86_64 GNU/Linux
[nix-shell:~/Downloads/tracy/profiler/build/unix]$ find /nix/store/nmmpnfxykqr9jyiyzyayna8fd7l73yqx-capstone-4.0.2/include/
/nix/store/nmmpnfxykqr9jyiyzyayna8fd7l73yqx-capstone-4.0.2/include/
/nix/store/nmmpnfxykqr9jyiyzyayna8fd7l73yqx-capstone-4.0.2/include/capstone
/nix/store/nmmpnfxykqr9jyiyzyayna8fd7l73yqx-capstone-4.0.2/include/capstone/tms320c64x.h
/nix/store/nmmpnfxykqr9jyiyzyayna8fd7l73yqx-capstone-4.0.2/include/capstone/sparc.h
/nix/store/nmmpnfxykqr9jyiyzyayna8fd7l73yqx-capstone-4.0.2/include/capstone/m68k.h
/nix/store/nmmpnfxykqr9jyiyzyayna8fd7l73yqx-capstone-4.0.2/include/capstone/arm.h
/nix/store/nmmpnfxykqr9jyiyzyayna8fd7l73yqx-capstone-4.0.2/include/capstone/mips.h
/nix/store/nmmpnfxykqr9jyiyzyayna8fd7l73yqx-capstone-4.0.2/include/capstone/capstone.h
/nix/store/nmmpnfxykqr9jyiyzyayna8fd7l73yqx-capstone-4.0.2/include/capstone/platform.h
/nix/store/nmmpnfxykqr9jyiyzyayna8fd7l73yqx-capstone-4.0.2/include/capstone/evm.h
/nix/store/nmmpnfxykqr9jyiyzyayna8fd7l73yqx-capstone-4.0.2/include/capstone/xcore.h
/nix/store/nmmpnfxykqr9jyiyzyayna8fd7l73yqx-capstone-4.0.2/include/capstone/m680x.h
/nix/store/nmmpnfxykqr9jyiyzyayna8fd7l73yqx-capstone-4.0.2/include/capstone/ppc.h
/nix/store/nmmpnfxykqr9jyiyzyayna8fd7l73yqx-capstone-4.0.2/include/capstone/x86.h
/nix/store/nmmpnfxykqr9jyiyzyayna8fd7l73yqx-capstone-4.0.2/include/capstone/systemz.h
/nix/store/nmmpnfxykqr9jyiyzyayna8fd7l73yqx-capstone-4.0.2/include/capstone/arm64.h
andrewrk commented 1 year ago

Fixed by:

diff --git a/server/TracySourceView.cpp b/server/TracySourceView.cpp
index 0cb01e50..d3071e57 100644
--- a/server/TracySourceView.cpp
+++ b/server/TracySourceView.cpp
@@ -2,7 +2,7 @@
 #include <inttypes.h>
 #include <stdio.h>

-#include <capstone.h>
+#include <capstone/capstone.h>

 #include "imgui.h"
 #include "TracyCharUtil.hpp"
diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp
index d3820076..4a354200 100644
--- a/server/TracyWorker.cpp
+++ b/server/TracyWorker.cpp
@@ -19,7 +19,7 @@
 #include <inttypes.h>
 #include <sys/stat.h>

-#include <capstone.h>
+#include <capstone/capstone.h>

 #define ZDICT_STATIC_LINKING_ONLY
 #include "../zstd/zdict.h"
wolfpld commented 1 year ago
[19:42 wolf@oberon:~]% pkg-config --cflags capstone
-I/usr/include/capstone
[19:42 wolf@oberon:~]% ls -l /usr/include/capstone/capstone.h
.rw-r--r-- 30k root 28 kwi  2022 /usr/include/capstone/capstone.h
[19:42 wolf@oberon:~]% pacman -Q capstone
capstone 4.0.2-6

This issue has surfaced earlier and there's no easy fix. See #170 and especially #429. Maybe I should use __has_include? Ugh...

andrewrk commented 1 year ago

Yeah that's unfortunate. I don't really know of a way to nicely solve this. The best I know how to do is to do it the way that feels the most "standard" to you, and relying on systems to provide patches to make it work for their nonstandard include paths. For me the "standard" way would be including the directory prefix in the #include sites (like the patch above) and then pointing the blame at distributions for not packaging this way.

If you're interested in considering it, I could provide a build.zig file for Tracy which would allow using the zig build system to provide most of the dependencies rather than relying on system packages, which might be nice for users who could then run zig build on any system (including Windows) rather than having to install a bunch of dependencies that are different across different systems (such as capstone). It might increase the "it just works" factor for some people.

wolfpld commented 1 year ago

The best I know how to do is to do it the way that feels the most "standard" to you, and relying on systems to provide patches to make it work for their nonstandard include paths. For me the "standard" way would be including the directory prefix in the #include sites (like the patch above) and then pointing the blame at distributions for not packaging this way.

Yeah, we're kinda at this point right now. The true culprit is that capstone has been in the RC phase for 5.0 for more than a year.

If you're interested in considering it, I could provide a build.zig file for Tracy

Thank you for the offer, but I don't think having another build system that would inevitably go out of the sync sooner rather than later would be beneficial to people. I'd rather have just one thing that works well.

viseztrance commented 1 year ago

Not really a fix, but for anyone else seeing the error, I just wanted to point out that the following would also work

make CFLAGS="-I/usr/include/capstone" # change to path that includes capstone.h
autoantwort commented 10 months ago

This seems to be a breaking change. Version 4 of capstone: #include <capstone/capstone.h> https://github.com/capstone-engine/capstone/blame/4.0.2/capstone.pc.in Version 5 of capstone: #include <capstone.h> https://github.com/capstone-engine/capstone/blame/5.0.1/capstone.pc.in https://github.com/microsoft/vcpkg/issues/34292