On Thu, Jun 30, 2016 at 12:36 PM, Yang Luo <hslu...@gmail.com> wrote:

> Hi Guy,
>
> On Sat, Jun 25, 2016 at 12:09 AM, Guy Harris <g...@alum.mit.edu> wrote:
>
>> On Jun 24, 2016, at 8:58 PM, Yang Luo <hslu...@gmail.com> wrote:
>>
>> > I found that there are a lot of “precompiled source code files" like
>> grammar.c, scanner.c, grammar.h, ,scanner.h, etc. (which are also listed in
>> .gitignore). They are NOT contained in the libpcap repo.
>> >
>> > I personally want to ship them in the "Win32-Extensions" folder of the
>> Npcap repo, so the Npcap developers can just build the "libpcap.sln"
>> project with one click, and will get the wpcap.dll.
>> >
>> > Do you think this is a good idea? Or Windows developers should also
>> build everything from the bottom?
>>
>> You can either
>>
>>         1) install Flex and Bison yourself, use them to build those
>> files, and ship them with the Npcap source (along with the .y and .l files!)
>>
>> or
>>
>>         2) require that developers install Flex and Bison.
>>
>> You will need Flex 2.5.31 or later.  See, for example
>>
>>         https://sourceforge.net/projects/winflexbison/
>>
>> for Flex and Bison for Windows.
>>
>
> OK. I will choose option 2). Npcap developers should install Flex and
> Bison on their own machine and generate those files by their own hands.
> Now I have installed the latest Win-Flex-Bison on my own machine:)
>
>
>>
>> > I noticed this docs:
>> https://github.com/the-tcpdump-group/libpcap/blob/master/INSTALL.txt,
>> and it seems to require to run "./configure" (a shell script), which is for
>> Linux. So I think there's no Windows alternative config command for now?
>>
>> The autoconf script is UN*X-only.  (It's not "for Linux", it's for Linux
>> and OS X and FreeBSD and NetBSD and OpenBSD and DragonFly BSD and Solaris
>> and HP-UX and AIX and even, assuming it still works, older dead UN*Xes.)
>>
>> We also support CMake:
>>
>>         https://cmake.org
>>
>> on both UN*X *and* Windows.
>>
>
> OK then. I think I will first create a bat file to do the work.
> I have created a file named "prebuild.bat" in "libpcap\Win32", it contains
> two lines:
>
> win_flex -Ppcap_ -7 --outfile=..\scanner.c --header-file=..\scanner.h
> ..\scanner.l
> win_bison -ppcap_ --yacc --output=..\grammar.c --defines ..\grammar.y
>
> But I encountered an issue here, the built out scanner.h and scanner.c
> will report these errors:
>
> 1>  gencode.c
> 1>..\scanner.h(239): fatal error C1083: Cannot open include file:
> 'unistd.h': No such file or directory
> 1>  grammar.c
> 1>..\scanner.h(239): fatal error C1083: Cannot open include file:
> 'unistd.h': No such file or directory
> 1>..\scanner.c(2787): fatal error C1083: Cannot open include file:
> 'unistd.h': No such file or directory
>
> It seems that these generated source files want to include a UN*X only
> file "unistd.h", which is not available on Windows, like you said in the
> next reply. I think I need to switch some options to let Flex not use
> "unistd.h", how to do it?
>

OK. I found the solution. I changed the bat to:

win_flex -Ppcap_ -7 --nounistd --outfile=..\scanner.c
--header-file=..\scanner.h ..\scanner.l
win_bison -ppcap_ --yacc --output=..\grammar.c --defines ..\grammar.y

And Flex won't let the generated source filess require "unistd.h" any more.


>
> When this bat is done, I think I will make MSVC run this bat every time
> before a build process starts, is this solution OK for you?
>
>
>
>>
>> > And installing flex and bison for Windows are not also very friendly.
>>
>>         https://twitter.com/geraldcombs/status/735870968451629056
>
>
> In fact I didn't catch the meaning very well.. What's a "IKEA motorcycle
> engine"? I think "IKEA" is a furniture vendor? What does it has to do with
> the motorcycle engine? Does it mean that building open source on Windows is
> very painful and inconvenient?
>
>
> Cheers,
> Yang
>
>
>
>>
>>
>> > And I think those source files are less likely to change as frequently
>> as other sources.
>>
>> That is not necessarily true.  Any time new operators are added to the
>> packet filter language, either scanner.l or grammar.y or both will be
>> changed.
>
>
>> > I think just ship them in Npcap repo will be a good idea?
>>
>> We won't be putting the generated versions into the libpcap repository,
>> and I would *not* recommend putting them into the Npcap repository.  *If*
>> you want to provide the generated source files in the Npcap source release,
>> as they're provided in libpcap source releases, I would recommend that you
>> generate them as part of the process of building an Npcap source release.
>
>
>
_______________________________________________
tcpdump-workers mailing list
tcpdump-workers@lists.tcpdump.org
https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers

Reply via email to