windows make
1.babon
2.g++,gcc
3.vs2010
4.增加PATH
5.修改makefile中的4个空格->tab
6.make all -d 提示
getopt.c(45) : fatal error C1034: stdio.h: 不包括路径集
https://www.cnblogs.com/hiccup/p/5424009.html
出现错误“fatal error C1034: stdio.h: no include path set”,解决方法是在环境变量中新建LIB和INCLUDE变量,在LIB中设置如下值:“E:\Program Files\Microsoft Visual Studio 10.0\VC\lib”;在INCLUDE中设置如下值:“E:\Program Files\Microsoft Visual Studio 10.0\VC\include”
7. make all -d 提示
doexec.c(10) : fatal error C1083: 无法打开包括文件:“winsock2.h”: No such file or directory
查找了一下在C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include 中,手动添加到INCLUDE.
8. make all -d 提示
link: extra operand ‘netcat.obj’
解决:
https://stackoverflow.com/questions/19677870/error-in-assembly-masm-linker-link-extra-operand
查看babun的link whereis 发现没有使用windows的link ,
cp /cygdrive/c/Program\ Files\ \(x86\)/Microsoft\ Visual\ Studio\ 10.0/vc/bin/link.exe /usr/bin/
9.make all -d 提示
link getopt.obj doexec.obj netcat.obj kernel32.lib user32.lib wsock32.lib winmm.lib /nologo /subsystem:console /incremental:yes /machine:I386 /out:nc.exe
Putting child 0x8004ca68 (nc.exe) PID 2600 on the chain.
Live child 0x8004ca68 (nc.exe) PID 2600
LINK : warning LNK4224: /INCREMENTAL:YES is no longer supported; ignored
LINK : fatal error LNK1104: cannot open file 'kernel32.lib'
Reaping losing child 0x8004ca68 PID 2600
makefile:21: recipe for target 'nc.exe' failed
Removing child 0x8004ca68 PID 2600 from chain.
makefile如下定义
lflags=kernel32.lib user32.lib wsock32.lib winmm.lib /nologo /subsystem:console /incremental:yes /machine:I386 /out:nc.exe
nc.exe: getopt.obj doexec.obj netcat.obj
$(link) getopt.obj doexec.obj netcat.obj $(lflags)
查了一下三个lib的位置在C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\x64
加了一下LINK变量位置
参考: https://msdn.microsoft.com/zh-cn/library/6y6t9esh.aspx
LINK 工具使用以下环境变量:
LIB(如已定义)。 当 LINK 工具搜索在命令行上指定的对象、库或其他文件时或通过 /base 选项进行搜索时会使用 LIB 路径。 它还可使用 LIB 路径查找在对象上命名的 .pdb 文件。 LIB 变量可以包含一个或多个路径规范,用分号分隔。 一个路径必须指向 Visual C++ 安装的 \lib 子目录
10.make all -d提示大量
link getopt.obj doexec.obj netcat.obj kernel32.lib user32.lib wsock32.lib winmm.lib /nologo /subsystem:console /incremental:yes /machine:I386 /out:nc.exe
LINK : warning LNK4224: /INCREMENTAL:YES is no longer supported; ignored
doexec.obj : error LNK2019: unresolved external symbol _holler referenced in function _StartShell
LIBCMT.lib(lseeki64.obj) : error LNK2019: unresolved external symbol __imp__GetLastError@0 referenced in function __lseeki64_nolock
LIBCMT.lib(read.obj) : error LNK2001: unresolved external symbol __imp__GetLastError@0
LIBCMT.lib(close.obj) : error LNK2001: unresolved external symbol __imp__GetLastError@0
LIBCMT.lib(dup.obj) : error LNK2001: unresolved external symbol __imp__GetLastError@0
LIBCMT.lib(tidtable.obj) : error LNK2001: unresolved external symbol __imp__GetLastError@0
LIBCMT.lib(osfinfo.obj) : error LNK2001: unresolved external symbol __imp__GetLastError@0
LIBCMT.lib(wctomb.obj) : error LNK2001: unresolved external symbol __imp__GetLastError@0
LIBCMT.lib(realloc.obj) : error LNK2001: unresolved external symbol __imp__GetLastError@0
LIBCMT.lib(commit.obj) : error LNK2001: unresolved external symbol __imp__GetLastError@0
LIBCMT.lib(winsig.obj) : error LNK2001: unresolved external symbol __imp__GetLastError@0
LIBCMT.lib(rand_s.obj) : error LNK2001: unresolved external symbol __imp__GetLastError@0
LIBCMT.lib(inithelp.obj) : error LNK2001: unresolved external symbol __imp__GetLastError@0
doexec.obj : error LNK2001: unresolved external symbol __imp__GetLastError@0
[popexizhi:
grep 了一下holler在netcat中定义, 而link先写的doexec.obj,不知是不是这个问题,所以调整了一下顺序为
nc.exe: getopt.obj doexec.obj netcat.obj
$(link) getopt.obj netcat.obj doexec.obj $(lflags)
]
11.调整顺序后make all -d提示大量
link getopt.obj netcat.obj doexec.obj kernel32.lib user32.lib wsock32.lib winmm.lib /nologo /subsystem:console /incremental:yes /machine:I386 /out:nc.exe
LINK : warning LNK4224: /INCREMENTAL:YES is no longer supported; ignored
netcat.obj : error LNK2019: unresolved external symbol _WSACleanup@0 referenced in function _res_init
netcat.obj : error LNK2019: unresolved external symbol _WSAStartup@8 referenced in function _res_init
LIBCMT.lib(lseeki64.obj) : error LNK2001: unresolved external symbol __imp__GetLastError@0
LIBCMT.lib(read.obj) : error LNK2001: unresolved external symbol __imp__GetLastError@0
LIBCMT.lib(close.obj) : error LNK2001: unresolved external symbol __imp__GetLastError@0
LIBCMT.lib(dup.obj) : error LNK2001: unresolved external symbol __imp__GetLastError@0
LIBCMT.lib(tidtable.obj) : error LNK2001: unresolved external symbol __imp__GetLastError@0
LIBCMT.lib(osfinfo.obj) : error LNK2001: unresolved external symbol __imp__GetLastError@0
LIBCMT.lib(wctomb.obj) : error LNK2001: unresolved external symbol __imp__GetLastError@0
LIBCMT.lib(realloc.obj) : error LNK2001: unresolved external symbol __imp__GetLastError@0
LIBCMT.lib(commit.obj) : error LNK2001: unresolved external symbol __imp__GetLastError@0
LIBCMT.lib(winsig.obj) : error LNK2001: unresolved external symbol __imp__GetLastError@0
LIBCMT.lib(rand_s.obj) : error LNK2001: unresolved external symbol __imp__GetLastError@0
LIBCMT.lib(inithelp.obj) : error LNK2001: unresolved external symbol __imp__GetLastError@0
这个WSACleanup是
查了一下原代码为winsock2.h的引入为
#ifdef __MINGW32__
#include <_mingw .h="">
#include
#endif
手动加入了
#ifdef __MINGW32__
#include <_mingw .h="">
#include
#endif
#include "generic.h" /* same as with L5, skey, etc */
#include
编译如下错误
link getopt.obj netcat.obj doexec.obj kernel32.lib user32.lib wsock32.lib winmm.lib /nologo /subsystem:console /incremental:yes /machine:I386 /out:nc.exe
LINK : warning LNK4224: /INCREMENTAL:YES is no longer supported; ignored
netcat.obj : error LNK2019: unresolved external symbol __imp__WSACleanup@0 referenced in function _res_init
netcat.obj : error LNK2019: unresolved external symbol __imp__WSAStartup@8 referenced in function _res_init
LIBCMT.lib(lseeki64.obj) : error LNK2001: unresolved external symbol __imp__GetLastError@0
https://stackoverflow.com/questions/16948064/unresolved-external-symbol-lnk2019
#pragma comment(lib, "Ws2_32.lib")
查了一下这个Ws2_32.lib的位置,有三个自己之前再lib的定义中写的是x64用的,:).改成默认的C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib
12.调整lib后make all
出现如下问题:
link getopt.obj netcat.obj doexec.obj kernel32.lib user32.lib wsock32.lib winmm.lib /nologo /subsystem:console /incremental:yes /machine:I386 /out:nc.exe
LINK : warning LNK4224: /INCREMENTAL:YES is no longer supported; ignored
netcat.obj : error LNK2019: unresolved external symbol _strcasecmp referenced in function _comparehosts
doexec.obj : error LNK2019: unresolved external symbol _holler referenced in function _StartShell
nc.exe : fatal error LNK1120: 2 unresolved externals
makefile:23: recipe for target 'nc.exe' failed
解决:https://github.com/osmcode/libosmium/issues/59
这个strcasecmp是linux方法,不是windows的,好吧。
在comparehosts使用strcasecmp使用前增加如下:
#ifdef _MSC_VER
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
+#endif
13.调整lib后make all
出现如下问题:
doexec.obj : error LNK2019: unresolved external symbol _holler referenced in function _StartShell
nc.exe : fatal error LNK1120: 1 unresolved externals
makefile:23: recipe for target 'nc.exe' failed
分析:看来这个holler在StartShell使用没有定义,不是link的obj顺序问题。
解决: netcat.c中holler声明如下:
/* holler :
fake varargs -- need to do this way because we wind up calling through
more levels of indirection than vanilla varargs can handle, and not all
machines have vfprintf/vsyslog/whatever! 6 params oughta be enough. */
//static void holler (str, p1, p2, p3, p4, p5, p6) //popexizhi - add:这个是原始的声明方式
void holler (str, p1, p2, p3, p4, p5, p6) //popexizhi - add: 这个是修改后可以编译的
char * str;
char * p1, * p2, * p3, * p4, * p5, * p6;
{
if (o_verbose) {
fprintf (stderr, str, p1, p2, p3, p4, p5, p6);
#ifdef WIN32
if (h_errno)
fprintf (stderr, ": %s (%d:%ld)\n",winsockstr(h_errno), h_errno, GetLastError());
#else
if (errno) { /* this gives funny-looking messages, but */
perror (" "); /* it's more portable than sys_errlist[]... */
} /* xxx: do something better. */
#endif
else
fprintf (stderr, "\n");
fflush (stderr);
}
} /* holler */
https://www.jianshu.com/p/22ba3738fe71
ok这次终于编译通过了,编译的32位的
没有评论:
发表评论