PREFIX = ENV["PREFIX"]
using Cxx
addHeaderDir(joinpath(PREFIX, "include"))
addHeaderDir("/usr/include")
addHeaderDir("/usr/include/eigen3")
using Libdl
dlopen(joinpath(PREFIX, "lib/AAAA.so"), RTLD_GLOBAL)
cxx"""
#include "BBBB.h"
#include "AAAA.h"
void simulate_cpp() {
// some C++ code
}
"""
simulate() = @cxx simulate_cpp()
If I put this code in a.jl, then I start julia (1.3.1) with include("a.jl") it will run correctly
If I put this code in one module, defined like below:
module BBB
# same code as above
end
then when I call this module,
using BBB
# reported warning:
# [ Info: Precompiling BBB [-----]
# WARNING: eval into closed module CxxCore:
# Expr(:let, Expr(:call, :f) = Expr(:block, #= Symbol("/home/xxxx/.julia/packages/Cxx/1RaOv/src/initialization.jl"):72 =#, Expr(:call, :llvmcall, 0x000000000bda98f8, :Cvoid, Expr(:curly, :Tuple))), Expr(:block, #= Symbol("/home/xxxx/.julia/packages/Cxx/1RaOv/src/initialization.jl"):72 =#, Expr(:call, :f)))
# ** incremental compilation may be fatally broken for this module **
BBB.simulate()
julia> sanyi.simulate()
ERROR: Could not find `simulate_cpp` in translation unit
Stacktrace:
[1] error(::String) at ./error.jl:33
[2] lookup_name(::Cxx.CxxCore.ClangCompiler, ::Tuple{Symbol}, ::Ptr{Nothing}, ::Cxx.CxxCore.CppPtr{Cxx.CxxCore.CxxQualType{Cxx.CxxCore.CppBaseType{Symbol("clang::Decl")},(false, false, false)},(false, false, false)}, ::Bool) at /home/xxx/.julia/packages/Cxx/1RaOv/src/typetranslation.jl:116
[3] declfornns(::Cxx.CxxCore.ClangCompiler, ::Type{Cxx.CxxCore.CppNNS{Tuple{:simulate_cpp}}}, ::Ptr{Nothing}) at /home/hongbo/.julia/packages/Cxx/1RaOv/src/codegen.jl:273
[4] declfornns(::Cxx.CxxCore.ClangCompiler, ::Type{Cxx.CxxCore.CppNNS{Tuple{:simulate_cpp}}}) at /home/xxx/.julia/packages/Cxx/1RaOv/src/codegen.jl:240
[5] _cppcall(::Type, ::Type, ::Bool, ::Bool, ::Tuple{}) at /home/hongbo/.julia/packages/Cxx/1RaOv/src/codegen.jl:559
[6] #s37#39(::Any, ::Any, ::Any, ::Any) at /home/xxx/.julia/packages/Cxx/1RaOv/src/codegen.jl:841
[7] (::Core.GeneratedFunctionStub)(::Any, ::Vararg{Any,N} where N) at ./boot.jl:524
[8] simulate() at /home/xxx/Developer/Works/BBBB/aaa_demo/aaaa/src/BBB.jl:62
[9] top-level scope at REPL[2]:1
I have code like below:
If I put this code in
a.jl
, then I start julia (1.3.1) withinclude("a.jl")
it will run correctly If I put this code in one module, defined like below:then when I call this module,