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

To support MinGW cross compiler #1275

Closed
wants to merge 1 commit into from
Closed

Conversation

mcuee
Copy link
Collaborator

@mcuee mcuee commented Jan 11, 2023

This patch is necessary to support MinGW cross compiler.

It is adapted from Arduino avrdude-packing project.
https://github.com/arduino/avrdude-packing/blob/main/patches/0007-Cmake-fix-build-not-working-with-mingw-toolchain.patch

@mcuee mcuee added the enhancement New feature or request label Jan 11, 2023
@mcuee
Copy link
Collaborator Author

mcuee commented Jan 11, 2023

Without this patch, the failure is like the following github action run.
https://github.com/mcuee/avrdude-packing/actions/runs/3889057820

[ 97%] Linking C executable avrdude
cd /__w/avrdude-packing/avrdude-packing/avrdude/build/src && /usr/bin/cmake -E cmake_link_script CMakeFiles/avrdude.dir/link.txt --verbose=1
/usr/bin/i686-w64-mingw32-gcc -I/opt/lib/i686-w64-mingw32/include/libusb-1.0/ -I/opt/lib/i686-w64-mingw32/include -pthread  -static-libgcc -static-libstdc++ CMakeFiles/avrdude.dir/main.c.o CMakeFiles/avrdude.dir/term.c.o CMakeFiles/avrdude.dir/avrintel.c.o CMakeFiles/avrdude.dir/developer_opts.c.o CMakeFiles/avrdude.dir/whereami.c.o  -o avrdude  libavrdude.a -lm /opt/lib/i686-w64-mingw32/lib/libelf.a /opt/lib/i686-w64-mingw32/lib/libusb.a /opt/lib/i686-w64-mingw32/lib/libusb-1.0.a /opt/lib/i686-w64-mingw32/lib/libhidapi.a /opt/lib/i686-w64-mingw32/lib/libftdi1.a /opt/lib/i686-w64-mingw32/lib/libreadline.a /opt/lib/i686-w64-mingw32/lib/libncurses.a 
/usr/bin/i686-w64-mingw32-ld: libavrdude.a(ser_win32.c.o):ser_win32.c:(.text+0x206): undefined reference to `_imp__WSAStartup@8'
/usr/bin/i686-w64-mingw32-ld: libavrdude.a(ser_win32.c.o):ser_win32.c:(.text+0x408): undefined reference to `_imp__gethostbyname@4'
/usr/bin/i686-w64-mingw32-ld: libavrdude.a(ser_win32.c.o):ser_win32.c:(.text+0x49f): undefined reference to `_imp__socket@12'
/usr/bin/i686-w64-mingw32-ld: libavrdude.a(ser_win32.c.o):ser_win32.c:(.text+0x4b6): undefined reference to `_imp__WSAGetLastError@0'
/usr/bin/i686-w64-mingw32-ld: libavrdude.a(ser_win32.c.o):ser_win32.c:(.text+0x59b): undefined reference to `_imp__htons@4'
/usr/bin/i686-w64-mingw32-ld: libavrdude.a(ser_win32.c.o):ser_win32.c:(.text+0x5d4): undefined reference to `_imp__connect@12'
/usr/bin/i686-w64-mingw32-ld: libavrdude.a(ser_win32.c.o):ser_win32.c:(.text+0x5e6): undefined reference to `_imp__WSAGetLastError@0'
/usr/bin/i686-w64-mingw32-ld: libavrdude.a(ser_win32.c.o):ser_win32.c:(.text+0xa7e): undefined reference to `_imp__closesocket@4'
/usr/bin/i686-w64-mingw32-ld: libavrdude.a(ser_win32.c.o):ser_win32.c:(.text+0xa88): undefined reference to `_imp__WSACleanup@0'
/usr/bin/i686-w64-mingw32-ld: libavrdude.a(ser_win32.c.o):ser_win32.c:(.text+0xdaa): undefined reference to `_imp__send@16'
/usr/bin/i686-w64-mingw32-ld: libavrdude.a(ser_win32.c.o):ser_win32.c:(.text+0xdc1): undefined reference to `_imp__WSAGetLastError@0'
/usr/bin/i686-w64-mingw32-ld: libavrdude.a(ser_win32.c.o):ser_win32.c:(.text+0x134f): undefined reference to `_imp__select@20'
/usr/bin/i686-w64-mingw32-ld: libavrdude.a(ser_win32.c.o):ser_win32.c:(.text+0x13c6): undefined reference to `_imp__WSAGetLastError@0'
/usr/bin/i686-w64-mingw32-ld: libavrdude.a(ser_win32.c.o):ser_win32.c:(.text+0x13d4): undefined reference to `_imp__WSAGetLastError@0'
/usr/bin/i686-w64-mingw32-ld: libavrdude.a(ser_win32.c.o):ser_win32.c:(.text+0x142d): undefined reference to `_imp__WSAGetLastError@0'
/usr/bin/i686-w64-mingw32-ld: libavrdude.a(ser_win32.c.o):ser_win32.c:(.text+0x150d): undefined reference to `_imp__recv@16'
/usr/bin/i686-w64-mingw32-ld: libavrdude.a(ser_win32.c.o):ser_win32.c:(.text+0x1524): undefined reference to `_imp__WSAGetLastError@0'
/usr/bin/i686-w64-mingw32-ld: libavrdude.a(ser_win32.c.o):ser_win32.c:(.text+0x1cb2): undefined reference to `_imp__select@20'
/usr/bin/i686-w64-mingw32-ld: libavrdude.a(ser_win32.c.o):ser_win32.c:(.text+0x1d24): undefined reference to `_imp__WSAGetLastError@0'
/usr/bin/i686-w64-mingw32-ld: libavrdude.a(ser_win32.c.o):ser_win32.c:(.text+0x1d32): undefined reference to `_imp__WSAGetLastError@0'
/usr/bin/i686-w64-mingw32-ld: libavrdude.a(ser_win32.c.o):ser_win32.c:(.text+0x1d8b): undefined reference to `_imp__WSAGetLastError@0'
/usr/bin/i686-w64-mingw32-ld: libavrdude.a(ser_win32.c.o):ser_win32.c:(.text+0x1e5d): undefined reference to `_imp__recv@16'
/usr/bin/i686-w64-mingw32-ld: libavrdude.a(ser_win32.c.o):ser_win32.c:(.text+0x1e74): undefined reference to `_imp__WSAGetLastError@0'
collect2: error: ld returned 1 exit status
make[2]: *** [src/CMakeFiles/avrdude.dir/build.make:152: src/avrdude] Error 1
make[2]: Leaving directory '/__w/avrdude-packing/avrdude-packing/avrdude/build'
make[1]: *** [CMakeFiles/Makefile2:98: src/CMakeFiles/avrdude.dir/all] Error 2
make[1]: Leaving directory '/__w/avrdude-packing/avrdude-packing/avrdude/build'
make: *** [Makefile:130: all] Error 2
Error: Process completed with exit code 2.

@mcuee
Copy link
Collaborator Author

mcuee commented Jan 12, 2023

#1159 (comment)

If you are targeting Windows, CMake must define WIN32. If not, there is something wrong with your cross-build setup.

I think @mariusgreuel's comment is correct. This is a not a problem of avrdude but rather the cross-compile environment from Arduino avrdude-packing project.

In this case, this PR is invalid.

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

Successfully merging this pull request may close these issues.

1 participant