2

I am trying to install Nmap as a static binary. I have tried several configure/make stanzas. The error changes but the problem is the nsock dependency included in the Nmap source code.

I have a static binary for openssl and static lib for zlib.

Here is the latest stanzas and error (Note: long commands posted on multi-line for readability, in reality, they are 1 liners):

CPPFLAGS="-I/opt/laura/zlib-1.2.11 
          -I/opt/laura/openssl-1.1.0h_bis 
          -I/opt/laura/openssl-1.1.0h_bis/include
          -I./liblinear 
          -I./liblua 
          -I./libdnet-stripped/include 
          -I./libpcap 
          -I./nbase 
          -I./nsock 
          -I./nsock/include" LDFLAGS="-L/opt/laura/zlib-1.2.11 
          -L/opt/laura/openssl-1.1.0h_bis 
          -L./liblinear 
          -L./liblua 
          -L./libpcap 
          -L./nbase 
          -L./nsock" 
LIBS="-ldl" 
./configure --prefix=/opt/laura/nmap-7.70 
            --with-libz=/opt/laura/zlib-1.2.11/ 
            --with-openssl=/opt/laura/openssl-1.1.0h_bis/include/ 
            --with-libnsock=/opt/src/nmap-7.70/nsock

NMAP IS A POWERFUL TOOL -- USE CAREFULLY AND RESPONSIBLY
Configured with: ndiff zenmap nping openssl zlib libssh2 lua ncat
Configured without: localdirs nmap-update
Type make (or gmake on some *BSD machines) to compile.

make LDFLAGS="-L/opt/laura/zlib-1.2.11 
              -L/opt/laura/openssl-1.1.0h_bis 
              -L/opt/src/nmap-7.70/nsock -static"
[...]

Compiling nmap

rm -f nmap
g++ -L/opt/laura/zlib-1.2.11 -L/opt/laura/openssl-1.1.0h_bis -L/opt/src/nmap-7.70/nsock -static -o nmap charpool.o FingerPrintResults.o FPEngine.o FPModel.o idle_scan.o MACLookup.o nmap_dns.o nmap_error.o nmap.o nmap_ftp.o NmapOps.o NmapOutputTable.o nmap_tty.o osscan2.o osscan.o output.o payload.o portlist.o portreasons.o protocols.o scan_engine.o scan_engine_connect.o scan_engine_raw.o scan_lists.o service_scan.o services.o NewTargets.o TargetGroup.o Target.o targets.o tcpip.o timing.o traceroute.o utils.o xml.o  main.o -lnsock -lnbase -lpcre libpcap/libpcap.a libssh2/lib/libssh2.a -lssl -lcrypto -lz libnetutil/libnetutil.a ./libdnet-stripped/src/.libs/libdnet.a  ./liblinear/liblinear.a -ldl
/usr/bin/ld: cannot find -lnsock
collect2: ld returned 1 exit status
make: *** [nmap] Error 1

The nsock dir has the following content:

include  nsock.vcxproj  src  tests

In src dir is located the configure and nsock.h is located in include dir.

Any help?

KR

Nic3500
  • 8,144
  • 10
  • 29
  • 40
m00n
  • 21
  • 1
  • 3

1 Answers1

1

Nsock is always linked statically in Nmap. Using the --with-lib* options indicates where those libs are installed, but you've pointed it at the source. Just take the --with-libnsock option out of your configure line and it should build just fine. You'll probably also want to add --with-lib{pcap,pcre,z,ssh2,dnet,lua,linear}=included to build and statically-link the included libraries (unless you have static libraries built and installed elsewhere you would like to link to).

bonsaiviking
  • 5,825
  • 1
  • 20
  • 35