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

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

Open
andrewrk opened this issue Apr 8, 2023 · 6 comments
Open

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

andrewrk opened this issue Apr 8, 2023 · 6 comments

Comments

@andrewrk
Copy link
Sponsor

andrewrk commented Apr 8, 2023

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
Copy link
Sponsor Author

andrewrk commented Apr 8, 2023

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
Copy link
Owner

wolfpld commented Apr 8, 2023

[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
Copy link
Sponsor Author

andrewrk commented Apr 8, 2023

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
Copy link
Owner

wolfpld commented Apr 8, 2023

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
Copy link

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
Copy link

autoantwort commented Oct 11, 2023

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
microsoft/vcpkg#34292

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

4 participants