microsoft / Chakra-Samples

Repository for Chakra JavaScript engine related samples.
MIT License
216 stars 84 forks source link

Canno't compile 'Hello World' example on MacOS #33

Closed ThomasCrevoisier closed 8 years ago

ThomasCrevoisier commented 8 years ago

Hello,

I followed the instructions to compile ChakraCore on my Mac running ./build.sh --static --icu=/usr/local/opt/icu4c/include --test-build -j=2 --debug

I created the folder CrossPlatform inside ChakraCore repo and added sample.cpp and Makefile.

Then I built it running make BUILD_TYPE=Debug PLATFORM=darwin and here are the errors I get :

Undefined symbols for architecture x86_64:
  "icu_57::Normalizer2::getNFCInstance(UErrorCode&)", referenced from:
      PlatformAgnostic::UnicodeText::TranslateToICUNormalizer(PlatformAgnostic::UnicodeText::NormalizationForm) in libChakra.Jsrt.a(UnicodeText.ICU.cpp.o)
  "icu_57::Normalizer2::getNFDInstance(UErrorCode&)", referenced from:
      PlatformAgnostic::UnicodeText::TranslateToICUNormalizer(PlatformAgnostic::UnicodeText::NormalizationForm) in libChakra.Jsrt.a(UnicodeText.ICU.cpp.o)
  "icu_57::Normalizer2::getNFKCInstance(UErrorCode&)", referenced from:
      PlatformAgnostic::UnicodeText::TranslateToICUNormalizer(PlatformAgnostic::UnicodeText::NormalizationForm) in libChakra.Jsrt.a(UnicodeText.ICU.cpp.o)
  "icu_57::Normalizer2::getNFKDInstance(UErrorCode&)", referenced from:
      PlatformAgnostic::UnicodeText::TranslateToICUNormalizer(PlatformAgnostic::UnicodeText::NormalizationForm) in libChakra.Jsrt.a(UnicodeText.ICU.cpp.o)
  "icu_57::UnicodeString::UnicodeString(unsigned short const*, int)", referenced from:
      PlatformAgnostic::UnicodeText::NormalizeString(PlatformAgnostic::UnicodeText::NormalizationForm, char16_t const*, unsigned int, char16_t*, int, PlatformAgnostic::UnicodeText::ApiError*) in libChakra.Jsrt.a(UnicodeText.ICU.cpp.o)
      PlatformAgnostic::UnicodeText::IsNormalizedString(PlatformAgnostic::UnicodeText::NormalizationForm, char16_t const*, int) in libChakra.Jsrt.a(UnicodeText.ICU.cpp.o)
  "icu_57::UnicodeString::~UnicodeString()", referenced from:
      PlatformAgnostic::UnicodeText::NormalizeString(PlatformAgnostic::UnicodeText::NormalizationForm, char16_t const*, unsigned int, char16_t*, int, PlatformAgnostic::UnicodeText::ApiError*) in libChakra.Jsrt.a(UnicodeText.ICU.cpp.o)
      PlatformAgnostic::UnicodeText::IsNormalizedString(PlatformAgnostic::UnicodeText::NormalizationForm, char16_t const*, int) in libChakra.Jsrt.a(UnicodeText.ICU.cpp.o)
      icu_57::Normalizer2::normalize(icu_57::UnicodeString const&, UErrorCode&) const in libChakra.Jsrt.a(UnicodeText.ICU.cpp.o)
  "icu_57::UnicodeString::extract(unsigned short*, int, UErrorCode&) const", referenced from:
      PlatformAgnostic::UnicodeText::NormalizeString(PlatformAgnostic::UnicodeText::NormalizationForm, char16_t const*, unsigned int, char16_t*, int, PlatformAgnostic::UnicodeText::ApiError*) in libChakra.Jsrt.a(UnicodeText.ICU.cpp.o)
  "vtable for icu_57::Replaceable", referenced from:
      icu_57::Replaceable::Replaceable() in libChakra.Jsrt.a(UnicodeText.ICU.cpp.o)
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
  "vtable for icu_57::UnicodeString", referenced from:
      icu_57::UnicodeString::UnicodeString() in libChakra.Jsrt.a(UnicodeText.ICU.cpp.o)
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
  "vtable for icu_57::UObject", referenced from:
      icu_57::UObject::UObject() in libChakra.Jsrt.a(UnicodeText.ICU.cpp.o)
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
  "_u_charType_57", referenced from:
      PlatformAgnostic::UnicodeText::GetGeneralCategoryClass(unsigned int) in libChakra.Jsrt.a(UnicodeText.ICU.cpp.o)
      PlatformAgnostic::UnicodeText::GetLegacyCharacterClassificationType(char16_t) in libChakra.Jsrt.a(UnicodeText.ICU.cpp.o)
  "_u_errorName_57", referenced from:
      PlatformAgnostic::UnicodeText::TranslateToICUNormalizer(PlatformAgnostic::UnicodeText::NormalizationForm) in libChakra.Jsrt.a(UnicodeText.ICU.cpp.o)
  "_u_hasBinaryProperty_57", referenced from:
      PlatformAgnostic::UnicodeText::IsIdContinue(unsigned int) in libChakra.Jsrt.a(UnicodeText.ICU.cpp.o)
  "_u_isIDStart_57", referenced from:
      PlatformAgnostic::UnicodeText::IsIdStart(unsigned int) in libChakra.Jsrt.a(UnicodeText.ICU.cpp.o)
  "_u_isUWhiteSpace_57", referenced from:
      PlatformAgnostic::UnicodeText::IsWhitespace(unsigned int) in libChakra.Jsrt.a(UnicodeText.ICU.cpp.o)
  "_u_strToLower_57", referenced from:
      PlatformAgnostic::UnicodeText::ChangeStringLinguisticCase(PlatformAgnostic::UnicodeText::CaseFlags, char16_t const*, unsigned int, char16_t*, unsigned int, PlatformAgnostic::UnicodeText::ApiError*) in libChakra.Jsrt.a(UnicodeText.ICU.cpp.o)
  "_u_strToUpper_57", referenced from:
      PlatformAgnostic::UnicodeText::ChangeStringLinguisticCase(PlatformAgnostic::UnicodeText::CaseFlags, char16_t const*, unsigned int, char16_t*, unsigned int, PlatformAgnostic::UnicodeText::ApiError*) in libChakra.Jsrt.a(UnicodeText.ICU.cpp.o)
  "_u_strlen_57", referenced from:
      PlatformAgnostic::UnicodeText::IsNormalizedString(PlatformAgnostic::UnicodeText::NormalizationForm, char16_t const*, int) in libChakra.Jsrt.a(UnicodeText.ICU.cpp.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [testmake] Error 1

Any clue on what I missed ?

obastemur commented 8 years ago

@ThomasCrvsr on the sample Makefile we have icucore .

However, your command line with the latest ChakraCore uses the libs from the --icu=/usr/local/opt/icu4c/ location. So, under the makefile, we should set those instead of icucore too.

See https://github.com/Microsoft/ChakraCore/blob/linux/CMakeLists.txt#L15-L17

those 2 lib files under the /usr/local/opt/icu4c/lib instead of icucore

I will try to send an addition to sample explaining this detail.

ThomasCrevoisier commented 8 years ago

@obastemur Got it, thanks !

I came mostly from a JS background, so I'm not really used to this ecosystem. How can I specify a custom location for those 2 files in the Makefile of the example ?

juliusl commented 8 years ago

See https://github.com/Microsoft/ChakraCore/blob/linux/CMakeLists.txt#L15-L17

those 2 lib files under the /usr/local/opt/icu4c/lib instead of icucore

Just to clarify.. Lines 15-17 highlight 3 libraries, do you mean to include all 3?

juliusl commented 8 years ago

Scratch that. Got it to work and put up PR #35.

obastemur commented 8 years ago

Thanks to @juliusl this is now fixed on master.