2016-07-29 2 views
0

Я пытаюсь перекрестно скомпилировать крошечную программу под Linux для win32. Он использует libarchive, который доступен для mingw на моей установке fedora 23 (все установлено через dnf), но я получаю много ошибок компоновщика.mingw + libarchive: cross compiling linker error

Источник: https://github.com/panzi/save_the_zazus

Compiler выход/линкер:

[email protected] save_the_zazus [master*]$ mkdir -p package/img 
[email protected] save_the_zazus [master*]$ touch package/img/atlas0.png package/img/atlas1.png package/img/atlas2.png 
[email protected] save_the_zazus [master*]$ make TARGET=win32 setup 
mkdir -p build/win32 build/src 
[email protected] save_the_zazus [master*]$ make TARGET=win32 
i686-w64-mingw32-gcc -m32 -DLIBARCHIVE_STATIC -Wall -Werror -Wextra -std=gnu11 -Ibuild/src -O2 -c src/save_the_zazus.c -o build/win32/save_the_zazus.o 
xxd -i package/img/atlas0.png > build/src/package_img_atlas0_png.c 
i686-w64-mingw32-gcc -m32 -DLIBARCHIVE_STATIC -Wall -Werror -Wextra -std=gnu11 -Ibuild/src -O2 -c build/src/package_img_atlas0_png.c -o build/win32/package_img_atlas0_png.o 
xxd -i package/img/atlas1.png > build/src/package_img_atlas1_png.c 
i686-w64-mingw32-gcc -m32 -DLIBARCHIVE_STATIC -Wall -Werror -Wextra -std=gnu11 -Ibuild/src -O2 -c build/src/package_img_atlas1_png.c -o build/win32/package_img_atlas1_png.o 
xxd -i package/img/atlas2.png > build/src/package_img_atlas2_png.c 
i686-w64-mingw32-gcc -m32 -DLIBARCHIVE_STATIC -Wall -Werror -Wextra -std=gnu11 -Ibuild/src -O2 -c build/src/package_img_atlas2_png.c -o build/win32/package_img_atlas2_png.o 
i686-w64-mingw32-gcc -m32 -DLIBARCHIVE_STATIC -static -larchive build/win32/save_the_zazus.o build/win32/package_img_atlas0_png.o build/win32/package_img_atlas1_png.o build/win32/package_img_atlas2_png.o -o build/win32/save_the_zazus.exe 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x301): undefined reference to `archive_read_new' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x31d): undefined reference to `archive_read_support_filter_all' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x3cd): undefined reference to `archive_entry_free' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x3df): undefined reference to `archive_read_free' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x3ef): undefined reference to `archive_write_free' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x426): undefined reference to `archive_error_string' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x462): undefined reference to `archive_error_string' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x4a1): undefined reference to `archive_read_support_format_all' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x538): undefined reference to `archive_read_open_filename' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x545): undefined reference to `archive_write_new' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x557): undefined reference to `archive_write_set_format_zip' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x56b): undefined reference to `archive_write_set_options' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x581): undefined reference to `archive_error_string' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x5c9): undefined reference to `archive_write_open_filename' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x5d9): undefined reference to `archive_error_string' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x61e): undefined reference to `archive_error_string' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x67a): undefined reference to `archive_entry_new2' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x6ba): undefined reference to `archive_read_next_header2' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x6d0): undefined reference to `archive_entry_pathname' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x727): undefined reference to `archive_entry_new2' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x73d): undefined reference to `archive_entry_copy_pathname' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x74b): undefined reference to `archive_entry_perm' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x75a): undefined reference to `archive_entry_set_perm' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x762): undefined reference to `archive_entry_filetype' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x771): undefined reference to `archive_entry_set_filetype' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x77f): undefined reference to `archive_entry_mode' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x78e): undefined reference to `archive_entry_set_mode' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x7a5): undefined reference to `archive_entry_set_size' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x7b3): undefined reference to `archive_entry_uid' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x7c3): undefined reference to `archive_entry_set_uid' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x7d1): undefined reference to `archive_entry_gid' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x7e1): undefined reference to `archive_entry_set_gid' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x7ef): undefined reference to `archive_entry_mtime_nsec' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x803): undefined reference to `archive_entry_mtime' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x819): undefined reference to `archive_entry_set_mtime' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x82b): undefined reference to `archive_write_header' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x83b): undefined reference to `archive_entry_free' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x854): undefined reference to `archive_write_data' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x870): undefined reference to `archive_error_string' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x904): undefined reference to `archive_write_header' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x91a): undefined reference to `archive_entry_size' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x948): undefined reference to `archive_read_data' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x96c): undefined reference to `archive_write_data' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x988): undefined reference to `archive_error_string' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x9dd): undefined reference to `archive_write_add_filter_none' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0xa13): undefined reference to `archive_error_string' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0xa47): undefined reference to `archive_entry_free' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0xa8e): undefined reference to `archive_error_string' 
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0xad6): undefined reference to `archive_error_string' 
collect2: error: ld returned 1 exit status 
Makefile:82: recipe for target 'build/win32/save_the_zazus.exe' failed 
make: *** [build/win32/save_the_zazus.exe] Error 1 

Для этой одной программы исходного файла я просто написал простой Makefile. Файлы png не находятся в репо (пока), поэтому просто создайте для них пустые файлы, если вы попытаетесь скомпилировать. Я пробовал динамическую и статическую привязку (предпочитаю статичный, поэтому мне нужно только передать файл .exe). Для этого вывода я использовал -static -larchive, и он не жалуется на недостающие библиотеки, но я получаю все эти неопределенные ссылки.

ответ

1

Добавьте -static -larchive в конец вашей командной строки и повторите попытку. Компонент не связывает библиотеку. Я нашел, что он должен быть последним в командной строке.

+0

Именно так. Также мне пришлось добавить все зависимости libarchive. – panzi