I added the mochijson2.erl module to my ejabberd src directory but when I try to compile the code I get the following error:
./mochijson2.erl:8: redefining module
Where could this module be defined? I don't have it in my source.
It means your module has two -module(...) directives, which is not allowed. Check the source code of the module.
Related
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 downloaded the zbar library and cloned the opencv-zbar repo in my home directory. Then I ran the following command $cmake . which gave my the error
-- Could NOT find ZBAR (missing: ZBAR_LIBRARIES ZBAR_INCLUDE_DIR)
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
ZBAR_LIBRARIES
linked by target "zbar_opencv" in directory /home/surabhi/opencv-zbar
-- Configuring incomplete, errors occurred!
See also "/home/surabhi/opencv-zbar/CMakeFiles/CMakeOutput.log".
I then made two changes in my CMakeCache.txt as follows
//Path to a file.
ZBAR_INCLUDE_DIR:PATH=/usr/include/zbar
//Path to a library.
ZBAR_LIBRARIES:FILEPATH=/usr/lib/libzbar.so
because the were set to NOTFOUND.
It then gave me no errors
-- Found ZBAR: /usr/lib/libzbar.so
-- Configuring done
-- Generating done
-- Build files have been written to: /home/surabhi/opencv-zbar
But when I run make
It gives the error:
fatal error: zbar.h: No such file or directory
#include <zbar.h>
^
compilation terminated.
I don't understand why I get this error as It says Found ZBAR when I run cmake.
Thanks in advance
You need to do actually use the include dirs somewhere in your CMakeLists.txt so CMake knows that you actually want to use these include paths.
Examples:
include_directories(${ZBAR_INCLUDE_DIR})
Or the more modern, recommended way:
target_include_directories(zbar_opencv PRIVATE ${ZBAR_INCLUDE_DIR})
I'm trying to add ASAN sanitize to our project which uses Bazel and stuck with the following problem. I've added blacklist for sanitize in our bazel.rc
build:asan --copt -fsanitize=address
build:asan --linkopt -fsanitize=address
build:asan --copt -fsanitize-blacklist=blacklist.txt
but when I build a target I get missing dependency error
ERROR: memory/main/BUILD:1:1: undeclared inclusion(s) in rule '//main:memory_leak':
this rule is missing dependency declarations for the following files included by 'main/memory_leak.cpp':
'memory/blacklist.txt'
Target //main:memory_leak failed to build
It seems that blacklist.txt should be added to the build rule in BUILD file, but we cannot really do that for all gazillion rules we already have. Is there a way to add a global dependency for all rules or something like this?
Normally the C++ toolchain should have the dependency but it is auto-generated.
You can always create a macros to overwrite the default cc_library:
In tools/build_rules/prelude_bazel:
load('#//tools/build_rules:cc.bzl', 'cc_library')
in tools/build_rules/cc.bzl:
def cc_library(data=[], **kwargs):
native.cc_library(data = data + ['//memory:blacklist.txt'], **kwargs)
in memory/BUILD:
exports_files(['blacklist.txt'])
Also add an empty file tools/build_rules/BUILD.
The first file is importing the cc_library in the begining of all your file, the second file is defining a new cc_library that adds the missing dependency and the third file just expose the 'blacklist.txt' to all the other rules. The last empty file is just to define a package for Bazel that is needed to load the cc.bzl file.
When I run using JLD I get the following warnings:
INFO: Recompiling stale cache file C:\Julia\PkgDir\lib\v0.4\JLD.ji for module JLD.
WARNING: Module HDF5 uuid did not match cache file
This is likely because module HDF5 does not support precompilation but is imported by a module that does.
WARNING: deserialization checks failed while attempting to load cache from C:\Julia\PkgDir\lib\v0.4\JLD.ji
INFO: Precompiling module JLD...
INFO: Recompiling stale cache file C:\Julia\PkgDir\lib\v0.4\JLD.ji for module JLD.
WARNING: Module HDF5 uuid did not match cache file
This is likely because module HDF5 does not support precompilation but is imported by a module that does.
__precompile__(true) but require failed to create a precompiled cache file
If I then run say:
A=ones(40)
save("c:\\OneDrive\\Model\\myfile.jld", "A", A)
I get the error:
UndefVarError: save not defined in include_string at loading.jl:288 in eval at
C:\Julia\PkgDir\v0.4\Atom\src\Atom.jl:3 [inlined code] from
C:\Julia\PkgDir\v0.4\Atom\src\eval.jl:39 in anonymous at
C:\Julia\PkgDir\v0.4\Atom\src\eval.jl:108 in withpath at
C:\Julia\PkgDir\v0.4\Requires\src\require.jl:37 in withpath at
C:\Julia\PkgDir\v0.4\Atom\src\eval.jl:53 [inlined code] from
C:\Julia\PkgDir\v0.4\Atom\src\eval.jl:107 in anonymous at task.jl:58
I'm using Atom 1.8.0 and Julia 0.4.7. I'm using JLD as, to the best of my knowledge, it's the only pkg that allows me to write variables to file and preserve all of their attributes.
I had a similar issue with JLD at one point and running Pkg.update() fixed it. Updating to the latest stable Julia version before running the package update could also be helpful.
First of all, 'rebar doc' works sometimes and sometimes not. It is strange.
Rebar version which I'm using is 2.5.1
My folder structure is:
Header_Directory
1.1 apps
1.1.1 sub_dir_1
1.1.2 sub_dir_2 / include
1.1.3 sub_dir_3
1.2 deps
1.3 confs
rebar.config
Modules in sub_dir_3 also use some include files from sub_dir_2/include folder.
The error I get when I use the command rebar doc is:
.sub_dir_3/src/my_log_worker.erl, in module header: at line 9: file
not found: some.hrl edoc: skipping source file
'sub_dir_3/src/my_log_worker.erl': {'EXIT',error}. edoc: error in
doclet 'edoc_doclet': {'EXIT',error}. ERROR: doc failed while
processing /home/learn/header_directory/apps/sub_dir_3: {'EXIT',error}
I do 'rebar clean' and then 'rebar compile' prior to 'rebar doc'
Also,when I do it in erl shell, I get error.
edoc:file("some_log_worker.erl", []).
edoc: error reading file 'some_log_worker.erl'.
** exception exit: {error,enoent}
in function edoc:read_source/2 (edoc.erl, line 664)
in call from edoc_extract:source/3 (edoc_extract.erl, line 52)
in call from edoc:read/2 (edoc.erl, line 537)
in call from edoc:file/2 (edoc.erl, line 116)
Is there any way by which I can include my hrl file either in rebar.config or edoc options?
I have '{edoc_opts, [{ i, "apps/sub_dir_3/include" }]}.' in rebar.config, still of no help.
It looks like you didn't follow the rebar/OTP conventions:
OTP Conventions
Rebar expects projects to follow the OTP conventions as described in
the OTP Design Principles document: Applications
An application should consists of the following set of directories:
src
ebin
priv
include
and have an application resource file: ebin/example_project.app or
src/example_project.app.src. In the later case, the
ebin/example_project.app file is generated from the
src/example_project.app.src one automatically during the compilation
phase.
Rebar & OTP convetions
I recommend you to move to that file organisation, it will be really much simpler to benefit from standard tools like rebar.
Yes, it is always in the best interest to follow the OTP principles. However, it worked for my app structure.
The only problem was because of #headerfile annotation in the erlang modules. Somehow, I don't know how to correctly use the #headerfile annotation.
Thanks for all the help. :)