我正在玩j2objc,看看我是否可以在我的項目中使用番石榴。j2objc錯誤添加番石榴(When.o is missing)
我的項目是很簡單:配置用於j2obcj(https://github.com/google/j2objc/wiki/Xcode-Build-Rules)與自定義線的單一視圖的應用程序添加到appDelegete.m
#include "java/util/ArrayList.h"
#include "com/google/common/collect/Lists.h"
[...]
[ComGoogleCommonCollectLists newArrayList];
試圖編譯它生成錯誤:
Undefined symbols for architecture x86_64:
"_JavaxAnnotationMetaWhenEnum_initialized", referenced from:
+[ComGoogleCommonBaseCharMatcher __annotations_removeFromWithJavaLangCharSequence_] in libguava.a(CharMatcher.o)
+[ComGoogleCommonBaseCharMatcher __annotations_retainFromWithJavaLangCharSequence_] in libguava.a(CharMatcher.o)
+[ComGoogleCommonBaseCharMatcher __annotations_replaceFromWithJavaLangCharSequence_withChar_] in libguava.a(CharMatcher.o)
+[ComGoogleCommonBaseCharMatcher __annotations_replaceFromWithJavaLangCharSequence_withJavaLangCharSequence_] in libguava.a(CharMatcher.o)
+[ComGoogleCommonBaseCharMatcher __annotations_trimFromWithJavaLangCharSequence_] in libguava.a(CharMatcher.o)
+[ComGoogleCommonBaseCharMatcher __annotations_trimLeadingFromWithJavaLangCharSequence_] in libguava.a(CharMatcher.o)
+[ComGoogleCommonBaseCharMatcher __annotations_trimTrailingFromWithJavaLangCharSequence_] in libguava.a(CharMatcher.o)
...
"_JavaxAnnotationMetaWhenEnum_values_", referenced from:
+[ComGoogleCommonBaseCharMatcher __annotations_removeFromWithJavaLangCharSequence_] in libguava.a(CharMatcher.o)
+[ComGoogleCommonBaseCharMatcher __annotations_retainFromWithJavaLangCharSequence_] in libguava.a(CharMatcher.o)
+[ComGoogleCommonBaseCharMatcher __annotations_replaceFromWithJavaLangCharSequence_withChar_] in libguava.a(CharMatcher.o)
+[ComGoogleCommonBaseCharMatcher __annotations_replaceFromWithJavaLangCharSequence_withJavaLangCharSequence_] in libguava.a(CharMatcher.o)
+[ComGoogleCommonBaseCharMatcher __annotations_trimFromWithJavaLangCharSequence_] in libguava.a(CharMatcher.o)
+[ComGoogleCommonBaseCharMatcher __annotations_trimLeadingFromWithJavaLangCharSequence_] in libguava.a(CharMatcher.o)
+[ComGoogleCommonBaseCharMatcher __annotations_trimTrailingFromWithJavaLangCharSequence_] in libguava.a(CharMatcher.o)
...
"_OBJC_CLASS_$_JavaxAnnotationCheckForNull", referenced from:
objc-class-ref in libguava.a(Ints.o)
objc-class-ref in libguava.a(AndroidInteger.o)
"_OBJC_CLASS_$_JavaxAnnotationCheckReturnValue", referenced from:
objc-class-ref in libguava.a(CharMatcher.o)
objc-class-ref in libguava.a(Joiner.o)
objc-class-ref in libguava.a(Splitter.o)
objc-class-ref in libguava.a(CacheBuilder.o)
objc-class-ref in libguava.a(BaseEncoding.o)
objc-class-ref in libguava.a(UnsignedLong.o)
objc-class-ref in libguava.a(UnsignedInteger.o)
...
"_OBJC_CLASS_$_JavaxAnnotationMetaWhenEnum", referenced from:
objc-class-ref in libguava.a(CharMatcher.o)
objc-class-ref in libguava.a(Joiner.o)
objc-class-ref in libguava.a(Splitter.o)
objc-class-ref in libguava.a(CacheBuilder.o)
objc-class-ref in libguava.a(BaseEncoding.o)
objc-class-ref in libguava.a(UnsignedLong.o)
objc-class-ref in libguava.a(UnsignedInteger.o)
...
"_OBJC_CLASS_$_JavaxAnnotationNullable", referenced from:
objc-class-ref in libguava.a(Equivalence.o)
objc-class-ref in libguava.a(FunctionalEquivalence.o)
objc-class-ref in libguava.a(Functions.o)
objc-class-ref in libguava.a(Joiner.o)
objc-class-ref in libguava.a(Objects.o)
objc-class-ref in libguava.a(Optional.o)
objc-class-ref in libguava.a(PairwiseEquivalence.o)
...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
看起來連接時有問題,中沒有When.o
。
我試圖運行沒有任何問題以下行,只是爲了檢查javax
包在那裏
#include "javax/xml/parsers/SAXParser.h"
[...]
[[JavaxXmlParsersSAXParser alloc] init];
還檢查了SAXParser.i
是libjre_emul
$ otool -o lib/libjre_emul.a | grep .o\): | grep SAXParser
lib/libjre_emul.a(SAXParser.o):
lib/libjre_emul.a(SAXParserFactory.o):
lib/libjre_emul.a(SAXParserFactoryImpl.o):
lib/libjre_emul.a(SAXParserImpl.o):
但在情況的嘗試When
#include "javax/annotation/meta/When.h"
[...]
[JavaxAnnotationMetaWhenEnum values];
我有一個類似與番石榴
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_JavaxAnnotationMetaWhenEnum", referenced from:
objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
錯誤校驗libjre_emul
後沒有When.o
otool -o lib/libjre_emul.a | grep .o\): | grep When
我的設置是:
J2OBJC_HOME = ./bin/j2objc-0.9.5;
HEADER_SEARCH_PATHS = $(inherited) "${J2OBJC_HOME}/include";
LIBRARY_SEARCH_PATHS = $(inherited) "${J2OBJC_HOME}/lib";
OTHER_LDFLAGS = $(inherited) -l"z" -l"jre_emul" -l"guava" -l"icucore" -framework "Security" -ObjC;
我已經嘗試了不同的版本(0.9.5,0.9.4,0.9.3,0.9),但錯誤依然存在。
總之,據我所知,沒有辦法與j2objc一起使用番石榴,因爲它取決於缺少的符號。
任何人都可以證明我錯了,希望?我真的想開始在一個真正的項目中使用j2objc!
提前致謝!聖誕節快樂!
最後它的作品!非常感謝! :) – 7ynk3r
是否有與所有'OTHER_LDFLAGS'可能值的參考? – 7ynk3r
所有使用j2objc發佈的庫都位於dist/lib中。本地庫的命名模式爲lib.a,所以有一個libjsr305.a,libguava.a,libjunit.a等,對應於jsr305.jar,guava-jdk5.jar,junit.jar文件/ lib目錄下。 –
tball