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

Ubuntu 16.04编译PJSIP时遇‘EAGAIN未声明’错误求助

Fixing "EAGAIN undeclared" Error When Compiling PJSIP on Ubuntu 16.04 LTS 64-bit

I’ve run into this exact issue before when compiling PJSIP on Ubuntu 16.04 LTS 64-bit—when you run make, the compiler throws an error saying EAGAIN is undeclared in the pj_ioqueue_recv function, linked to the PJ_BLOCKING_ERROR_VAL macro in os_auto.h. Let’s break down how to fix this:

Why this happens

Ubuntu 16.04 uses GCC 5, and there’s a small mismatch in PJSIP’s compatibility header logic. EAGAIN is typically defined in <unistd.h> or <errno.h>, but the include order in PJSIP’s source files isn’t pulling it in properly before the macro tries to reference it.

Solutions to try

1. Patch the PJSIP compatibility header

Edit the file ../include/pj/compat/os_auto.h:

  • Scroll to the line where #define PJ_BLOCKING_ERROR_VAL EAGAIN is declared (around line 149 in your case).
  • Right above that line, add these lines to ensure EAGAIN is defined:
    #ifndef EAGAIN
    #define EAGAIN EWOULDBLOCK
    #endif
    
    Alternatively, you can just add an include for <unistd.h> at the top of the file, since it reliably includes the EAGAIN definition on Linux systems.

2. Pass the definition directly via configure

If you don’t want to modify the source files, you can define EAGAIN during the configure step:

./configure CFLAGS="-DEAGAIN=EWOULDBLOCK"

Then run make clean && make to rebuild from scratch. On Linux, EAGAIN and EWOULDBLOCK are functionally equivalent, so this works as a quick workaround.

3. Ensure system development packages are installed

Sometimes missing basic system headers can cause this issue. Make sure you have all the required build dependencies installed:

sudo apt-get update && sudo apt-get install build-essential libssl-dev libasound2-dev

This ensures you have the full set of standard C library headers and tools needed for compiling PJSIP.

After trying any of these steps, re-run make—the error should be gone, and compilation should proceed normally.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.21 06:28:57