Cygwin compile Netcat 0.7.1 to generate an. exe file

Source: Internet
Author: User
Tags data structures lenovo

Turn from: https://blog.csdn.net/vah101/article/details/26229623

https://sourceforge.net/projects/netcat/files/

1. Preparation Environment

First, go to the www.cygwin.com download Cygwin installer Setup-x86_64.exe (or Setup-x86.exe), and then follow the installation prompts, and note that by default, Cygwin does not contain GCC, make, Patch and other common tools, you need additional installation methods, you can download gcc, make, patch to Cygwin in reference to the methods in the following links:

Http://www.cnblogs.com/aoaoblogs/archive/2012/10/31/2748712.html

http://hi.baidu.com/iwaters/item/328d05dde0cab3fd92a97406


The netcat needs to be downloaded to http://netcat.sourceforge.net/, the version used is 0.7.1, and the downloaded code packet is copied to the corresponding user list under the Cygwin root directory.


2. Play Patch

Native Netcat is working under Linux platform, some data structures are inconsistent with Windows platform, directly compiled words will report the following error:

UDPHELPER.C: In the function ' Udphelper_ancillary_read ':
UDPHELPER.C:90:42: Error: ' struct In_pktinfo ' does not have a member named ' IPI_SPEC_DST '
memcpy (&get_addr->sin_addr, &GET_PKTINFO->IPI_SPEC_DST,

This is because the IN_PKTINFO structure is different from the Linux platform on the Windows platform, and there is no IPI_SPEC_DST on the Windows platform, Cygwin for compatibility with Windows, there is no such item in the corresponding data structure.


For this problem, the solution is to netcat code patch, download patch URL in http://sourceforge.net/p/netcat/bugs/50/

Copy the patch to the Netcat directory in Cygwin and perform

Patch-p0 < Netcat-cygwin.patch

Note that if you do not patch this command, you can install the patch command (patch also in Devel subkeys) by referencing the installation of GCC.


3. Configure

Enter the Netcat directory, execute./configure, and then prompt for an error: Configure:error:cannot guess build type; You must specify one

Switch to./configure--build= "i686"


4. Compile

Run the make command directly, and the following problems occur:

/home/lenovo/netcat-0.7.1/src/core.c:225: References not defined for ' udphelper_ancillary_read '
/home/lenovo/netcat-0.7.1/src/core.c:225: (. text+0x3cb): Relocation truncated to FIT:R_X86_64_PC32 against Symbol ' Udphelper_ancillary_read '
COLLECT2: Error: LD return 1

By modifying the src/core.c file, add the following:

#include "proto.h"

The reason for this error is that CORE.C uses the Udphelper_ancillary_read function, which is declared in Proto.h, but core.c does not reference proto.h

Re-enter make, complete the compilation, in the NETCAT-0.7.1/SRC directory to generate Netcat.exe files, but this exe will be executed when the error "did not find Cygwin1.dll", The solution is to put the cygwin1.dll in the same directory as the EXE, or place the cygwin1.dll in the system directory such as Windows/system32, or add the cygwin1.dll path to the environment variable.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.