Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

UNIX network programming _ volume I _ environment building

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Construction of UNIX Network programming (Volume I) Environment

-- solving the problem of unp.h compilation

1. Install the compiler, and whether or not to install build-essential in order to complete the situation.

Sudo apt-get install build-essential

2. Download the header file and sample source code of this book

Original book address: www.turingbook.com

3. After decompressing unpv13e.tar.gz, go to the directory to view README, and then you can follow the instructions inside. You may encounter problems in Ubuntu environment. Take Ubuntu12.04LTS as an example:

Step 1: enter the upnv13e directory in the terminal, and then execute the code:

1. Chmod Ubunx configure # Grant execution permission

2.. / configure

Step 2: go to the lib directory and execute make:

1. Cd lib

2. Make

Step 3: establish a basic class library:

1. Cd.. / libfree

2. Make

Step 4: compile the function library:

1. Cd.. / libgai

2. Make

4. Copy the generated libunp.a static library to / usr/lib/ and / usr/lib64/.

1. Cd..

2. Sudo cp libunp.a / usr/lib

3. Sudo cp libunp.a / usr/lib64

5. Modify unp.h and copy unp.h and config.h to / usr/include to facilitate the inclusion of header files in the future

1. Vim lib/unp.h / / modify # include ".. / config.h" in unp.h to # include "config.h"

2. Sudo cp lib/unp.h / usr/include

3. Sudo cp config.h / usr/include

6. Compile the source code

1. Cd. / intro

2. Gcc daytimetcpcli.c-o daytimetcpcli-l unp

If an error is found:

Daytimetcpcli.c:1:17: fatal error: / usr/include/unp.h: insufficient permissions

Solution:

1. Delete the / usr/include/unp.h file:

Sudo rm / usr/include/unp.h

two。 Go to the lib file under the unpv13e directory to find unp.h,chmod, and change its permission to read-write, or read-only

3. Copy the unp.h file again:

Sudo cp lib/unp.h / usr/include

Done.

What is different from normal compilation is to add the link library at the end, the-l parameter plus the libunp.a to remove lib and the following .a. Finally, the parameter-l unp is obtained.

7, write a program

Later, the code in installation 6 will be compiled, and then the code can be exactly the same as in the book. You just need to add-l unp when compiling. Otherwise, there will be a failure!

Such as: gcc test.c-l unp

Original reference: http://blog.csdn.net/a649518776/article/details/6724121

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report