Ruby/C/Makefile,-lpcap/#include中使用的默认 pcap.h 文件是什么?

发布于 2024-10-05 06:42:18 字数 857 浏览 6 评论 0原文

如何确定通过 Makefile 编译/安装的 C 源代码中包含哪些 pcap.h 文件?

具体来说,它是一个 Ruby 库 (pcaprub),通过以下方式安装:

ruby extconf.rb && make && make install

extconf.rb 是:

require 'mkmf'

if /i386-mswin32/ =~ RUBY_PLATFORM
    pcap_dir        = with_config("pcap-dir", "C:\WpdPack")
    pcap_includedir = with_config("pcap-includedir", pcap_dir + "\\include")
    pcap_libdir     = with_config("pcap-libdir", pcap_dir + "\\lib")

    $CFLAGS  = "-DWIN32 -I#{pcap_includedir}"
    $LDFLAGS = "/link /LIBPATH:#{pcap_libdir}"
    have_library("wpcap", "pcap_open_live")
    have_library("wpcap", "pcap_setnonblock")
else
    have_library("pcap", "pcap_open_live")
    have_library("pcap", "pcap_setnonblock")
end

if ( RUBY_VERSION =~ /^1\.9/ )
    $CFLAGS += " -DRUBY_19"
end

create_makefile("pcaprub")

How can I determine what pcap.h file is being included in a C source that is being compiled/installed via a Makefile?

Specifically, it is a Ruby library (pcaprub) that is being installed via:

ruby extconf.rb && make && make install

and the extconf.rb is:

require 'mkmf'

if /i386-mswin32/ =~ RUBY_PLATFORM
    pcap_dir        = with_config("pcap-dir", "C:\WpdPack")
    pcap_includedir = with_config("pcap-includedir", pcap_dir + "\\include")
    pcap_libdir     = with_config("pcap-libdir", pcap_dir + "\\lib")

    $CFLAGS  = "-DWIN32 -I#{pcap_includedir}"
    $LDFLAGS = "/link /LIBPATH:#{pcap_libdir}"
    have_library("wpcap", "pcap_open_live")
    have_library("wpcap", "pcap_setnonblock")
else
    have_library("pcap", "pcap_open_live")
    have_library("pcap", "pcap_setnonblock")
end

if ( RUBY_VERSION =~ /^1\.9/ )
    $CFLAGS += " -DRUBY_19"
end

create_makefile("pcaprub")

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

舞袖。长 2024-10-12 06:42:18

您可以查看生成的 Makefile 以了解哪些 -I 选项被传递给 gcc 吗?您还可以将 -H 传递给 gcc 以显示它最终使用的头文件:

 -H 打印所使用的每个头文件的名称,以及其他
       正常活动。每个名称都缩进以显示其深度
       #include 堆栈就是这样。还打印预编译头文件,
       即使它们被发现无效;无效的预编译头
       文件打印有 ...x 且有效文件打印有 ...! 。

Can you look at the generated Makefile to see what -I options are being passed to gcc? You can also pass -H to gcc to display the header file that it ends up using:

   -H  Print the name of each header file used, in addition to other
       normal activities.  Each name is indented to show how deep in the
       #include stack it is.  Precompiled header files are also printed,
       even if they are found to be invalid; an invalid precompiled header
       file is printed with ...x and a valid one with ...! .
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文