Есть ли флаг gcc, чтобы пропускать разрешение символов компоновщиком времени компоновки при создании общей библиотеки (которая зависит от других разделяемых библиотек)? По какой-то причине моя toolchain дает undefined reference
ошибки, когда я пытаюсь создать общую библиотеку C, которая зависит от B.so и A.so, хотя зависимости заданы и существуют. Я слышал, что существует флаг gcc, чтобы отложить разрешение зависимостей во время выполнения.Пропустить разрешение символа компиляции при создании общих библиотек Linux с зависимостями
3
A
ответ
2
Я думаю, что вы ищете --allow-shlib-undefined
. Из ld
man page:
--allow-shlib-undefined
--no-allow-shlib-undefined
Allows (the default) or disallows undefined symbols in shared libraries.
This switch is similar to --no-undefined except that it determines the
behaviour when the undefined symbols are in a shared library rather than
a regular object file. It does not affect how undefined symbols in regular
object files are handled.
The reason that --allow-shlib-undefined is the default is that the shared
library being specified at link time may not be the same as the one that
is available at load time, so the symbols might actually be resolvable at
load time. Plus there are some systems, (eg BeOS) where undefined symbols
in shared libraries is normal. (The kernel patches them at load time to
select which function is most appropriate for the current architecture.
This is used for example to dynamically select an appropriate memset
function). Apparently it is also normal for HPPA shared libraries to have
undefined symbols.
Позволяющ неопределенных символов по умолчанию, хотя, так что я предполагаю, что ваши проблемы на самом деле что-то другое.