Hi, I dowloaded Kotlin/Native to my computer using...
# kotlin-native
l
Hi, I dowloaded Kotlin/Native to my computer using GitHub Desktop, and I'm trying to open the samples directory in CLion EAP (which has the Kotlin/Native plugin), but when I press "open" and select the "samples" directory, nothing happens. When I try "import from sources", it asks me to select files for a CMake project, and I don't know what to do since the samples seem to be built by gradle, and I don't know anything in CMake (I'm a true beginner in the native ecosystem). Could anyone help me in getting the samples open properly in CLion please?
s
AFAIK, you cannot open samples from this repo in CLion. CLion supports only CMake projects and this examples are in gradle. But CLion Kotlin plugin has some builtin examples: File -> New project… -> Kotlin/Native Application -> Select example from listbox
l
That's sad. I'd like to explore Kotlin/Native with the IDE to see what I can do rapidly
s
You can do it with Kotlin/Native examples built in CLion
l
Yep, I already did, but wanted to take a look at the tensorflow sample
s
@louiscad I’m ported this sample to CMake: https://github.com/snrostov/konan_cmake_HelloTensorflow
👍🏽 1
You need to run downloadTensorflow.sh first
l
Thank you for this! BTW, you made a typo in the GitHub subtitle where you typed "proted" instead of "typed"
s
Oops. Fixed
l
meant "ported", not "typed" concurrency bug while thinking 😂
The project (just like the sample gradle project) doesn't build. I guess the cause is what's "explained" in the README: You may need to specify
LD_LIBRARY_PATH
or
DYLD_LIBRARY_PATH
to
$HOME/.konan/third-party/tensorflow/lib
if the TensorFlow dynamic library cannot be found.
The only issue, is that the explanation is not explicit enough for native beginners like me: Where do I specify this? It'd be nice if anyone can tell me
s
You should do it in run configration
👍🏽 1
In the Environment variables field
l
And how am I supposed to do it in the gradle config if I want to build all the samples?
s
You just need to set the same env var before running target kexe
l
Also, there are 4 configurations (you have them too, right?), which one am I supposed to pick?
s
HelloTensorflow.kexe
l
For gradle, I need to add them in one of the properties file?
s
No, just build it using gradle and then run in terminal:
Copy code
export DYLD_LIBRARY_PATH=~/.konan/third-party/tensorflow/lib
./build/bin/HelloTensorflow.kexe
l
BTW, I have unresolved references for all tensorflow related symbols. Do you have them resolved in CLion?
s
What the name of unresolved symbold?
try to check it using
nm -g ~/.konan/third-party/tensorflow/lib/libtensorflow.so | grep $SYMBOLD_NAME
l
the whole tensorflow package and it's contents, starting from the import
Will post a screenshot back in the channel
It's in #kotlin-native (

https://kotlinlang.slack.com/files/U3ZLHBTLG/F87KWV094/screen_shot_2017-11-28_at_23.01.34.png

)
message has been deleted
s
There are 2 unrelated problems here: 1) unresolved references in editor. looks like closing it and opening again should help 2) linker cannot find symbol in tensorflow.so for second one try to run this:
nm -g ~/.konan/third-party/tensorflow/lib/libtensorflow.so | grep TF_GraphImportGraphDefOptions
is there
TF_GraphImportGraphDefOptionsRemapControlDependency
in output?
l
There's no output at all
s
then just comment out
Copy code
extern void TF_GraphImportGraphDefOptionsRemapControlDependency(
    TF_ImportGraphDefOptions* opts, const char* src_name, TF_Operation* dst);
in ~/.konan/third-party/tensorflow/include/tensorflow/c/c_api.h
l
Why would it not be correct?
s
Looks like bug in tensorflow build
this symbol is declared in header and not provided in so
l
Still doesn't build
s
Try run -> clean first
l
Copy code
KtFile: HelloTensorflow.kt
ld: warning: could not create compact unwind for _ffi_call_unix64: does not use RBP or RSP based frame
Undefined symbols for architecture x86_64:
  "_TF_GraphImportGraphDefOptionsRemapControlDependency", referenced from:
      _tensorflow_kniBridge96 in combined6191069496991552343.o
ld: symbol(s) not found for architecture x86_64
error: linker invocation reported errors
make[3]: *** [CMakeFiles/HelloTensorflow_TEMP.kexe] Error 1
make[2]: *** [CMakeFiles/HelloTensorflow.compile.dir/all] Error 2
make[1]: *** [CMakeFiles/HelloTensorflow.kexe.dir/rule] Error 2
make: *** [HelloTensorflow.kexe] Error 2
You were right about closing and reopening the IDE for unresolved references. Weird… Is this a known bug?
s
I don’t know
For the second: did you try build with clean first after changing header? Does it helps?
l
Just came back to the IDE after hitting clean (was instant) and pressing run button again to build the project, and the references are unresolved again
It's still building at the moment
It finished, but with a non 0 exit code, not sure how to interpret that
Copy code
GitHub/konan_cmake_HelloTensorflow/cmake-build-debug/HelloTensorflow.kexe
dyld: Library not loaded: bazel-out/local-opt/bin/tensorflow/libtensorflow.so
  Referenced from: /Users/statop/GitHub/konan_cmake_HelloTensorflow/cmake-build-debug/HelloTensorflow.kexe
  Reason: image not found

Process finished with exit code 6
BTW, the unresolved references are gone again
s
Looks like the env variable not set properly
l
It's like you saw it in my screenshot
Should I use
$HOME
instead of
~
?
s
Try to use absolute paths
This is worked for me: https://yadi.sk/i/kM1yEUwP3Q8ykE
l
Works with absolute path!
👍🏻 1
Thanks a lot for helping me overcome these roadblocks!
s
No problem )
l
So 3+2 = 5 😂
Given I'm a beginner in the native world (but not in Kotlin, used for 1y+ on Android apps, nor Java used it for ~4y, minus the Kotlin year and the upcoming ones), where can I learn more about CMake, C (for interop with Kotlin/Native and general knowledge) and machine learning? Also want to learn about LLVM. I'm a bit confused by all of this now, don't know where to start, and all resources I looked at by now kept me at the bottom of the learning curve.
s
Sorry, I’m not an expert in C/CMake nor in ML. For ML looks like #datascience is good place for this question.