2016-07-29 2 views
0

리눅스에서 win32 용으로 작은 프로그램을 컴파일하려고합니다. libarchive는 fedora 23 설치시 mingw에서 사용할 수 있지만 (모두 dnf를 통해 설치됨) 많은 링커 오류가 발생합니다.mingw + libarchive : 링커 오류 교차 컴파일

출처 : https://github.com/panzi/save_the_zazus

컴파일러/링커 출력 :

[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 파일은 repo (아직)에 없으므로 컴파일하려고하면 빈 파일을 만듭니다. 나는 동적이고 정적 인 연결을 시도했다. (정적 인 것을 선호하므로 .exe 파일을 전달하는 것이 전부다.) 이 출력을 위해 -static -larchive을 사용했는데 누락 된 라이브러리에 대해서는 불평하지 않지만 정의되지 않은 참조는 모두 얻습니다.

답변

1

명령 줄 끝에 -static -larchive을 추가하고 다시 시도하십시오. 링커가 링크 할 라이브러리를 가져 오지 않습니다. 커맨드 라인에서 마지막 일 필요가 있다는 것을 알았습니다.

+0

그게 전부입니다. 또한 libarchive의 모든 종속성을 추가해야했습니다. – panzi