#linker #mingw #mupdf #jbig2
Вопрос:
Я попытался создать библиотеки mupdf с помощью MinGW-w64. Операции компиляции и ar были завершены, но при связывании файла exec он сообщал о подобных ошибках
build/mingw64-cross/release/libmupdf-third.a(jbig2_symbol_dict.o):jbig2_symbol_dict.c:(.text$_Exit 0x0): multiple definition of `_Exit'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$_Exit 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_symbol_dict.o):jbig2_symbol_dict.c:(.text$llabs 0x0): multiple definition of `llabs'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$llabs 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_symbol_dict.o):jbig2_symbol_dict.c:(.text$atoll 0x0): multiple definition of `atoll'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$atoll 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_symbol_dict.o):jbig2_symbol_dict.c:(.text$lltoa 0x0): multiple definition of `lltoa'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$lltoa 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_symbol_dict.o):jbig2_symbol_dict.c:(.text$ulltoa 0x0): multiple definition of `ulltoa'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$ulltoa 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_symbol_dict.o):jbig2_symbol_dict.c:(.text$wtoll 0x0): multiple definition of `wtoll'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$wtoll 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_symbol_dict.o):jbig2_symbol_dict.c:(.text$lltow 0x0): multiple definition of `lltow'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$lltow 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_symbol_dict.o):jbig2_symbol_dict.c:(.text$ulltow 0x0): multiple definition of `ulltow'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$ulltow 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_text.o):jbig2_text.c:(.text$_Exit 0x0): multiple definition of `_Exit'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$_Exit 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_text.o):jbig2_text.c:(.text$llabs 0x0): multiple definition of `llabs'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$llabs 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_text.o):jbig2_text.c:(.text$atoll 0x0): multiple definition of `atoll'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$atoll 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_text.o):jbig2_text.c:(.text$lltoa 0x0): multiple definition of `lltoa'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$lltoa 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_text.o):jbig2_text.c:(.text$ulltoa 0x0): multiple definition of `ulltoa'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$ulltoa 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_text.o):jbig2_text.c:(.text$wtoll 0x0): multiple definition of `wtoll'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$wtoll 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_text.o):jbig2_text.c:(.text$lltow 0x0): multiple definition of `lltow'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$lltow 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_text.o):jbig2_text.c:(.text$ulltow 0x0): multiple definition of `ulltow'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$ulltow 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_arith_iaid.o):jbig2_arith_iaid.c:(.text$_Exit 0x0): multiple definition of `_Exit'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$_Exit 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_arith_iaid.o):jbig2_arith_iaid.c:(.text$llabs 0x0): multiple definition of `llabs'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$llabs 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_arith_iaid.o):jbig2_arith_iaid.c:(.text$atoll 0x0): multiple definition of `atoll'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$atoll 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_arith_iaid.o):jbig2_arith_iaid.c:(.text$lltoa 0x0): multiple definition of `lltoa'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$lltoa 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_arith_iaid.o):jbig2_arith_iaid.c:(.text$ulltoa 0x0): multiple definition of `ulltoa'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$ulltoa 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_arith_iaid.o):jbig2_arith_iaid.c:(.text$wtoll 0x0): multiple definition of `wtoll'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$wtoll 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_arith_iaid.o):jbig2_arith_iaid.c:(.text$lltow 0x0): multiple definition of `lltow'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$lltow 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_arith_iaid.o):jbig2_arith_iaid.c:(.text$ulltow 0x0): multiple definition of `ulltow'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$ulltow 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_arith_int.o):jbig2_arith_int.c:(.text$_Exit 0x0): multiple definition of `_Exit'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$_Exit 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_arith_int.o):jbig2_arith_int.c:(.text$llabs 0x0): multiple definition of `llabs'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$llabs 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_arith_int.o):jbig2_arith_int.c:(.text$atoll 0x0): multiple definition of `atoll'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$atoll 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_arith_int.o):jbig2_arith_int.c:(.text$lltoa 0x0): multiple definition of `lltoa'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$lltoa 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_arith_int.o):jbig2_arith_int.c:(.text$ulltoa 0x0): multiple definition of `ulltoa'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$ulltoa 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_arith_int.o):jbig2_arith_int.c:(.text$wtoll 0x0): multiple definition of `wtoll'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$wtoll 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_arith_int.o):jbig2_arith_int.c:(.text$lltow 0x0): multiple definition of `lltow'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$lltow 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_arith_int.o):jbig2_arith_int.c:(.text$ulltow 0x0): multiple definition of `ulltow'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$ulltow 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_generic.o):jbig2_generic.c:(.text$_Exit 0x0): multiple definition of `_Exit'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$_Exit 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_generic.o):jbig2_generic.c:(.text$llabs 0x0): multiple definition of `llabs'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$llabs 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_generic.o):jbig2_generic.c:(.text$atoll 0x0): multiple definition of `atoll'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$atoll 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_generic.o):jbig2_generic.c:(.text$lltoa 0x0): multiple definition of `lltoa'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$lltoa 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_generic.o):jbig2_generic.c:(.text$ulltoa 0x0): multiple definition of `ulltoa'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$ulltoa 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_generic.o):jbig2_generic.c:(.text$wtoll 0x0): multiple definition of `wtoll'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$wtoll 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_generic.o):jbig2_generic.c:(.text$lltow 0x0): multiple definition of `lltow'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$lltow 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_generic.o):jbig2_generic.c:(.text$ulltow 0x0): multiple definition of `ulltow'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$ulltow 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_halftone.o):jbig2_halftone.c:(.text$_Exit 0x0): multiple definition of `_Exit'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$_Exit 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_halftone.o):jbig2_halftone.c:(.text$llabs 0x0): multiple definition of `llabs'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$llabs 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_halftone.o):jbig2_halftone.c:(.text$atoll 0x0): multiple definition of `atoll'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$atoll 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_halftone.o):jbig2_halftone.c:(.text$lltoa 0x0): multiple definition of `lltoa'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$lltoa 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_halftone.o):jbig2_halftone.c:(.text$ulltoa 0x0): multiple definition of `ulltoa'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$ulltoa 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_halftone.o):jbig2_halftone.c:(.text$wtoll 0x0): multiple definition of `wtoll'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$wtoll 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_halftone.o):jbig2_halftone.c:(.text$lltow 0x0): multiple definition of `lltow'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$lltow 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_halftone.o):jbig2_halftone.c:(.text$ulltow 0x0): multiple definition of `ulltow'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$ulltow 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_mmr.o):jbig2_mmr.c:(.text$llabs 0x0): multiple definition of `llabs'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$llabs 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_mmr.o):jbig2_mmr.c:(.text$atoll 0x0): multiple definition of `atoll'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$atoll 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_mmr.o):jbig2_mmr.c:(.text$lltoa 0x0): multiple definition of `lltoa'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$lltoa 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_mmr.o):jbig2_mmr.c:(.text$ulltoa 0x0): multiple definition of `ulltoa'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$ulltoa 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_mmr.o):jbig2_mmr.c:(.text$wtoll 0x0): multiple definition of `wtoll'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$wtoll 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_mmr.o):jbig2_mmr.c:(.text$lltow 0x0): multiple definition of `lltow'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$lltow 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_mmr.o):jbig2_mmr.c:(.text$ulltow 0x0): multiple definition of `ulltow'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$ulltow 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_refinement.o):jbig2_refinement.c:(.text$_Exit 0x0): multiple definition of `_Exit'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$_Exit 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_refinement.o):jbig2_refinement.c:(.text$llabs 0x0): multiple definition of `llabs'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$llabs 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_refinement.o):jbig2_refinement.c:(.text$atoll 0x0): multiple definition of `atoll'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$atoll 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_refinement.o):jbig2_refinement.c:(.text$lltoa 0x0): multiple definition of `lltoa'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$lltoa 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_refinement.o):jbig2_refinement.c:(.text$ulltoa 0x0): multiple definition of `ulltoa'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$ulltoa 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_refinement.o):jbig2_refinement.c:(.text$wtoll 0x0): multiple definition of `wtoll'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$wtoll 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_refinement.o):jbig2_refinement.c:(.text$lltow 0x0): multiple definition of `lltow'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$lltow 0x0): first defined here
build/mingw64-cross/release/libmupdf-third.a(jbig2_refinement.o):jbig2_refinement.c:(.text$ulltow 0x0): multiple definition of `ulltow'
build/mingw64-cross/release/libmupdf-third.a(jbig2_segment.o):jbig2_segment.c:(.text$ulltow 0x0): first defined here
collect2.exe: error: ld returned 1 exit status
mingw32-make: *** [Makefile:247: build/mingw64-cross/release/mutool] Error 1
Все эти ошибки были связаны с библиотекой jbig2dec. Похоже, что эти программы несколько раз определяли такие символы, как _Exit, но в исходных файлах я не использовал такие символы. Я использовал nm
команду для анализа файла jbig2_segment.o, а затем обнаружил, что
...
0000000000000000 t .text
0000000000000000 t .text$_Exit
0000000000000000 t .text$atoll
0000000000000000 t .text$jbig2_find_segment
0000000000000000 t .text$jbig2_free_segment
0000000000000000 t .text$jbig2_get_region_segment_info
0000000000000000 t .text$jbig2_parse_segment
0000000000000000 t .text$jbig2_parse_segment_header
0000000000000000 t .text$llabs
0000000000000000 t .text$lltoa
0000000000000000 t .text$lltow
0000000000000000 t .text$ulltoa
0000000000000000 t .text$ulltow
0000000000000000 t .text$wtoll
...
Это показывает, что такие символы, как _Exit и atoll, действительно были определены, но в исходном файле программы таких символов не было. За исключением jbig2_xxx.o, в других файлах .o таких символов не было.
Затем я использовал linux для создания того же проекта, и он прошел. Так в чем же причина этой проблемы? как я мог это исправить?
Комментарии:
1. Вы пробовали создавать jbig2dec автономно из исходного кода вместо поставляемой третьей стороны? Когда я строю github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/… с MinGW-w64 он работает нормально. Чтобы создать mupdf против него, мне пришлось добавить
LDFLAGS="-Wl,--as-needed -ljbig2dec"
его в команду make. Обратите внимание, что я построил все зависимости отдельно, поэтому ни одна из них не используется из сторонних источников, предоставленных mupdf.2. @BrechtSanders Вы смогли создать jbig2dec-0.19 из исходного кода [ArtifexSoftware]? Это интересно, учитывая, что MSYS2 пришлось исправлять
os_types.h
, чтобы построить их.3. @TamirEvan Я создаю jbig2dec-0.19 из источника по адресу: github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/… без каких-либо изменений с помощью
./configure LDFLAGS="-Wl,--allow-multiple-definition" amp;amp; make
Ответ №1:
Обходным путем может быть использование флага компоновщика -Wl,--allow-multiple-definition
, например, с make LDFLAGS="-Wl,--allow-multiple-definition"
помощью .
Лично я создаю MuPDF с помощью MinGW-w64 без какого-либо дополнительного стороннего кода. Вместо этого у меня есть все библиотеки зависимостей, уже скомпилированные в моей системе, и сборка MuPDF с:
make NOX11=yes CC=gcc USE_SYSTEM_LIBS=yes SYS_FREETYPE_LIBS=-lfreetype CFLAGS="$(pkg-config --cflags libopenjp2) -I$(pwd)/include -I$(pwd)/fitz -I$(pwd)/pdf" SYS_GUMBO_LIBS="-lgumbo" LDFLAGS="-Wl,--as-needed -lfreetype -ljbig2dec -ljpeg -lopenjp2 -lz"
Комментарии:
1. (1)
NOX11=yes
??? Когда вы в последний раз создавали MuPDF? Тестирование дляNOX11
было заменено более 7 лет назад в разделе «Добавление подмодуля, реализация и сборка MuJS» ( фиксация db63530 ). (2) Поскольку OP, похоже, на самом деле пытается скомпилировать MuPDF в Mingw-w64, вторая часть вашего ответа, вероятно, не сильно поможет ему. Кроме того, если бы он не использовал что-то вроде MSYS2, ему бы тоже пришлось упаковать эти сторонние библиотеки вместе с приложениями.2. @TamirEvan (1) Возможно, NOX11=да все еще был там после создания более старых версий, и я упустил тот факт, что он больше не нужен. (2) Я строю из оболочки MSYS2, но не использую ни один из их готовых пакетов, вместо этого я сам создал все сторонние пакеты из исходного кода. На самом деле, я работаю над системой упаковки самостоятельно, чтобы использовать winlibs.com
3. Извините за опоздание. -Wl,—работает флаг с несколькими определениями. Спасибо!