Clang link转义$表示弱符号



我正在使用Theos进行调整,但我在Makefiles和链接器标志方面遇到了麻烦。

链接器正在抱怨一个未定义的符号,所以我试图将-Wl,-U, _OBJC_CLASS_$_Hook_HTTestClass传递给像这样的弱链接符号,

ARCHS = arm64
TARGET := iphone:clang:latest:7.0
INSTALL_TARGET_PROCESSES = HookTest
include $(THEOS)/makefiles/common.mk
TWEAK_NAME = HookTestTweak
HookTestTweak_FILES = Tweak.m
HookTestTweak_CFLAGS = -fobjc-arc
HookTestTweak_LDFLAGS += -v -Wl,-U,_OBJC_CLASS_$_Hook_HTTestClass
include $(THEOS_MAKE_PATH)/tweak.mk

一开始,我以为是$,所以我试着转义它。

HookTestTweak_LDFLAGS += -v -Wl,-U,_OBJC_CLASS_$$_Hook_HTTestClass

但是链接器的结果是(注意它是怎么写-U _OBJC_CLASS_的)

"/home/haow6/.theos/toolchain/linux/iphone/bin/ld" -dynamic -dylib -arch arm64 -dylib_install_name /Library/MobileSubstrate/DynamicLibraries/HookTestTweak.dylib -platform_version ios 7.0.0 14.4 -multiply_defined suppress -syslibroot /home/haow6/.theos/sdks/iPhoneOS14.4.sdk -o /home/haow6/source/HookTest/HookTestTweak/.theos/obj/debug/arm64/HookTestTweak.dylib -L/home/haow6/.theos/lib -L/home/haow6/.theos/vendor/lib -lobjc -framework Foundation -framework CoreFoundation -framework CydiaSubstrate -lc++ -U _OBJC_CLASS_ /home/haow6/source/HookTest/HookTestTweak/.theos/obj/debug/arm64/Tweak.m.bd8afb95.o -lc++ -lSystem -F/home/haow6/.theos/vendor/lib
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_HTTestClass", referenced from:
_OBJC_CLASS_$_Hook_HTTestClass in Tweak.m.bd8afb95.o
"_OBJC_METACLASS_$_HTTestClass", referenced from:
_OBJC_METACLASS_$_Hook_HTTestClass in Tweak.m.bd8afb95.o
ld: symbol(s) not found for architecture arm64

接下来,我试图将符号名称用引号括起来,它更接近-U "_OBJC_CLASS_$_Hook_HTTestClass",但它仍然不起作用,

"/home/haow6/.theos/toolchain/linux/iphone/bin/ld" -dynamic -dylib -arch arm64 -dylib_install_name /Library/MobileSubstrate/DynamicLibraries/HookTestTweak.dylib -platform_version ios 7.0.0 14.4 -multiply_defined suppress -syslibroot /home/haow6/.theos/sdks/iPhoneOS14.4.sdk -o /home/haow6/source/HookTest/HookTestTweak/.theos/obj/debug/arm64/HookTestTweak.dylib -L/home/haow6/.theos/lib -L/home/haow6/.theos/vendor/lib -lobjc -framework Foundation -framework CoreFoundation -framework CydiaSubstrate -lc++ -U "_OBJC_CLASS_$_Hook_HTTestClass" /home/haow6/source/HookTest/HookTestTweak/.theos/obj/debug/arm64/Tweak.m.bd8afb95.o -lc++ -lSystem -F/home/haow6/.theos/vendor/lib
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_HTTestClass", referenced from:
_OBJC_CLASS_$_Hook_HTTestClass in Tweak.m.bd8afb95.o
"_OBJC_METACLASS_$_HTTestClass", referenced from:
_OBJC_METACLASS_$_Hook_HTTestClass in Tweak.m.bd8afb95.o
ld: symbol(s) not found for architecture arm64

我可以使用-Wl,-undefined,dynamic_lookup,但它抱怨它已被弃用。

我希望我在正确的轨道上,但任何帮助将非常感激!

$字符对于来说是特殊的使成为shell,所以必须转义两次,每次转义一次。

对于make,您通过$$将其翻倍以转义它。对于shell,将其包含在单引号中。所以尝试:

HookTestTweak_LDFLAGS += -v '-Wl,-U,_OBJC_CLASS_$$_Hook_HTTestClass' 

相关内容

  • 没有找到相关文章

最新更新