netdb.h not linking properly

前端 未结 4 2009
面向向阳花
面向向阳花 2021-02-05 17:06

I\'m trying to compile this program, as referenced in Beej\'s Guide to Network Programming on page 19.

#include 
#include          


        
4条回答
  •  半阙折子戏
    2021-02-05 17:31

    Linking doesn't attach a header file to the program, pre-processing handles header files.

    Linking attaches shared object libraries (look in /usr/lib) to compiled objects. Sometimes it is not sufficent to just add "-lnetdb" as the library might not be in the linker path. In that case, you need to use a -L(path) to add a path entry so the directive "-lnetdb" can find the correct netdb.so file.

提交回复
热议问题