GNS3 / vpcs

Simple Virtual PC Simulator
BSD 2-Clause "Simplified" License
101 stars 39 forks source link

Fails to compile on Linux due to various errors (0.6.1 and 0.6.2) #39

Closed 20kdc closed 2 years ago

20kdc commented 2 years ago

Attempt to compile occurred on Ubuntu 22.04 Jammy Jellyfish. I am aware this is not released yet, but it is worth keeping in mind https://packages.ubuntu.com/source/jammy/vpcs for reference - alas this is of 0.5b2.

cd src ; ./mk.sh gives this result:

In file included from hv.c:45:
./getopt.h:53:5: error: conflicting types for ‘getopt’; have ‘int(int,  char **, char *)’
   53 | int getopt(int argc, char** argv, char* optstr);
      |     ^~~~~~
In file included from /usr/include/x86_64-linux-gnu/bits/getopt_posix.h:27,
                 from /usr/include/unistd.h:903,
                 from hv.c:33:
/usr/include/x86_64-linux-gnu/bits/getopt_core.h:91:12: note: previous declaration of ‘getopt’ with type ‘int(int,  char * const*, const char *)’
   91 | extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
      |            ^~~~~~
make: *** [Makefile.linux:37: hv.o] Error 1

Once getopt.h and getopt.c are removed, the resulting error shows up on linking:

gcc -m64 vpcs.o daemon.o readline.o packets.o utils.o queue.o command.o dev.o dhcp.o command6.o packets6.o ip.o tcp.o inet6.o dns.o remote.o help.o dump.o relay.o hv.o -o vpcs -lpthread -lutil -s -static 
/usr/bin/ld: packets.o:(.bss+0x0): multiple definition of `vpc'; vpcs.o:(.bss+0x60): first defined here
/usr/bin/ld: command.o:(.bss+0x0): multiple definition of `vpc'; vpcs.o:(.bss+0x60): first defined here
/usr/bin/ld: dev.o:(.bss+0x0): multiple definition of `vpc'; vpcs.o:(.bss+0x60): first defined here
/usr/bin/ld: dhcp.o:(.bss+0x0): multiple definition of `vpc'; vpcs.o:(.bss+0x60): first defined here
/usr/bin/ld: command6.o:(.bss+0x0): multiple definition of `vpc'; vpcs.o:(.bss+0x60): first defined here
/usr/bin/ld: packets6.o:(.bss+0x0): multiple definition of `vpc'; vpcs.o:(.bss+0x60): first defined here
/usr/bin/ld: tcp.o:(.bss+0x0): multiple definition of `vpc'; vpcs.o:(.bss+0x60): first defined here
/usr/bin/ld: dns.o:(.bss+0x0): multiple definition of `vpc'; vpcs.o:(.bss+0x60): first defined here
/usr/bin/ld: dump.o:(.bss+0x0): multiple definition of `vpc'; vpcs.o:(.bss+0x60): first defined here
/usr/bin/ld: relay.o:(.bss+0x0): multiple definition of `vpc'; vpcs.o:(.bss+0x60): first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile.linux:34: vpcs] Error 1
20kdc@Magnus:/media/modus/External2/gns3/vpcs-0.6.2/src$ 
20kdc commented 2 years ago

The former error... is "fixed" by deleting getopt.c and getopt.h, unless there's semantic differences I haven't caught. The latter error is because there's no extern on the vpc global declaration in vpcs.h. That in mind I will be sending a PR to fix the latter error.

20kdc commented 2 years ago

Ok, so what I didn't catch was that 9019b7fcfa89e5944e6c1ffba4a2e1f53899f4fa does fix said latter error. The problem is I can't use 0.8 because the last GNS3 release (gns3-server-2.2.31) tells me VPCS executable version must be >= 0.6.1 but not a 0.8. That in mind my PR will basically just be a backport of that commit to the 0.6 branch.

cristian-ciobanu commented 2 years ago

I'm running GNS3 version 2.2.31 with VPCS 0.8.2 compiled on ArchLinux and it works fine. That error message related to version 0.8 is misleading. I looked here on the GNS3 server code VPCS

and the minimum required version for VPCS is 0.6.1 but it does allow you to use higher versions like 0.8.x

20kdc commented 2 years ago

Ah. There is still the issue that GNS3 sources ship with the outdated VPCS - I'm not sure where to file that, though.

20kdc commented 2 years ago

In any case, 0.6 branch looks fine, so closing this