dynamips icon indicating copy to clipboard operation
dynamips copied to clipboard

compile in MinGW

Open flaviojs opened this issue 12 years ago • 13 comments

dynamips doesn't compile in MinGW. Currently it can compile in Cygwin by relying on it's posix-ness.

Tasks:

  • lock files

    use https://github.com/epi/xedisk/wiki/File-locking as reference

  • missing header sys/mmap.h

    memory mapped files, can be replaced with windows.h (WinXP+)

    mmap -> CreateFileMapping + MapViewOfFile

    munmap -> UnmapViewOfFile

    msync -> FlushViewOfFile (asynchronous, so not exactly what we need)

    consider moving memzone_* functions from utils.c to a separate file memzone.c

  • missing header uuid/uuid.h

    external library, can be replaced with Rpc.h (Win2000+)

    create compatible functions

    uuid_t <-> UUID - convert Data1 with htonl/ntohl, convert Data2 and Data3 with htons/ntohs

    uuid_generate -> UuidCreateNil + UuidCreate

    uuid_parse -> UuidFromString

    uuid_unparse -> UuidToString

    uuid_compare -> UuidCompare

  • missing headers sys/socket.h + sys/un.h + arpa/inet.h + netdb.h + netinet/in.h

    sockets, can be replaced with winsock2.h + ws2tcpip.h (WinXP+ or WinVista+)

    most IPv6 stuff is WinVista+, ~~try to implement it for WinXP+?~~ (WinXP is EOL now)

    struct sockaddr_un doesn't exist, filter out code that needs it

  • other missing headers

    ~~arpa/inet.h - dev_vtty.c, gen_eth.c, hv_atmsw.c, hv_atm_bridge.c, hv_c1700.c, hv_c2600.c, hv_c2691.c, hv_c3600.c, hv_c3725.c, hv_c3745.c, hv_c7200.c, hv_ethsw.c, hv_frsw.c, hv_nio.c, hv_nio_bridge.c, hv_store.c, hv_vm_debug.c, net.c, net_io.c, net_io_filter.c, parser.c, timer.c, utils.c, hv_vm.c, hypervisor.c~~ arpa/telnet.h- dev_vtty.c dlfcn.h - plugin.c ~~netdb.h - dev_vtty.c, gen_eth.c, net.c, net_io.c, net_io_filter.c, timer.c, utils.c~~ ~~netinet/in.h - gen_eth.c, net_io.c, net_io_filter.c, timer.c, utils.h(!!)~~ netinet/tcp.h - dev_vtty.c sys/ioctl.h - gen_eth.c, hv_atmsw.c, hv_atm_bridge.c, hv_c1700.c, hv_c2600.c, hv_c2691.c, hv_c3600.c, hv_c3725.c, hv_c3745.c, hv_c7200.c, hv_ethsw.c, hv_frsw.c, hv_nio.c, hv_nio_bridge.c, hv_store.c, hv_vm_debug.c, net.c, net_io.c, net_io_filter.c, parser.c, utils.c, hv_vm.c, hypervisor.c ~~sys/mman.h - utils.c~~ sys/select.h - atm.c, atm_bridge.c, atm_vsar.c, eth_switch.c, frame_relay.c, net_io_bridge.c ~~sys/socket.h - cisco_eeprom.c, dev_vtty.c, gen_eth.c, hv_atmsw.c, hv_atm_bridge.c, hv_c1700.c, hv_c2600.c, hv_c2691.c, hv_c3600.c, hv_c3725.c, hv_c3745.c, hv_c7200.c, hv_ethsw.c, hv_frsw.c, hv_nio.c, hv_nio_bridge.c, hv_store.c, hv_vm_debug.c, net.c, net_io.c, net_io.h(!!), net_io_filter.c, net_io_filter.h(!!), parser.c, ptask.h(!!), timer.c, utils.c, hv_vm.c, hypervisor.c~~ sys/uio.h - atm_vsar.c ~~sys/un.h - net_io.c, net_io.h(!!), net_io_filter.c, net_io_filter.h(!!), ptask.h(!!)~~ sys/wait.h - gen_eth.c, net_io.c, net_io_filter.c, registry.c termios.h - dev_c1700_iofpga.c, dev_c2600_iofpga.c, dev_c2691_iofpga.c, dev_c3600_iofpga.c, dev_c3725_iofpga.c, dev_c3745_iofpga.c, dev_c6msfc1_iofpga.c, dev_c6sup1_iofpga.c, dev_c7200_iofpga.c, dev_ds1620.c, dev_ns16552.c, dev_sb1.c, dev_sb1_io.c, dev_vtty.c

  • consider adding a global include, like all.h, to be included before anything else.

    all OS/compiler juggling can be put in there, as well as common includes.

    currently utils.h serves that purpose, along with providing utility functions.

  • check all longs

    in windows it's always 32-bits, in linux it's either 32-bits or 64-bits (size of pointer)

  • find more stuff that needs changing...

  • ~~make it compile with CMake (optional)~~ - cmake is supported now

