I’m trying to wrap the LibRaw C library in Julia using Clang.jl to provide the .raw image support in Julia. The wrapping was done successfully to give me a .jl file, with julia functions calling all the respective C language functions as follows:
Next I wrote the code for decoding a .raw file as follows:
include("lib/LibRaw.jl")
function decode_image(filename::AbstractString)
data = LibRaw.libraw_init(0)
LibRaw.libraw_open_file(data, filename)
LibRaw.libraw_unpack(data)
# process decoded image data
LibRaw.libraw_free_image(data)
LibRaw.libraw_recycle(data)
LibRaw.libraw_close(data)
return data
end
filename = "test\\nikon\\Nikon-D4-Shotkit-2.NEF"
data = decode_image(filename)
But on running this code I’m getting the following error after a very long error messege:
ERROR: `ccall` requires the compiler
Stacktrace:
[1] libraw_init(flags::Int64)
@ Main.LibRaw d:\D_Drive_HP\ImageIO\libraw\lib\LibRaw.jl:737
[2] decode_image(filename::AbstractString)
@ Main d:\D_Drive_HP\ImageIO\libraw\librawtest.jl:5
[3] top-level scope
@ d:\D_Drive_HP\ImageIO\libraw\librawtest.jl:17
The complete error messege is:
Internal error: encountered unexpected error during compilation of decode_image:
TypeError(func=:ccall, context="", expected=Symbol, got=LibRaw)
ijl_type_error_rt at /cygdrive/c/buildbot/worker/package_win64/build/src\rtutils.c:119
ijl_type_error at /cygdrive/c/buildbot/worker/package_win64/build/src\rtutils.c:127
interpret_symbol_arg at /cygdrive/c/buildbot/worker/package_win64/build/src\ccall.cpp:611
emit_ccall at /cygdrive/c/buildbot/worker/package_win64/build/src\ccall.cpp:1280
emit_expr at /cygdrive/c/buildbot/worker/package_win64/build/src\codegen.cpp:4723
emit_ssaval_assign at /cygdrive/c/buildbot/worker/package_win64/build/src\codegen.cpp:4310
emit_stmtpos at /cygdrive/c/buildbot/worker/package_win64/build/src\codegen.cpp:4557 [inlined]
emit_function at /cygdrive/c/buildbot/worker/package_win64/build/src\codegen.cpp:7387
jl_emit_code at /cygdrive/c/buildbot/worker/package_win64/build/src\codegen.cpp:7722
jl_emit_codeinst at /cygdrive/c/buildbot/worker/package_win64/build/src\codegen.cpp:7767
_jl_compile_codeinst at /cygdrive/c/buildbot/worker/package_win64/build/src\jitlayers.cpp:119
jl_generate_fptr_impl at /cygdrive/c/buildbot/worker/package_win64/build/src\jitlayers.cpp:332
jl_compile_method_internal at /cygdrive/c/buildbot/worker/package_win64/build/src\gf.c:2081
jl_compile_method_internal at /cygdrive/c/buildbot/worker/package_win64/build/src\gf.c:2028 [inlined]
_jl_invoke at /cygdrive/c/buildbot/worker/package_win64/build/src\gf.c:2359 [inlined]
ijl_apply_generic at /cygdrive/c/buildbot/worker/package_win64/build/src\gf.c:2549
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1839 [inlined]
do_call at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:126
eval_value at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:215
eval_stmt_value at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:166 [inlined]
eval_body at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:594
jl_interpret_toplevel_thunk at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:750
top-level scope at d:\D_Drive_HP\ImageIO\libraw\librawtest.jl:17
jl_toplevel_eval_flex at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:906
jl_toplevel_eval_flex at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:850
ijl_toplevel_eval at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:915 [inlined]
ijl_toplevel_eval_in at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:965
eval at .\boot.jl:368 [inlined]
include_string at .\loading.jl:1428
include_string at .\loading.jl:1438
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1839 [inlined]
jl_f__call_latest at /cygdrive/c/buildbot/worker/package_win64/build/src\builtins.c:774
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1839 [inlined]
do_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\builtins.c:730
#invokelatest#2 at .\essentials.jl:729
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1839 [inlined]
do_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\builtins.c:730
invokelatest at .\essentials.jl:726
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1839 [inlined]
do_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\builtins.c:730
#inlineeval#71 at c:\Users\Aditi Dey\.vscode\extensions\julialang.language-julia-1.38.2\scripts\packages\VSCodeServer\src\eval.jl:233
inlineeval##kw at c:\Users\Aditi Dey\.vscode\extensions\julialang.language-julia-1.38.2\scripts\packages\VSCodeServer\src\eval.jl:230 [inlined]
#66 at c:\Users\Aditi Dey\.vscode\extensions\julialang.language-julia-1.38.2\scripts\packages\VSCodeServer\src\eval.jl:157
withpath at c:\Users\Aditi Dey\.vscode\extensions\julialang.language-julia-1.38.2\scripts\packages\VSCodeServer\src\repl.jl:249
#65 at c:\Users\Aditi Dey\.vscode\extensions\julialang.language-julia-1.38.2\scripts\packages\VSCodeServer\src\eval.jl:155
hideprompt at c:\Users\Aditi Dey\.vscode\extensions\julialang.language-julia-1.38.2\scripts\packages\VSCodeServer\src\repl.jl:38
#64 at c:\Users\Aditi Dey\.vscode\extensions\julialang.language-julia-1.38.2\scripts\packages\VSCodeServer\src\eval.jl:126
unknown function (ip: 000000005a887083)
with_logstate at .\logging.jl:511
with_logger at .\logging.jl:623 [inlined]
#63 at c:\Users\Aditi Dey\.vscode\extensions\julialang.language-julia-1.38.2\scripts\packages\VSCodeServer\src\eval.jl:225
unknown function (ip: 000000005a885553)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1839 [inlined]
jl_f__call_latest at /cygdrive/c/buildbot/worker/package_win64/build/src\builtins.c:774
#invokelatest#2 at .\essentials.jl:729 [inlined]
invokelatest at .\essentials.jl:726
unknown function (ip: 000000005a87d9c6)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1839 [inlined]
do_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\builtins.c:730
macro expansion at c:\Users\Aditi Dey\.vscode\extensions\julialang.language-julia-1.38.2\scripts\packages\VSCodeServer\src\eval.jl:34 [inlined]
#61 at .\task.jl:484
unknown function (ip: 000000005a864cf3)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1839 [inlined]
start_task at /cygdrive/c/buildbot/worker/package_win64/build/src\task.c:931
Internal error: encountered unexpected error during compilation of libraw_init:
TypeError(func=:ccall, context="", expected=Symbol, got=LibRaw)
ijl_type_error_rt at /cygdrive/c/buildbot/worker/package_win64/build/src\rtutils.c:119
ijl_type_error at /cygdrive/c/buildbot/worker/package_win64/build/src\rtutils.c:127
interpret_symbol_arg at /cygdrive/c/buildbot/worker/package_win64/build/src\ccall.cpp:611
emit_ccall at /cygdrive/c/buildbot/worker/package_win64/build/src\ccall.cpp:1280
emit_expr at /cygdrive/c/buildbot/worker/package_win64/build/src\codegen.cpp:4723
emit_ssaval_assign at /cygdrive/c/buildbot/worker/package_win64/build/src\codegen.cpp:4310
emit_stmtpos at /cygdrive/c/buildbot/worker/package_win64/build/src\codegen.cpp:4557 [inlined]
emit_function at /cygdrive/c/buildbot/worker/package_win64/build/src\codegen.cpp:7387
jl_emit_code at /cygdrive/c/buildbot/worker/package_win64/build/src\codegen.cpp:7722
jl_emit_codeinst at /cygdrive/c/buildbot/worker/package_win64/build/src\codegen.cpp:7767
_jl_compile_codeinst at /cygdrive/c/buildbot/worker/package_win64/build/src\jitlayers.cpp:119
jl_generate_fptr_impl at /cygdrive/c/buildbot/worker/package_win64/build/src\jitlayers.cpp:332
jl_compile_method_internal at /cygdrive/c/buildbot/worker/package_win64/build/src\gf.c:2081
jl_compile_method_internal at /cygdrive/c/buildbot/worker/package_win64/build/src\gf.c:2028 [inlined]
_jl_invoke at /cygdrive/c/buildbot/worker/package_win64/build/src\gf.c:2359 [inlined]
ijl_apply_generic at /cygdrive/c/buildbot/worker/package_win64/build/src\gf.c:2549
decode_image at d:\D_Drive_HP\ImageIO\libraw\librawtest.jl:5
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1839 [inlined]
do_call at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:126
eval_value at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:215
eval_stmt_value at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:166 [inlined]
eval_body at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:594
jl_interpret_toplevel_thunk at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:750
top-level scope at d:\D_Drive_HP\ImageIO\libraw\librawtest.jl:17
jl_toplevel_eval_flex at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:906
jl_toplevel_eval_flex at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:850
ijl_toplevel_eval at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:915 [inlined]
ijl_toplevel_eval_in at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:965
eval at .\boot.jl:368 [inlined]
include_string at .\loading.jl:1428
include_string at .\loading.jl:1438
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1839 [inlined]
jl_f__call_latest at /cygdrive/c/buildbot/worker/package_win64/build/src\builtins.c:774
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1839 [inlined]
do_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\builtins.c:730
#invokelatest#2 at .\essentials.jl:729
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1839 [inlined]
do_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\builtins.c:730
invokelatest at .\essentials.jl:726
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1839 [inlined]
do_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\builtins.c:730
#inlineeval#71 at c:\Users\Aditi Dey\.vscode\extensions\julialang.language-julia-1.38.2\scripts\packages\VSCodeServer\src\eval.jl:233
inlineeval##kw at c:\Users\Aditi Dey\.vscode\extensions\julialang.language-julia-1.38.2\scripts\packages\VSCodeServer\src\eval.jl:230 [inlined]
#66 at c:\Users\Aditi Dey\.vscode\extensions\julialang.language-julia-1.38.2\scripts\packages\VSCodeServer\src\eval.jl:157
withpath at c:\Users\Aditi Dey\.vscode\extensions\julialang.language-julia-1.38.2\scripts\packages\VSCodeServer\src\repl.jl:249
#65 at c:\Users\Aditi Dey\.vscode\extensions\julialang.language-julia-1.38.2\scripts\packages\VSCodeServer\src\eval.jl:155
hideprompt at c:\Users\Aditi Dey\.vscode\extensions\julialang.language-julia-1.38.2\scripts\packages\VSCodeServer\src\repl.jl:38
#64 at c:\Users\Aditi Dey\.vscode\extensions\julialang.language-julia-1.38.2\scripts\packages\VSCodeServer\src\eval.jl:126
unknown function (ip: 000000005a887083)
with_logstate at .\logging.jl:511
with_logger at .\logging.jl:623 [inlined]
#63 at c:\Users\Aditi Dey\.vscode\extensions\julialang.language-julia-1.38.2\scripts\packages\VSCodeServer\src\eval.jl:225
unknown function (ip: 000000005a885553)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1839 [inlined]
jl_f__call_latest at /cygdrive/c/buildbot/worker/package_win64/build/src\builtins.c:774
#invokelatest#2 at .\essentials.jl:729 [inlined]
invokelatest at .\essentials.jl:726
unknown function (ip: 000000005a87d9c6)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1839 [inlined]
do_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\builtins.c:730
macro expansion at c:\Users\Aditi Dey\.vscode\extensions\julialang.language-julia-1.38.2\scripts\packages\VSCodeServer\src\eval.jl:34 [inlined]
#61 at .\task.jl:484
unknown function (ip: 000000005a864cf3)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1839 [inlined]
start_task at /cygdrive/c/buildbot/worker/package_win64/build/src\task.c:931
Internal error: encountered unexpected error during compilation of libraw_init:
TypeError(func=:ccall, context="", expected=Symbol, got=LibRaw)
ijl_type_error_rt at /cygdrive/c/buildbot/worker/package_win64/build/src\rtutils.c:119
ijl_type_error at /cygdrive/c/buildbot/worker/package_win64/build/src\rtutils.c:127
interpret_symbol_arg at /cygdrive/c/buildbot/worker/package_win64/build/src\ccall.cpp:611
emit_ccall at /cygdrive/c/buildbot/worker/package_win64/build/src\ccall.cpp:1280
emit_expr at /cygdrive/c/buildbot/worker/package_win64/build/src\codegen.cpp:4723
emit_ssaval_assign at /cygdrive/c/buildbot/worker/package_win64/build/src\codegen.cpp:4310
emit_stmtpos at /cygdrive/c/buildbot/worker/package_win64/build/src\codegen.cpp:4557 [inlined]
emit_function at /cygdrive/c/buildbot/worker/package_win64/build/src\codegen.cpp:7387
jl_emit_code at /cygdrive/c/buildbot/worker/package_win64/build/src\codegen.cpp:7722
jl_emit_codeinst at /cygdrive/c/buildbot/worker/package_win64/build/src\codegen.cpp:7767
_jl_compile_codeinst at /cygdrive/c/buildbot/worker/package_win64/build/src\jitlayers.cpp:119
jl_generate_fptr_for_unspecialized_impl at /cygdrive/c/buildbot/worker/package_win64/build/src\jitlayers.cpp:380
jl_compile_method_internal at /cygdrive/c/buildbot/worker/package_win64/build/src\gf.c:2094
jl_compile_method_internal at /cygdrive/c/buildbot/worker/package_win64/build/src\gf.c:2028 [inlined]
_jl_invoke at /cygdrive/c/buildbot/worker/package_win64/build/src\gf.c:2359 [inlined]
ijl_apply_generic at /cygdrive/c/buildbot/worker/package_win64/build/src\gf.c:2549
decode_image at d:\D_Drive_HP\ImageIO\libraw\librawtest.jl:5
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1839 [inlined]
do_call at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:126
eval_value at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:215
eval_stmt_value at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:166 [inlined]
eval_body at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:594
jl_interpret_toplevel_thunk at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:750
top-level scope at d:\D_Drive_HP\ImageIO\libraw\librawtest.jl:17
jl_toplevel_eval_flex at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:906
jl_toplevel_eval_flex at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:850
ijl_toplevel_eval at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:915 [inlined]
ijl_toplevel_eval_in at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:965
eval at .\boot.jl:368 [inlined]
include_string at .\loading.jl:1428
include_string at .\loading.jl:1438
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1839 [inlined]
jl_f__call_latest at /cygdrive/c/buildbot/worker/package_win64/build/src\builtins.c:774
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1839 [inlined]
do_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\builtins.c:730
#invokelatest#2 at .\essentials.jl:729
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1839 [inlined]
do_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\builtins.c:730
invokelatest at .\essentials.jl:726
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1839 [inlined]
do_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\builtins.c:730
#inlineeval#71 at c:\Users\Aditi Dey\.vscode\extensions\julialang.language-julia-1.38.2\scripts\packages\VSCodeServer\src\eval.jl:233
inlineeval##kw at c:\Users\Aditi Dey\.vscode\extensions\julialang.language-julia-1.38.2\scripts\packages\VSCodeServer\src\eval.jl:230 [inlined]
#66 at c:\Users\Aditi Dey\.vscode\extensions\julialang.language-julia-1.38.2\scripts\packages\VSCodeServer\src\eval.jl:157
withpath at c:\Users\Aditi Dey\.vscode\extensions\julialang.language-julia-1.38.2\scripts\packages\VSCodeServer\src\repl.jl:249
#65 at c:\Users\Aditi Dey\.vscode\extensions\julialang.language-julia-1.38.2\scripts\packages\VSCodeServer\src\eval.jl:155
hideprompt at c:\Users\Aditi Dey\.vscode\extensions\julialang.language-julia-1.38.2\scripts\packages\VSCodeServer\src\repl.jl:38
#64 at c:\Users\Aditi Dey\.vscode\extensions\julialang.language-julia-1.38.2\scripts\packages\VSCodeServer\src\eval.jl:126
unknown function (ip: 000000005a887083)
with_logstate at .\logging.jl:511
with_logger at .\logging.jl:623 [inlined]
#63 at c:\Users\Aditi Dey\.vscode\extensions\julialang.language-julia-1.38.2\scripts\packages\VSCodeServer\src\eval.jl:225
unknown function (ip: 000000005a885553)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1839 [inlined]
jl_f__call_latest at /cygdrive/c/buildbot/worker/package_win64/build/src\builtins.c:774
#invokelatest#2 at .\essentials.jl:729 [inlined]
invokelatest at .\essentials.jl:726
unknown function (ip: 000000005a87d9c6)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1839 [inlined]
do_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\builtins.c:730
macro expansion at c:\Users\Aditi Dey\.vscode\extensions\julialang.language-julia-1.38.2\scripts\packages\VSCodeServer\src\eval.jl:34 [inlined]
#61 at .\task.jl:484
unknown function (ip: 000000005a864cf3)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1839 [inlined]
start_task at /cygdrive/c/buildbot/worker/package_win64/build/src\task.c:931
ERROR: `ccall` requires the compiler
Stacktrace:
[1] libraw_init(flags::Int64)
@ Main.LibRaw d:\D_Drive_HP\ImageIO\libraw\lib\LibRaw.jl:737
[2] decode_image(filename::AbstractString)
@ Main d:\D_Drive_HP\ImageIO\libraw\librawtest.jl:5
[3] top-level scope
@ d:\D_Drive_HP\ImageIO\libraw\librawtest.jl:17
I have Julia installed in my windows system and added to path. I’m using VS Code, and on running the test code, the code automatically runs in the Julia REPL. Hence I’m not able to understand what is going wrong. Can anyone please help?