I started learning Erlang, after read first chapter got strange error during compilation of module.
So when I try to compile demo.erl
-module(demo).
-author("alex").
-export([double/1]).
double(Value) ->
Value * 2.
So I try to compile it
1> m(demo).
and got
** exception error: undefined function demo:module_info/0
The only way to compile was
make:files(filelib:wildcard("demo.erl")).
I got demo.beam and now even after deletion of it m(demo). begin work.
Can anyone explain to me that compiler behavior?
To compile a module from the Erlang shell, use the c command:
1> c(demo).
{ok,demo}
The shell m command is for retrieving information about a compiled module:
2> m(demo).
Module: demo
MD5: 422cee9099e136c6dec13dd200927c63
Compiled: December 12 2015, 22:51
Object file: /tmp/demo.beam
Compiler options: []
Exports:
double/1
module_info/0
module_info/1
ok
Related
I am trying to install ChicagoBoss based on the instructions here. Now, Make is failing with exception -
=ERROR REPORT==== 14-Dec-2022::11:15:33.605319 ===
beam/beam_load.c(148): Error loading module rebar:
please re-compile this module with an Erlang/OTP 25 compiler
escript: exception error: undefined function rebar:main/1
in function escript:run/2 (escript.erl, line 750)
in call from escript:start/1 (escript.erl, line 277)
in call from init:start_em/1
in call from init:do_boot/3
make: *** [compile] Error 127
I have further installed rebar3 using command -
homebrew install rebar3
I am running Erlang OTP/25 in mac. I haven't been able to understand if it's a problem with
rebar3
or
ChicagoBoss
The problem is with ChicagoBoss. It includes a rebar binary that was compiled with Erlang/OTP release 17, but Erlang/OTP release 25 can only use modules compiled with release 21 or later.
The rebar binary starts with the line #!/usr/bin/env escript, meaning that it looks for escript in the PATH. This picks up release 25, causing this problem. You could try installing release 24 or earlier to work around this.
You might find ASDF useful for switching between Erlang versions: https://github.com/asdf-vm/asdf-erlang
I am unable to use ejabberd_auth in my helloworld project.
-behaviour(ejabberd_auth).
...
....
try_register(<<"username">>, <<"example.com">>, <<"secret_password">>).
With that I get the error warning:
helloworld.erl:15: Warning: behaviour ejabberd_auth undefined
-import(ejabberd_auth, [try_register/3]).
...
....
try_register(<<"username">>, <<"example.com">>, <<"secret_password">>).
With this I get:
exception error: undefined function ejabberd_auth:try_register/3
Why am I unable to access ejabberd_auth?
I am using IntelliJ Idea, with the Erlang plugin installed.
Thank you all in advance.
UPDATE:
I'm on Ubuntu 16.04 LTS
I can get you past that error. Here's how...
When I compile a module in the erlang shell, the compiler creates a .beam file in the same directory, which allows me to call functions defined in the module. In your case, if you cd into the directory:
.../ejabberd/ebin
you will see all the ejabberd .beam files, including ejabberd_auth.beam. If you start an erlang shell in that directory, then issue your function call (don't compile anything), you won't get that error anymore.
But, then I get the error:
exception error: undefined function jid:nodeprep/1
in function ejabberd_auth:validate_credentials/3 (src/ejabberd_auth.erl, line 796)
in call from ejabberd_auth:try_register/3 (src/ejabberd_auth.erl, line`
There is no jid.beam file in that directory. But:
~/Downloads/ejabberd$ find . -name jid.beam
./deps/xmpp/ebin/jid.beam
You are going to have to figure out how to compile your module so that all the ejabberd modules are available to your program. See: ejabberd how to compile new module.
I am unable to use ejabberd_auth in my helloworld project.
Are you following a tutorial somewhere?
I have Erlang/OTP 19 [erts-8.3.5] and runtime_tools included in release, rel/reltool.config.script: [tools, runtime_tools];, but when I trying using dbg I got
error: dbg:tracer().
** exception error: undefined function dbg:tracer/0
Looks like dbg module is not included to my application
(ejabberd#localhost)4> m(dbg).
** exception error: undefined function dbg:module_info/0
I want use erlang easy profiler, that I successfully used on erl 16
Does anyone faced with this problem?
I need to build OpenCV from source, because I want to make modifications to it. So using pre-built binaries is not an option for me. I'm doing this on Windows 8. I do not have MS Visual Studio, and I don't want to use it.
Here is how I reproduce the build error:
I git clone https://github.com/opencv/opencv
I use CMake 3.7.1, press Configure, then press Generate. It seems to work (no errors). I named the output folder opencv/release.
I go to the opencv/release folder, and type mingw32-make.
Eventually, after compiling for a while, it displays the following error message:
Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/parallel.cpp.obj
modules\core\src\parallel.cpp:135:43: error: operator '&&' has no right operand
modules\core\src\parallel.cpp: In function 'void cv::parallel_for_(const cv::Range&, const cv::ParallelLoopBody&, double)':
modules\core\src\parallel.cpp:311:52: error: 'parallel_for_pthreads' was not declared in this scope parallel_for_pthreads(range, body, nstripes);
^
modules\core\src\parallel.cpp: In function 'int cv::getNumThreads()':
modules\core\src\parallel.cpp:370:50: error: 'parallel_pthreads_get_threads_num' was not declared in this scope return parallel_pthreads_get_threads_num();
^
modules\core\src\parallel.cpp: In function 'void cv::setNumThreads(int)':
modules\core\src\parallel.cpp:431:46: error: 'parallel_pthreads_set_threads_num' was not declared in this scope parallel_pthreads_set_threads_num(threads);
^
modules\core\CMakeFiles\opencv_core.dir\build.make:990: recipe for target 'modules/core/CMakeFiles/opencv_core.dir/src/parallel.cpp.obj' failed mingw32-make[2]: *** [modules/core/CMakeFiles/opencv_core.dir/src/parallel.cpp.obj] Error 1
Note: I tried to compile both with and without TPP (in the CMake config), and I get the same error message.
Also, I read the other similar questions on StackOverflow and the answers do not help.
I user rebar to make a eunit test with command "rebar compile eunit",but get a error info:
==> myapp (compile)
==> myapp (eunit)
src/myapp_app.erl:8: badly formed 'include_lib'
src/myapp_app.erl:26: undefined macro 'assertNot/1'
ERROR: eunit failed while processing /Users/Dao/ErlProject/myapp: rebar_abort
I really don't know how this mean,who can tell me why?
PS:my english is poor,please forgive me
myapp_app.erl like this:
-ifdef(TEST).
-include_lib(“eunit/include/eunit.hrl”).
-endif.
........
-ifdef(TEST).
simple_test() ->
ok = application:start(myapp),
?assertNot(undefined == whereis(myapp_sup)).
-endif.
and It's came from here:https://github.com/rebar/rebar/wiki/Getting-started
I follow the step,but got the error!
My erlang version is R15B03
os: OS X Lion
Based on the code you've presented, I believe the problem has to do with the doublequotes you're using. Right now, you are using some kind of slanted quotes, which, if I copy and paste it and use that same definition myself in a test module, it generates the same error.
You want to make sure for your doublequotes that you use "normal" ones:
" (ASCII 34) instead of ”, which is unicode.
So change
-include_lib(“eunit/include/eunit.hrl”).
to
-include_lib("eunit/include/eunit.hrl").
Make sure you include eunit in the following way:
-include_lib("eunit/include/eunit.hrl").
Needless to say, make sure you installed eunit at all. So far I remember, it may be not installed by default in some Ubuntu versions, for instance.