flaviojs avatar Sep 13 '13 22:09 flaviojs

Indeed, not having to rely on Cygwin would be great.

grossmj avatar Feb 07 '14 23:02 grossmj

for mmap it look like this might a solution: http://code.google.com/p/mman-win32/

TwoWheelDev avatar Sep 23 '14 17:09 TwoWheelDev

I just tried compiling an application that includes uuid/uuid.h and x86_64-w64-mingw32-gcc complains that "uuid/uuid.h": No such file or directory. Is this because libuuid(3) isn't supported by mingw?

hertzsprung avatar May 24 '15 20:05 hertzsprung

I have it building on MinGW. Oddly enough the 'stable' branch runs the MIPS64 JIT quite nicely, while the unstable branch runs the PPC32 JIT. Libuuid will conflict with windows built in uuid support so the fix there is it rename libuuid's uuid_t to something like uu_uuid_t and all references to it in Dynamips. Of course, don't forget to rename the library file, otherwise you'll overwrite the system libuuid.a !

There is some stuff to mess around with sockets in the hypervisor, as Win32 can't treat a socket like a stdio device, but I have it to the point where dynagen 0.11 can talk to dynamips.

I put my stuff here: http://sourceforge.net/projects/dynamips-mingw/

Also I have it compiling with TDM-GCC-64, although none of the JIT works. But it does work interpreted!

neozeed avatar Sep 12 '15 02:09 neozeed

@neozeed we have recently remove the libuuid dependency. Have you made progress?

grossmj avatar Mar 23 '16 23:03 grossmj

I never had issues once I renamed uuid to uu_uuid. But now that I see it's updated, I can pull and re-merge my stuff.

Oh yeah, and doing winpcap dynamically is SO much more nicer, than having it statically linked in. It makes doing demos much more easier without having to install things.

neozeed avatar Apr 03 '16 19:04 neozeed

Sounds good, let me know how that goes.

Thanks :)

grossmj avatar Apr 04 '16 02:04 grossmj

I've got a first pass.... and I still ended up cutting it in half, MIPS from stable, and PowerPC from unstable. Both seem to be somewhat behaved. I've booted 7200 MIPS, and 1700 PPC IOS ok. The pcap code needs to be made more dynamic for UNIX. I've done it before, I just have to find it and put it in there.

I've separated all the bits that are missing from MinGW into the contrib folder.

Also I've been going in circles on the vty code, so for now Im just using an older version of that file. It works 'well enough for now'. Just go into the 'merge' directory and run make, as it's all MinGW32. I guess I should rename merge to mingw..

neozeed avatar Apr 07 '16 18:04 neozeed

Looks like you did a good job :+1: I will be away for the next couple of week, so I won't be able to test before a while. I will post back when I do.

Thanks again! :)

grossmj avatar Apr 07 '16 20:04 grossmj

I forgot, I had to make the unix & vde transports optional as a #ifdef UNIX_ETH & VDE_ETH since Win32 has no good analogue.

neozeed avatar Apr 08 '16 00:04 neozeed

Awesome

On Fri, Apr 8, 2016 at 2:25 AM neozeed [email protected] wrote:

I forgot, I had to make the unix & vde transports optional as a #ifdef UNIX_ETH & VDE_ETH since Win32 has no good analogue.

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/GNS3/dynamips/issues/18#issuecomment-207147925

julien-duponchelle avatar Apr 08 '16 07:04 julien-duponchelle

I really really need to revisit all of this. You know how live (new kids) and overwhelming jobs go. :|

On a long trip I was reading that book infrastructure as code, and Ive been trying to get to that point for years but it's nice to see it just spelt out. And time to re-tackle dynamips.

neozeed avatar Nov 29 '16 07:11 neozeed

No worries. I am very interested for a version of Dynamips compiled with MinGW.

On Tue, Nov 29, 2016, 18:17 neozeed [email protected] wrote:

I really really need to revisit all of this. You know how live (new kids) and overwhelming jobs go. :|

On a long trip I was reading that book infrastructure as code, and Ive been trying to get to that point for years but it's nice to see it just spelt out. And time to re-tackle dynamips.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/GNS3/dynamips/issues/18#issuecomment-263494955, or mute the thread https://github.com/notifications/unsubscribe-auth/AEiE5jwYJpEmpEFM3vjiHDmCJrK_4reJks5rC9GVgaJpZM4A_yL3 .

grossmj avatar Dec 07 '16 22:12 grossmj