Hello again,
After following the above mentioned instructions of Jeff managed to make
Cxx working properly in the julia version
installed via (make install), yet again the original problem persists.
Just to remind you:
I have the following c++ class:
1) cpp.file:
#include "ArrayMaker.h"
#include <iostream>
using namespace std;
ArrayMaker::ArrayMaker() {
// TODO Auto-generated constructor stub
}
ArrayMaker::~ArrayMaker() {
// TODO Auto-generated destructor stub
}
double ArrayMaker::ArrayMak(int iNum, float fNum) {
jl_init(JULIA_INIT_DIR);
jl_load("/home/kostav/.julia/v0.4/loleee/src/loleee.jl");
jl_value_t * mod = (jl_value_t*)jl_eval_string("loleee");
jl_function_t * func =
jl_get_function((jl_module_t*)mod,"funior");
jl_value_t * argument = jl_box_float64(2.0);
jl_value_t * argument2 = jl_box_float64(3.0);
jl_value_t * ret = jl_call2(func, argument, argument2);
sol = jl_unbox_float64(ret);
jl_atexit_hook();
return sol;
}
}
2) header file:
#ifndef ARRAYMAKER_H
#define ARRAYMAKER_H
#include <julia.h>
class ArrayMaker
{
public:
ArrayMaker();
virtual ~ArrayMaker();
double ArrayMak(int, float);
};
#endif
Which are called isnide this small julia file:
using Cxx
# Importing shared library and header file
const path_to_lib = "/home/kostav/Documents/Project/julia/cle"
addHeaderDir(path_to_lib, kind=C_System)
Libdl.dlopen(path_to_lib * "/test.so", Libdl.RTLD_GLOBAL)
cxxinclude("ArrayMaker.h")
maker = @cxxnew ArrayMaker()
a = @cxx maker->ArrayMak(5, 2.0)
println("return value is: ", a)
As described above what I am trying is to call the c++ function ArrayMak
from julia file,
where inside this function I call an other julia function (called name
"funior") that just receives
two numbers as arguments and returns their sum.
More or less want to verify that I can have the following process:
Julia file -> Calling C++ classes -> calling inside them other julia
functions -> returning arguments from the C++ classes to the original julia
file.
So when I run the julia file everything works until the moment that the c++
function needs to return the argument to julia file, I have checked
and confirmed that until that point everything works proprely:
1) C++ function ArrayMak is called
2) Function funior is receiving the arguments properly and returns to the
variable sol the sum of the two arguments
But when the value of sol needs to be returned to the julia function
everythins stucks.
Judging from the example in the cxx web-site in order to return arguments
from c++ functions to julia you don't need to do anything complicated
or different from what is shown here:
arr = @cxx maker->fillArr() (where fillArr is supposed to return an array)
So, I am not sure what is going wrong here...
On Wednesday, July 22, 2015 at 9:33:00 AM UTC+2, Kostas
Tavlaridis-Gyparakis wrote:
>
> Any help/further suggestions please?
>
> On Tuesday, July 21, 2015 at 3:27:10 PM UTC+2, Kostas Tavlaridis-Gyparakis
> wrote:
>>
>> Hello again,
>> Unfortunately and let me apologize in advance I still find myself
>> confused on how to make things
>> work properly.
>>
>>> Here are the symbolic links. I believe with some simple changes to Cxx,
>>> the need for these
>>> will disappear, but for now there's where it searches.
>>>
>>> /usr/local/julia/lib
>>>
>>> bizarro% ls -l
>>>
>>> total 16
>>>
>>> drwxr-xr-x 4 jeffw staff 136 Jul 18 18:26 clang
>>>
>>> lrwxr-xr-x 1 root staff 10 Jul 19 03:16 include -> ../include
>>>
>>> drwxr-xr-x 49 jeffw staff 1666 Jul 18 20:11 julia
>>>
>>> lrwxr-xr-x 1 root staff 1 Jul 19 03:16 lib -> .
>>>
>>
>> If I get this right does it mean that for all the files that are included
>> in the list " * DirectoryLayout*
>> <https://gist.github.com/waTeim/ec622a0630f220e6b3c3#file-directorylayout>
>> "
>> I need to create a soft link to link them with the directory
>> "/usr/local/julia/lib" (which doesn't exist
>> in my system)?
>> Aslo regarding the instructions of part "*BuildJuliaLLVMforCXX*
>> <https://gist.github.com/waTeim/ec622a0630f220e6b3c3#file-buildjuliallvmforcxx>"
>>
>> where you present the files that
>> need to be cp to the directory julia-f428392003 in my system I face the
>> following problems:
>>
>> 1) The image files (sys.ji, sys.dylib,sys-debug.dylib) don't exist
>> anywhere in my system
>> 2) The folder llvm-svn (in the source julia directory) has completely
>> different structure in my system,
>> In my julia (source code) folder there are two folders with the name
>> llvm-svn the one has a structure
>> that you can look in the attach picture called name (llvmsn), while the
>> second one is located in the
>> path "/home/kostav/julia/usr-staging/llvm-svn" and has a single folder
>> named "build_Release+Asserts".
>>
>> All in all I am confused on how to follow your instructions (for which I
>> do really appreciate the effort you
>> put to provide me with). Is what I have to do:
>>
>> 1) Try to copy paste the folders as presented in "*BuildJuliaLLVMforCXX*
>> <https://gist.github.com/waTeim/ec622a0630f220e6b3c3#file-buildjuliallvmforcxx>
>> "?
>> 2) Create links for all the files listed * "DirectoryLayout" *
>> <https://gist.github.com/waTeim/ec622a0630f220e6b3c3#file-directorylayout>towards
>>
>> the folder "/usr/local/julia/lib"?
>>
>>
>> On Sunday, July 19, 2015 at 10:44:07 PM UTC+2, Jeff Waller wrote:
>>>
>>>
>>>> Symbolic links to link which files though?
>>>> Sorry if the questions I raise are already answered by the git, I just
>>>> failed to understand it properly so that's
>>>> why I come back with these questions now.
>>>>
>>>>
>>>
>>> I've added a listing of the entire directory structure
>>> <https://gist.github.com/waTeim/ec622a0630f220e6b3c3#file-directorylayout>
>>>
>>>
>>> Here are the symbolic links. I believe with some simple changes to Cxx,
>>> the need for these
>>> will disappear, but for now there's where it searches.
>>>
>>> /usr/local/julia/lib
>>>
>>> bizarro% ls -l
>>>
>>> total 16
>>>
>>> drwxr-xr-x 4 jeffw staff 136 Jul 18 18:26 clang
>>>
>>> lrwxr-xr-x 1 root staff 10 Jul 19 03:16 include -> ../include
>>>
>>> drwxr-xr-x 49 jeffw staff 1666 Jul 18 20:11 julia
>>>
>>> lrwxr-xr-x 1 root staff 1 Jul 19 03:16 lib -> .
>>>
>>