#include <sys/socket.h>找不到头文件

来源:互联网 发布:mac程序删除 编辑:程序博客网 时间:2024/05/16 03:36
    ubuntu下socket编程涉及到头文件sys/socket.h 和sys/types.h。我是用的codeblocks编辑器,当我想查看socket,h头文件时编辑器提示找不到头文件。

           我就想可能是没有设置codeblocks头文件的搜索路径。好吧,那首先就找找这个文件藏在哪里吧

[cpp] view plain copy print?在CODE上查看代码片派生到我的代码片
  1. <span style="font-size:12px;">find / -name socket.h -print  
  2. 或者locate sys/socket.h</span>  
            结果显示文件位置为/usr/include/x86_64-linux-gnu/sys/socket.h。我们打开codeblocks——》settting——》compiler——》search directories ,点击add,新增一条路径为

/usr/include/x86_64-Linux-gnu/sys/

              重新开始编译文件,选中sys/socket.h右键"open #include <sys/socket.h>"结果居然还是显示

                                                                                

            这就让人很是尴尬啦,明明已经找到路径添加完成结果编辑器还是提示找不到。一番搜索查找好终于找到解决方法。Fix by using the following code:

[cpp] view plain copy print?在CODE上查看代码片派生到我的代码片
  1. sudo apt-get install build-essential flex libelf-dev libc6-dev-amd64 binutils-dev libdwarf-dev  
           安装完成后我们会在/usr/include下发现一个sys文件夹。这时我们就可以顺利查看sys/socket.h头文件了。编辑器的提示功能也可以正常使用了。           但打开/usr/include/sys目录发现里面都是链接文件,socket.h的连接地址其实还是指向了/usr/include/x86_64-linux-gnu/sys/socket.h。修复环境后没有设置查找路径编辑器就可以找到,未修复前添加文件的查找路径后却依然无法找到,这点也是弄不明白。
0 0
原创粉丝点击