# Call C++ dll used Cxx.jl on windows

**URL:** https://discourse.julialang.org/t/call-c-dll-used-cxx-jl-on-windows/60766
**Category:** General Usage
**Tags:** question, cxx
**Created:** [May 8, 2021, 8:46am UTC](https://discourse.julialang.org/t/call-c-dll-used-cxx-jl-on-windows/60766 "2021-05-08T08:46:41Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![wgst1024](https://avatars.discourse-cdn.com/v4/letter/w/a88e4f/32.png) [@wgst1024](https://discourse.julialang.org/u/wgst1024)
#### Post date: [May 8, 2021, 8:46am UTC](https://discourse.julialang.org/t/call-c-dll-used-cxx-jl-on-windows/60766/1 "2021-05-08T08:46:41Z")

</div>

Refer to official documents Example 8: Using C++ with shared libraries，the example is on linux，but I want to test on windows.  
[https://github.com/JuliaInterop/Cxx.jl](https://github.com/JuliaInterop/Cxx.jl)

**JuliaDll.h**

> #ifndef ARRAYMAKER\_H  
> #define ARRAYMAKER\_H
> 
> class \_\_declspec(dllexport) ArrayMaker  
> {  
> private:  
> int iNumber;  
> float fNumber;  
> float\* fArr;  
> public:  
> ArrayMaker(int, float);  
> float\* fillArr();  
> };
> 
> extern “C” \_\_declspec(dllexport) double GetSum(double x, double y);
> 
> #endif

**JuliaDll.cpp**

> #include “JuliaDll.h”  
> #include
> 
> using namespace std;
> 
> ArrayMaker::ArrayMaker(int iNum, float fNum) {  
> cout \<\< "Got arguments: " \<\< iNum \<\< ", and " \<\< fNum \<\< endl;  
> iNumber = iNum;  
> fNumber = fNum;  
> fArr = new float[iNumber];  
> }
> 
> float\* ArrayMaker::fillArr() {  
> cout \<\< “Filling the array” \<\< endl;  
> for (int i=0; i \< iNumber; i++) {  
> fArr[i] = fNumber;  
> fNumber \*= 2;  
> }  
> return fArr;  
> }
> 
> double GetSum(double x, double y)  
> {  
> return x + y;  
> }

Refer to that example

> julia\> const path\_to\_lib = pwd()  
> addHeaderDir(path\_to\_lib, kind=C\_System)  
> Libdl.dlopen(joinpath(path\_to\_lib, “JuliaDll.dll”), Libdl.RTLD\_GLOBAL)  
> cxxinclude(joinpath(path\_to\_lib, “JuliaDll.h”))

This function is right

> julia\> a = @cxx GetSum(1,2)  
> 3.0

Copy the example’s code report an error

> julia\> maker = @cxxnew ArrayMaker(5, 2.0)  
> LLVM ERROR: Program used external function ‘\_ZN10ArrayMakerC1Eif’ which could not be resolved!
