SBT native link command not working?

I’m trying out scala native. I have used the official example. I want to generate the binary file with sbt.

But when I do native link ,I get the following error.

[error] Not a valid command: nativeLink
[error] Not a valid project ID: nativeLink
[error] Expected ‘:’
[error] Not a valid key: nativeLink
[error] nativeLink
[error] ^

What am I missing?

Gracias !!!

Did you add and enable the scala native sbt plugin?

It’s enabled by default right ? Coz this is the scala-native official example .

My build.sbt

scalaVersion := “2.11.12”

// Set to false or remove if you want to show stubs as linking errors
nativeLinkStubs := true

enablePlugins(ScalaNativePlugin)

My plugins.sbt

addSbtPlugin(“org.scala-native” % “sbt-scala-native” % “0.3.7”)

Everything’s ok ?

Thank you!

Looks ok to me.

I think it is not recognising ‘nativeLink’ command ?

suryax04

Let me see if I can help out. I am a scala-native user, since 1 year +, but not a devo.

Looks like you are using the most current scala-native (0.3.7). Good.

TLDR; try the “run” command. I believe you are right the nativeLInk may no longer
exist.

Longer story:

  I believe the "run" command is your friend.  It produces (including linking) an

executable file and then executes it. The file created is left the ${project_root}/target/mumble directory. I can not remember a time, if ever, I used a nativeLink or such command. Many a time I have set nativeLinkingOptions (and the prior name).

Your situation may vary. If you really want/need a “nativeLink” for your application, try
the “sbt> help”, “sbt> help tasks”, & “tasks -V” sequence. Those make SBT friendlier.

I could not see a nativeLink task. I think it got factored out in the 0.3.7 build API rework.

So, “run” may give you more than you need but it may get you going.

Let me know if this information is helpful. Always nice to see another person using scala-native.

Lee

Got this error with sbt run:

[error] /data/data/com.termux/files/home/hello/target/scala-2.11/native/lib/unwind.c:4:12: warning: use of SP or PC in the list is deprecated [-Winline-asm]
[error] return unw_getcontext((unw_context_t *)context);
[error] ^
[error] /usr/include/libunwind-common.h:108:29: note: expanded from macro ‘unw_getcontext’
[error] #define unw_getcontext(uc) unw_tdep_getcontext(uc)
[error] ^
[error] /usr/include/libunwind-arm.h:270:5: note: expanded from macro ‘unw_tdep_getcontext’
[error] “stmia %[base], {r0-r15}”
[error] ^
[error] :1:2: note: instantiated into assembly here
[error] stmia r0, {r0-r15}
[error] ^
[error] 1 warning generated.
[error] /usr/bin/ld: cannot find crtbeginS.o: No such file or directory
[error] /usr/bin/ld: cannot find -lunwind-armv7
[error] clang-6.0: error: linker command failed with exit code 1 (use -v to see invocation)
[info] Linking native code (boehm gc) (739 ms)
java.io.IOException: Cannot run program “/data/data/com.termux/files/home/hello/target/scala-2.11/hello-out”: error=2, No such file or directory

suryax04

The information you provided is quite helpful. It looks like you are running some form of linux on arm-7 hardware. I do not know much about ARM, but a quick lookup seems to indicate that arm-7 is a 32-bit system. Is that true?

If yes, I believe that out-of-the-box scala-native will not work. The good news is that github user shadaj has a 32-bit arm clone working at Github URL: https://github.com/shadaj/scala-native/tree/32-bit-support.

I do not know at 4AM local time if standard scala-native supports 64 bit ARM. If not, Shadaj might have a private clone which does.

I am indebted to Shadaj because his 32-bit ARM work forms the basis of my own private 32-bit X86 work.

If my surmise that you are on 32-bit ARM is correct and are also interested in shadaj’s 32-bit clone, I can walk you through building your private copy. Shadaj’s clone is currently at scala-native 0.3.6. The rebase onto 0.3.7 in my private clone was a few hours work. It would go faster for you because I have done it once & can give you some of the required edits.

If you are on 64 bit (and scala-native is supposed to support 64 bit ARM) we would have to dig deeper. The fault chain appears to be that the hello-out executable fails because the link failed. Probably no news to you. I am not sure if the compile of unwind.c completed.
I think it did. crtbeginS.o is new to me, we would have to track down why it is missing (or if it is specified when not needed.). The libunwind-armv7 issue may be either that it is supposed to be on your system and is missing or that the scala-native build chain specifies the wrong library name for your system. Shadaj has probably figure this out already.

Lee

Thanks for the detailed information , Lee.

Yea…I’m on a nexus 5 - armv7 platform.

If you could guide me through setting up scala native on 32 bit devices,it would be really awesome !

Thanks a ton ,

Poo.

If you could document this process and post a link afterwards, that’s be very much appreciated. I’m sure you’re not the only one who will try to link natively for mobile devices like this.

-dave-

@suryax04, @virus_dave,

scala-native advanced from version 0.3.3 to 0.3.4. about three weeks or so ago.
I have been trying since then to get my X86 build to pass acceptance tests so that
I could roughly document the scala-native build process & upgrade to 0.3.4.
No joy, sorry.

I suspect the problem I am chasing is small, once I find it. I also suspect that it
affects arm also. It definitely is humbling me…

Lee