yesib0

yesib0

KafkaEx compilation error on Windows

Hello everyone! I’m new here.

I’m trying to use KafkaEx in an app running on Windows 10 , but when I run mix deps.compile, I get an error related to the c++ compiler.

mix deps.get

Resolving Hex dependencies...
Dependency resolution completed:
Unchanged:
  connection 1.1.0
  crc32cer 0.1.10
  kafka_ex 0.12.1
  kayrock 0.1.14
  varint 1.2.0
* Getting kafka_ex (Hex package)
* Getting kayrock (Hex package)
* Getting connection (Hex package)
* Getting crc32cer (Hex package)
* Getting varint (Hex package)
$ mix deps.compile

==> connection
Compiling 1 file (.ex)
Generated connection app
==> varint
Compiling 2 files (.ex)
Generated varint app
===> Fetching pc (from {git,"https://github.com/blt/port_compiler.git",{tag,"v1.10.2"}})
===> Analyzing applications...
===> Compiling pc
===> Compiling c:/omited_path/kafka_conn_app/deps/crc32cer/c_src/crc32c.c
===> **'cl.exe' is not recognized as an internal or external command,**
operable program or batch file.

==> kafka_conn_app
** (Mix) Could not compile dependency :crc32cer, "escript.exe "c:/Users/Yesid/.mix/rebar3" bare compile --paths c:/omited_path/kafka_conn_app/_build/dev/lib/*/ebin" command failed. Errors may have been logged above. You can recompile this dependency with "mix deps.compile crc32cer", update it with "mix deps.update crc32cer" or clean it with "mix deps.clean crc32cer"

escript.exe is in the $PATH variable and rebar3 exists in the specified path.

I installed Visual Studio Community 2022 with the C++ compilers and ran the .bat file found here;
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat
That script sets all the environment variables necessary for the C++ compiler to run.
With this approach I was able to compile the KafkaEx dependency successfully, but I’m trying to find another way to compile it because it’s a bit of a hassle having to run that script every time I want to compile my application’s dependencies.

Elixir version: 1.13.0
Erlang/OTP 24

I really appreciate any help!
Thanks!

Marked As Solved

crispinb

crispinb

Whatever terminal app you use will somewhere have a place to configure the shell (cmd or powershell) startup. Just make sure the relevant vcvars*.bat file is run when starting up your shell.

I used the new Windows Terminal, configured in settings a profile to start with cmd /k "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars64.bat" && pwsh.exe. That profile is now always equipped with the necessary paths. You could do something similar if you use cmd.exe rather than powershell.

Also Liked

cmo

cmo

You could write a mix alias which does that for you.

Or run it from within the VS developer console, though that’s probably no less hassle then running the script.

Or try using zig as your C compiler.

yesib0

yesib0

It worked, thanks!

Where Next?

Popular in Questions Top

openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
Werner
Hi, I’m using Ubuntu 18.04 and after updating to OTP-24.0 yesterday i have this warning when I run “mix local.hex”: 14:57:30.512 [warn] ...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
kostonstyle
Hi all I want to have a unix time, from the current time plus 1 hour. DateTime.now + 1 hour How to get it in elixir? Thanks
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New
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
sabri
Can someone explain the settings of pool_size of Ecto in config file? and what is the recommend size? Thanks
New

Other popular topics Top

peerreynders
Manning 2016 Halloween weekend sale via Deal of the Day Friday, October 28 - Half off all MEAPs - code WM102816LT Saturday, October 29 ...
326 29600 154
New
sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
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
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
273 38985 115
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement