CNMAT / CNMAT-Externs

CNMAT Max/MSP externals
Other
96 stars 11 forks source link

randdist fails to compile on Win64 #137

Closed wagne342 closed 1 year ago

wagne342 commented 2 years ago

@maccallum @ramagottfried all CNMAT Externals currently compile on Windows under both Cygwin and MSYS2--with the solitary exception of randdist. It fails with a "multiple definitions error for each of the random distributions listed in libranddist.h and defined in libranddist.c.

x86_64-w64-mingw32-gcc -shared -static-libgcc -Wl,-Bstatic -lpthread  -o build/Release/randdist.mxe64 build/Release/randdist.o build/Release/commonsyms.o build/Release/libranddist.o -L../max-sdk-base/c74support/jit-includes -lx64/jitlib -L../max-sdk-base/c74support/max-includes -lx64/MaxAPI -L../max-sdk-base/c74support/msp-includes -lx64/MaxAudio -lm -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib -l:libgsl.a
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0x120): multiple definition of `ps_gaussian'; build/Release/randdist.o:randdist.c:(.bss+0x120): first defined here

...etc. for each ps_{distribution} t_symbol.

Normally, such an error is due to duplicate '#include' statements among dependencies, which may be the case here. I have encountered this before on MacOS where I think the solution was fixing my build of GSL or undoing a change of an Xcode setting. On Windows, one can force compilation by passing gcc '-Wl, --allow-multiple-definitions', but this feels like a band aid. Any insights would be appreciated.

wagne342 commented 2 years ago

Full error:

x86_64-w64-mingw32-gcc -shared -static-libgcc -Wl,-Bstatic -lpthread  -o build/Release/randdist.mxe64 build/Release/randdist.o build/Release/commonsyms.o build/Release/libranddist.o -L../max-sdk-base/c74support/jit-includes -lx64/jitlib -L../max-sdk-base/c74support/max-includes -lx64/MaxAPI -L../max-sdk-base/c74support/msp-includes -lx64/MaxAudio -lm -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib -l:libgsl.a
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0x120): multiple definition of `ps_gaussian'; build/Release/randdist.o:randdist.c:(.bss+0x120): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0x118): multiple definition of `ps_gaussian_tail'; build/Release/randdist.o:randdist.c:(.bss+0x118): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0x110): multiple definition of `ps_bivariate_gaussian'; build/Release/randdist.o:randdist.c:(.bss+0x110): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0x108): multiple definition of `ps_exponential'; build/Release/randdist.o:randdist.c:(.bss+0x108): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0x100): multiple definition of `ps_erlang'; build/Release/randdist.o:randdist.c:(.bss+0x100): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0xf8): multiple definition of `ps_laplace'; build/Release/randdist.o:randdist.c:(.bss+0xf8): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0xf0): multiple definition of `ps_exppow'; build/Release/randdist.o:randdist.c:(.bss+0xf0): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0xe8): multiple definition of `ps_cauchy'; build/Release/randdist.o:randdist.c:(.bss+0xe8): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0xe0): multiple definition of `ps_rayleigh'; build/Release/randdist.o:randdist.c:(.bss+0xe0): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0xd8): multiple definition of `ps_rayleigh_tail'; build/Release/randdist.o:randdist.c:(.bss+0xd8): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0xd0): multiple definition of `ps_landau'; build/Release/randdist.o:randdist.c:(.bss+0xd0): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0xc8): multiple definition of `ps_levy'; build/Release/randdist.o:randdist.c:(.bss+0xc8): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0xc0): multiple definition of `ps_levy_skew'; build/Release/randdist.o:randdist.c:(.bss+0xc0): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0xb8): multiple definition of `ps_gamma'; build/Release/randdist.o:randdist.c:(.bss+0xb8): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0xb0): multiple definition of `ps_uniform'; build/Release/randdist.o:randdist.c:(.bss+0xb0): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0xa8): multiple definition of `ps_lognormal'; build/Release/randdist.o:randdist.c:(.bss+0xa8): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0xa0): multiple definition of `ps_chisq'; build/Release/randdist.o:randdist.c:(.bss+0xa0): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0x98): multiple definition of `ps_f'; build/Release/randdist.o:randdist.c:(.bss+0x98): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0x90): multiple definition of `ps_t'; build/Release/randdist.o:randdist.c:(.bss+0x90): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0x88): multiple definition of `ps_beta'; build/Release/randdist.o:randdist.c:(.bss+0x88): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0x80): multiple definition of `ps_logistic'; build/Release/randdist.o:randdist.c:(.bss+0x80): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0x78): multiple definition of `ps_pareto'; build/Release/randdist.o:randdist.c:(.bss+0x78): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0x70): multiple definition of `ps_weibull'; build/Release/randdist.o:randdist.c:(.bss+0x70): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0x68): multiple definition of `ps_gumbel1'; build/Release/randdist.o:randdist.c:(.bss+0x68): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0x60): multiple definition of `ps_gumbel2'; build/Release/randdist.o:randdist.c:(.bss+0x60): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0x58): multiple definition of `ps_dirichlet'; build/Release/randdist.o:randdist.c:(.bss+0x58): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0x50): multiple definition of `ps_poisson'; build/Release/randdist.o:randdist.c:(.bss+0x50): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0x48): multiple definition of `ps_bernoulli'; build/Release/randdist.o:randdist.c:(.bss+0x48): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0x40): multiple definition of `ps_binomial'; build/Release/randdist.o:randdist.c:(.bss+0x40): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0x38): multiple definition of `ps_multinomial'; build/Release/randdist.o:randdist.c:(.bss+0x38): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0x30): multiple definition of `ps_negative_binomial'; build/Release/randdist.o:randdist.c:(.bss+0x30): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0x28): multiple definition of `ps_pascal'; build/Release/randdist.o:randdist.c:(.bss+0x28): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0x20): multiple definition of `ps_geometric'; build/Release/randdist.o:randdist.c:(.bss+0x20): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0x18): multiple definition of `ps_hypergeometric'; build/Release/randdist.o:randdist.c:(.bss+0x18): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0x10): multiple definition of `ps_multivariate_hypergeometric'; build/Release/randdist.o:randdist.c:(.bss+0x10): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0x8): multiple definition of `ps_logarithmic'; build/Release/randdist.o:randdist.c:(.bss+0x8): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/Release/libranddist.o:libranddist.c:(.bss+0x0): multiple definition of `ps_nonparametric'; build/Release/randdist.o:randdist.c:(.bss+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
make: *** [Makefile:166: build/Release/randdist.mxe64] Error 1
wagne342 commented 2 years ago

...this error appears to be avoided on MacOS due to the fact that randdist.c is compiled after libranddist. (You can generate the same error in Xcode by dragging randdist.c before libranddist.c. so it compiles first.) On the Windows build, if you force compilation of libranddist.c before building (just run the first line quoted above with the '-Wl, --allow-multiple-definitions'), then build again (without win-clean), everything is in its right place and order and the compiler is happy. So if I alter the Makefile to ensure libranddist.o is generated prior to randdist, that should take care of it.