You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Frama-C新手求助:打开C源文件时遇编译及解析错误

Fixing "event.h: No such file or directory" in Frama-C

Hey there! I’ve seen this exact issue a bunch of times with new Frama-C users—let’s get you sorted out quickly.

The root problem here is that Frama-C’s preprocessing step (which uses GCC under the hood) can’t find your event.h header file. By default, Frama-C only includes its own built-in libc paths and the current directory (-I.), but it doesn’t automatically scan your project’s other include directories.

Here’s how to fix it step by step:

  • Locate your event.h file first
    Run this command in your terminal to find where event.h lives on your system:

    find /home/xxx/Workspace -name event.h
    

    Let’s say it returns /home/xxx/Workspace/include/event.h—that include directory is what we need to tell Frama-C about.

  • Add the include path to your Frama-C command
    When you run Frama-C, add the -I flag followed by the directory containing event.h. For the example path above, your command would look like:

    frama-c -I /home/xxx/Workspace/include bipbuffer.c
    

    If you have multiple include directories, just add more -I flags (e.g., -I /path/first -I /path/second).

  • Optional: Make this permanent
    If you don’t want to type the -I flag every time, add it to Frama-C’s configuration file. Edit ~/.frama-c.conf and add a line like:

    -I /home/xxx/Workspace/include
    

    Now Frama-C will automatically include this path every time you run it.

  • Verify the fix manually (if needed)
    If you want to double-check the preprocessing step works, run the exact GCC command from your error log, but add the missing -I flag. For example:

    gcc -E -C -I. -dD -D__FRAMAC__ -nostdinc -D__FC_MACHDEP_X86_32 -I/usr/share/frama-c/libc -I /home/xxx/Workspace/include -o '/tmp/bipbuffer.ce6d077.i' '/home/xxx/Workspace/bipbuffer.c'
    

    If this command runs without errors, Frama-C should work perfectly afterward.

Just remember: Frama-C relies on GCC to handle preprocessing, so any include paths your project needs have to be explicitly passed in—Frama-C won’t guess them for you.

内容的提问来源于stack exchange,提问作者Raven

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 08:32:12