Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot build with mingw64 #155

Open
cslycord opened this issue Jun 26, 2020 · 2 comments
Open

Cannot build with mingw64 #155

cslycord opened this issue Jun 26, 2020 · 2 comments

Comments

@cslycord
Copy link

Won't build with mingw64 gcc/toolchain.

Linker complains of "undefined reference to `__imp__snprintf.constprop.0'"

This is a mingw64 64-bit toolchain inside msys2.

make make all-recursive make[1]: Entering directory '/home/tony/gifsicle' Making all in src make[2]: Entering directory '/home/tony/gifsicle/src' gcc -W -Wall -DHAVE_CONFIG_H -I. -I.. -I../include -g -O2 -MT clp.o -MD -MP -MF .deps/clp.Tpo -c -o clp.o clp.c mv -f .deps/clp.Tpo .deps/clp.Po gcc -W -Wall -DHAVE_CONFIG_H -I. -I.. -I../include -g -O2 -MT fmalloc.o -MD -MP -MF .deps/fmalloc.Tpo -c -o fmalloc.o fmalloc.c mv -f .deps/fmalloc.Tpo .deps/fmalloc.Po gcc -W -Wall -DHAVE_CONFIG_H -I. -I.. -I../include -g -O2 -MT giffunc.o -MD -MP -MF .deps/giffunc.Tpo -c -o giffunc.o giffunc.c mv -f .deps/giffunc.Tpo .deps/giffunc.Po gcc -W -Wall -DHAVE_CONFIG_H -I. -I.. -I../include -g -O2 -MT gifread.o -MD -MP -MF .deps/gifread.Tpo -c -o gifread.o gifread.c mv -f .deps/gifread.Tpo .deps/gifread.Po gcc -W -Wall -DHAVE_CONFIG_H -I. -I.. -I../include -g -O2 -MT gifunopt.o -MD -MP -MF .deps/gifunopt.Tpo -c -o gifunopt.o gifunopt.c mv -f .deps/gifunopt.Tpo .deps/gifunopt.Po gcc -W -Wall -DHAVE_CONFIG_H -I. -I.. -I../include -g -O2 -MT merge.o -MD -MP -MF .deps/merge.Tpo -c -o merge.o merge.c mv -f .deps/merge.Tpo .deps/merge.Po gcc -W -Wall -DHAVE_CONFIG_H -I. -I.. -I../include -g -O2 -MT optimize.o -MD -MP -MF .deps/optimize.Tpo -c -o optimize.o optimize.c mv -f .deps/optimize.Tpo .deps/optimize.Po gcc -W -Wall -DHAVE_CONFIG_H -I. -I.. -I../include -g -O2 -MT quantize.o -MD -MP -MF .deps/quantize.Tpo -c -o quantize.o quantize.c mv -f .deps/quantize.Tpo .deps/quantize.Po gcc -W -Wall -DHAVE_CONFIG_H -I. -I.. -I../include -g -O2 -MT support.o -MD -MP -MF .deps/support.Tpo -c -o support.o support.c mv -f .deps/support.Tpo .deps/support.Po gcc -W -Wall -DHAVE_CONFIG_H -I. -I.. -I../include -g -O2 -MT xform.o -MD -MP -MF .deps/xform.Tpo -c -o xform.o xform.c mv -f .deps/xform.Tpo .deps/xform.Po gcc -W -Wall -DHAVE_CONFIG_H -I. -I.. -I../include -g -O2 -MT gifsicle.o -MD -MP -MF .deps/gifsicle.Tpo -c -o gifsicle.o gifsicle.c mv -f .deps/gifsicle.Tpo .deps/gifsicle.Po gcc -W -Wall -DHAVE_CONFIG_H -I. -I.. -I../include -g -O2 -MT gifwrite.o -MD -MP -MF .deps/gifwrite.Tpo -c -o gifwrite.o gifwrite.c mv -f .deps/gifwrite.Tpo .deps/gifwrite.Po gcc -W -Wall -g -O2 -o gifsicle.exe clp.o fmalloc.o giffunc.o gifread.o gifunopt.o merge.o optimize.o quantize.o support.o xform.o gifsicle.o gifwrite.o C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: gifsicle.o: in functiongifread_error':
C:\msys64\home\tony\gifsicle\src/gifsicle.c:547: undefined reference to __imp__snprintf.constprop.0' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\msys64\home\tony\gifsicle\src/gifsicle.c:550: undefined reference to __imp__snprintf.constprop.0'
collect2.exe: error: ld returned 1 exit status
make[2]: *** [Makefile:385: gifsicle.exe] Error 1
make[2]: Leaving directory '/home/tony/gifsicle/src'
make[1]: *** [Makefile:452: all-recursive] Error 1
make[1]: Leaving directory '/home/tony/gifsicle'
make: *** [Makefile:350: all] Error 2`

@wjaguar
Copy link

wjaguar commented Dec 21, 2020

Encountered the same problem today (gcc 10.2.0 in MXE), found a workaround based on this:
https://stackoverflow.com/questions/21936012/a-c-linking-error
Namely: feeding CFLAGS=-fno-ipa-cp-clone to ./configure gets rid of the error.

@wjaguar
Copy link

wjaguar commented Dec 21, 2020

Correction: the above worked by coincidence - set CFLAGS preempted the default -O2.
The actual fix is either reducing the optimization level to -O1, or adding -fno-ipa-cp to -O2: CFLAGS='-O2 -fno-ipa-cp'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants