WolfDan

WolfDan

Making NIFs easier to work with on Windows 10 (And making work Elixir-ls too)

So my main OS is Windows, I do must of my work with it, Elixir and vscode elixirls works just fine when you’re working only with elixir, but when you’re working with nifs (more specifically the C/C++ code) can became really annoying to work with, this because of the compilation process of the Nifs

I endup running visual code on WSL, but today it stop working and corrupted all the permissions on the project I was working on (fortunatelly I was able to recover the data using linux dual boot), so I decided to look a way to simplify the windows development and make it work with elixir-ls as well, this is the result of my findings and how it solves all the problems I’ve faced before so far

This guide applies using Visual Studio 2017 Professional, but it must work with other versions as well, you just need to change the path

Getting the compiler and the path of the file “vcvarsall.bat”

If you have compiled nifs befores, you must already know that this is the great wall.

You must install Visual Studio 2017 (but it should work with older versions as well), make sure to have marked the option “Desktop Development with C++” it should install VC++ which contains the file, on the last version of VS is located at C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build, if is not, just go to your Visual Studio install folder and search for the file

Note: You must install Visual Studio with the English language pack!, I had the Spanish version and elixir-ls throws errors when it must print on console a diacritical character


- I only want to compile my files easier using VSCode, I don-t make use of ElixirLs

In that case you must chage the settings.json of VisualCode, adding this:

    "terminal.integrated.shellArgs.windows": [
        "/K",
        "C:\\PROGRA~2\\MICROS~1\\2017\\Professional\\VC\\Auxiliary\\Build\\vcvarsall amd64"
    ],

the second argument is the vcvarsall path location and the amd64 parameter


- I want to compile and make work ElixirLS

This solution is taken from this link, it covers older versions of Visual Studio, basically what vcvarsall does is setting up env variables during the session to make the compile, to make ElixirLS work we must set those variables manually, here’s the variables to set

INCLUDE
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.15.26726\include;C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.15.26726\atlmfc\include

LIB
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.15.26726\lib\x64

PATH
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE;C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.15.26726\bin\Hostx64\x64

This might change depending the on the version, but if you look carefully all the folders you want are inside the VC folder

With this method you can compile your nif code from a normal CMD or powershell without the need of calling the vcvarsall script!

(this will solve your issues compiling Bcrypt! Yei!)


So that’s all, if you see any grammar error, do not understand the explanation, need specific details or have a better option to solve it please let me know or feel free to edit the post :smiley:

Most Liked

OvermindDL1

OvermindDL1

For note, I had many issues with wsl so I ended up just using a normal mingw setup and never had issues after that once I got it all set up back when I still had to program on windows (blehg).

OvermindDL1

OvermindDL1

It is a bit of a pain to setup, but the installer for it nowadays are pretty rock solid to get a fully setup area for you now.

Really, give Kubuntu (18.10) a try, I’ve converted SO many people off Windows to it. And as for games you do know that Steam has a fully built in Wine support now (with whitelisted games by default or enable for all games via an option settings if you don’t mind the occasional package installation into a games prefix, protontricks is awesome for that, or just use wine straight for things not in steam). Not sure what ‘designs are awful’ you speak of, considering every distribution is incredibly different in many ways. As for problems, wow that incomparable in my experience, the amount of issues Windows gets at work and on friends systems (prior to linux conversion) is astounding, linux “Just works” (I don’t use laptops though but 2 of my friends that converted to linux on their laptops works perfectly, I know in the past there used to be issues though but it’s pretty solid now). As for gaming, nVidia’s drivers, as always, suck horribly, a modern AMD (or even Intel) setup is so much more stable than nVidia’s crashy binary blobs…

Where Next?

Popular in Guides/Tuts Top

eclark
I’ve been working on a phoenix project lately and I wanted to use the latest versions of everything. Webpack 5 had some breaking changes ...
New
Logan
Here is an example of a Mix application that utilizes Cowboy to handle websocket connections. If anyone has an idea about making this wor...
New
dgamidov
Hi folks, Just a short instruction. Maybe it will help somebody. https://v4-alpha.getbootstrap.com/getting-started Install boostrap...
New
njwest
In the process of developing a Phx-based multiplayer experience, I found myself with so many browser tabs open with Elixir gaming resourc...
New
tomciopp
TLS 1.3 has been out for a little over a year now, but it has been unavailable in Phoenix due to erlang’s handling of ssl. With the most ...
New
thetechnologyvault
One of our team members just published this getting started guide for Elixir/Phoenix devs to use the Nanobox platform: https://content.n...
New
emilsoman
Hello, While answering a StackOverflow question on how to debug an elixir node running remotely, I thought it may be helpful to write a...
New
TwistingTwists
This is a thread to note down things/best practices encountered in LiveBeats App as I explore the source code. Found this usage of r...
New
bluegene
Hi guys, I’ve been on a personal journey to learn Elixir for the past two years. During this journey I’ve been using the spaced repetiti...
New
tonydang
I recently got inertia-phoenix (an Inertia.js adapter for Phoenix) working with Svelte. Setting up the server-side rendering (SSR) with S...
New

Other popular topics Top

belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 45766 226
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 49522 488
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
sacepums
Hey guys. I'm new to elixir and im really stocked about it. But I ran into a bit of problem - I need to convert a date sting, for examp...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New

We're in Beta

About us Mission Statement