# \#cxxwrap

**URL:** https://discourse.julialang.org/tag/cxxwrap/780.md

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

---

## [High memory usage when creating lots of temporary C++ objects](https://discourse.julialang.org/t/high-memory-usage-when-creating-lots-of-temporary-c-objects/135399)

<div class="topic-metadata">

**Author:** [@Vasily\_Pisarev](https://discourse.julialang.org/u/Vasily_Pisarev)\
**Replies:** 9\
**Last updated:** [February 3, 2026, 3:51pm UTC](https://discourse.julialang.org/t/high-memory-usage-when-creating-lots-of-temporary-c-objects/135399 "2026-02-03T15:51:45Z")

</div>

I found out that creating lots of temporary C++ objects through CxxWrap takes a lot of memory (duh!) and does not return that memory to the system after GC. My use case is this package wrapping Voro++ library. Logically…

---

## [How to distribute a wrapper for a C++ library?](https://discourse.julialang.org/t/how-to-distribute-a-wrapper-for-a-c-library/130581)

<div class="topic-metadata">

**Author:** [@Vasily\_Pisarev](https://discourse.julialang.org/u/Vasily_Pisarev)\
**Replies:** 9\
**Last updated:** [December 10, 2025, 8:42pm UTC](https://discourse.julialang.org/t/how-to-distribute-a-wrapper-for-a-c-library/130581 "2025-12-10T20:42:44Z")

</div>

Could anyone share experience on how to distribute a C++ wrapper through package manager? My workflow idea is the following: package is available from a third-party registry wrapped library and C++ shim are packaged i…

---

## [Dynamic Type in CxxWrap.jl](https://discourse.julialang.org/t/dynamic-type-in-cxxwrap-jl/133007)

<div class="topic-metadata">

**Author:** [@phK3](https://discourse.julialang.org/u/phK3)\
**Replies:** 1\
**Last updated:** [October 20, 2025, 9:56am UTC](https://discourse.julialang.org/t/dynamic-type-in-cxxwrap-jl/133007 "2025-10-20T09:56:31Z")

</div>

I want to use CxxWrap.jl to create a Julia wrapper for a C++ library. On the Julia side, I want to dispatch on the type of my arguments. But when using CxxWrap, the Julia side only seems to know about the static return…

---

## [Passing an array of tuples to CxxWrap](https://discourse.julialang.org/t/passing-an-array-of-tuples-to-cxxwrap/125392)

<div class="topic-metadata">

**Author:** [@nabla](https://discourse.julialang.org/u/nabla)\
**Replies:** 0\
**Last updated:** [January 30, 2025, 1:49pm UTC](https://discourse.julialang.org/t/passing-an-array-of-tuples-to-cxxwrap/125392 "2025-01-30T13:49:32Z")

</div>

I’d love to pass an array of tuples to some C++ code; say calling myfunction(\[("a",1),("b",2)\]) At the C++ level, I would write a function mod.method("myfunction", \[\](const jlcxx::ArrayRef\<std::tuple\<std::string,int\>\> …

---

## [Add type's method to Base](https://discourse.julialang.org/t/add-types-method-to-base/123529)

<div class="topic-metadata">

**Author:** [@nabla](https://discourse.julialang.org/u/nabla)\
**Replies:** 2\
**Last updated:** [December 6, 2024, 11:18am UTC](https://discourse.julialang.org/t/add-types-method-to-base/123529 "2024-12-06T11:18:08Z")

</div>

I want to add a method directly to Base (it’s a basic operation :(!)). I’m aware of set\_override\_module(jl\_base\_module) and unset\_override\_module(). However, I want to define a method for an object myclass, and the foll…

---

## [Julia incorrect with function argument](https://discourse.julialang.org/t/julia-incorrect-with-function-argument/123520)

<div class="topic-metadata">

**Author:** [@Sergey](https://discourse.julialang.org/u/Sergey)\
**Replies:** 1\
**Last updated:** [December 6, 2024, 12:33am UTC](https://discourse.julialang.org/t/julia-incorrect-with-function-argument/123520 "2024-12-06T00:33:47Z")

</div>

Hi! Please help me to understand whats wrong with julia logic. The following code print out: println(typeof(section)) \>\> CxxWrap.CxxWrapCore.CxxPtr{Main.CppTypes.ISection} I wish to write function which take this (an…

---

## [@cfunction with CxxWrap arguments](https://discourse.julialang.org/t/cfunction-with-cxxwrap-arguments/123473)

<div class="topic-metadata">

**Author:** [@Sergey](https://discourse.julialang.org/u/Sergey)\
**Replies:** 1\
**Last updated:** [December 5, 2024, 9:31am UTC](https://discourse.julialang.org/t/cfunction-with-cxxwrap-arguments/123473 "2024-12-05T09:31:14Z")

</div>

Hi! Is it possible to get pointer by @function if this function argument is CxxWrap binded struct? Class binding types.add\_type\<DataBase\>("Database") .method("GetProperty", &DataBase::getProperty); and julia funct…

---

## [How to wrap C++ function writing to FILE\*?](https://discourse.julialang.org/t/how-to-wrap-c-function-writing-to-file/122945)

<div class="topic-metadata">

**Author:** [@Vasily\_Pisarev](https://discourse.julialang.org/u/Vasily_Pisarev)\
**Replies:** 1\
**Last updated:** [November 22, 2024, 9:11pm UTC](https://discourse.julialang.org/t/how-to-wrap-c-function-writing-to-file/122945 "2024-11-22T21:11:53Z")

</div>

I want to wrap a C++ function writing to a file stream to be able to print to a file or to stdout (eventually I’d like to try if redirect\_stdout would work to make it print to a custom buffer). However, CxxWrap does not …

---

## [CxxWrap module rely on external dll](https://discourse.julialang.org/t/cxxwrap-module-rely-on-external-dll/122917)

<div class="topic-metadata">

**Author:** [@Sergey](https://discourse.julialang.org/u/Sergey)\
**Replies:** 1\
**Last updated:** [November 22, 2024, 9:33am UTC](https://discourse.julialang.org/t/cxxwrap-module-rely-on-external-dll/122917 "2024-11-22T09:33:16Z")

</div>

Hi. Is it possible to develop CxxWrap module which depend on dll lib? Since we directly load dll in jl file and one dll cant load another. module CppTypes using CxxWrap @wrapmodule(() -\> "libcore.dll", :define…

---

## [Binding non-trivial C++ examples using CxxWrap.jl](https://discourse.julialang.org/t/binding-non-trivial-c-examples-using-cxxwrap-jl/119228)

<div class="topic-metadata">

**Author:** [@bthorne93](https://discourse.julialang.org/u/bthorne93)\
**Replies:** 0\
**Last updated:** [September 9, 2024, 9:31pm UTC](https://discourse.julialang.org/t/binding-non-trivial-c-examples-using-cxxwrap-jl/119228 "2024-09-09T21:31:56Z")

</div>

I am trying to write Julia bindings for a C++ library with types that depend on other types. It is unclear from the CxxWrap.jl docs or examples how to deal with this case. An example of the interdependent C++ structs are…

---

## [Use CxxWrap with embedded julia without shared lib](https://discourse.julialang.org/t/use-cxxwrap-with-embedded-julia-without-shared-lib/119159)

<div class="topic-metadata">

**Author:** [@Sergey](https://discourse.julialang.org/u/Sergey)\
**Replies:** 4\
**Last updated:** [September 7, 2024, 7:43pm UTC](https://discourse.julialang.org/t/use-cxxwrap-with-embedded-julia-without-shared-lib/119159 "2024-09-07T19:43:34Z")

</div>

From example i saw that cxxwrap define some module like this int greet() { return 12; } void define\_julia\_module(jlcxx::Module& mod) { mod.method("greet", &greet); } We could create jlcxx::Module ++ several w…

---

## [Pass vectors by reference using CxxWrap.@safe\_cfunction](https://discourse.julialang.org/t/pass-vectors-by-reference-using-cxxwrap-safe-cfunction/117350)

<div class="topic-metadata">

**Author:** [@afossa](https://discourse.julialang.org/u/afossa)\
**Replies:** 6\
**Last updated:** [July 23, 2024, 7:51pm UTC](https://discourse.julialang.org/t/pass-vectors-by-reference-using-cxxwrap-safe-cfunction/117350 "2024-07-23T19:51:37Z")

</div>

Hello, I have a Julia function like function f(x::AbstractVector{Float64}, y::AbstractVector{Float64}) y\[1\] = 2.0\*x\[1\]; y\[2\] = 2.0\*x\[2\]; return nothing; end; which takes in input two arrays of Float64 and …

---

## [Can someone provide a simple example of using CxxWrap?](https://discourse.julialang.org/t/can-someone-provide-a-simple-example-of-using-cxxwrap/115908)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 7\
**Last updated:** [June 21, 2024, 2:44pm UTC](https://discourse.julialang.org/t/can-someone-provide-a-simple-example-of-using-cxxwrap/115908 "2024-06-21T14:44:27Z")

</div>

Hello, I am trying to look at CxxWrap as the super-easy Cxx.jl package seems lost :-((((( However, as my usage of CMAKE is very limited, I am unable to follow even the example in the home page (and there is no separate …

---

## [Two ways to get C++ interface class from C API](https://discourse.julialang.org/t/two-ways-to-get-c-interface-class-from-c-api/112522)

<div class="topic-metadata">

**Author:** [@sairus7](https://discourse.julialang.org/u/sairus7)\
**Replies:** 0\
**Last updated:** [April 4, 2024, 1:41pm UTC](https://discourse.julialang.org/t/two-ways-to-get-c-interface-class-from-c-api/112522 "2024-04-04T13:41:09Z")

</div>

Consider simple C++ interface class: ▶ File \`shape.h\` Since Cxx.jl in obsolete, so you cannot generate julia types from C++, and CxxWrap.jl means you have to make changes on C++ side, so I’ve made two C library wrappers …

---

## [\`munmap\_chunk(): invalid pointer\` when wrapping a C++ package](https://discourse.julialang.org/t/munmap-chunk-invalid-pointer-when-wrapping-a-c-package/109205)

<div class="topic-metadata">

**Author:** [@biona001](https://discourse.julialang.org/u/biona001)\
**Replies:** 1\
**Last updated:** [January 26, 2024, 5:00am UTC](https://discourse.julialang.org/t/munmap-chunk-invalid-pointer-when-wrapping-a-c-package/109205 "2024-01-26T05:00:48Z")

</div>

Hello community, I’ve been trying to wrap a C++ package using CxxWrap.jl. My wrapper code and CMakeList.txt are available here, and they seem to work locally. Then, using this build\_tarballs.jl I created a jll package g…

---

## [Line number info missing when Windows DLL gets EXCEPTION\_ACCESS\_VIOLATION](https://discourse.julialang.org/t/line-number-info-missing-when-windows-dll-gets-exception-access-violation/108353)

<div class="topic-metadata">

**Author:** [@Kirby\_Zhang](https://discourse.julialang.org/u/Kirby_Zhang)\
**Replies:** 2\
**Last updated:** [January 4, 2024, 6:32pm UTC](https://discourse.julialang.org/t/line-number-info-missing-when-windows-dll-gets-exception-access-violation/108353 "2024-01-04T18:32:53Z")

</div>

The DLL was compiled using MSVC toolchain with debug configuration. A .pdb file was generated alongside the .dll file. But it seems line number information is not being made available to Julia’s access violation handler: …

---

## [CxxWrap How to handle Array of Array](https://discourse.julialang.org/t/cxxwrap-how-to-handle-array-of-array/107498)

<div class="topic-metadata">

**Author:** [@kemu](https://discourse.julialang.org/u/kemu)\
**Replies:** 0\
**Last updated:** [December 12, 2023, 1:10pm UTC](https://discourse.julialang.org/t/cxxwrap-how-to-handle-array-of-array/107498 "2023-12-12T13:10:07Z")

</div>

I am using CxxWrap to create a simple wrapper for OpenCV. cv::decomposeHomographyMat() takes std::vector\<cv::Mat\> as an argument, how can I wrap this? I tried jlcxx::ArrayRef\<jlcxx::ArrayRef\<double, 2\>, 1\> but I get st…

---

## [Auto cxxwrap generator like autopybind11](https://discourse.julialang.org/t/auto-cxxwrap-generator-like-autopybind11/102225)

<div class="topic-metadata">

**Author:** [@xgdgsc](https://discourse.julialang.org/u/xgdgsc)\
**Replies:** 3\
**Last updated:** [July 29, 2023, 6:21pm UTC](https://discourse.julialang.org/t/auto-cxxwrap-generator-like-autopybind11/102225 "2023-07-29T18:21:51Z")

</div>

Is there something like autopybind11 / autopybind11 · GitLab where you define a simple config file and it generates all the code needed for wrapping for you?

---

## [Wrapping of large C++ libraries](https://discourse.julialang.org/t/wrapping-of-large-c-libraries/100114)

<div class="topic-metadata">

**Author:** [@fran94](https://discourse.julialang.org/u/fran94)\
**Replies:** 5\
**Last updated:** [June 9, 2023, 8:36pm UTC](https://discourse.julialang.org/t/wrapping-of-large-c-libraries/100114 "2023-06-09T20:36:30Z")

</div>

Hi, I have seen several packages aiming at wrapping C++ code to use in Julia, such as CxxWrap.jl. I haven’t seen a lot of resources about wrapping large pre-existing C++ libraries. I’m thinking about something of the si…

---

## [CxxWrap and finalizers for specific instances](https://discourse.julialang.org/t/cxxwrap-and-finalizers-for-specific-instances/96254)

<div class="topic-metadata">

**Author:** [@peremato](https://discourse.julialang.org/u/peremato)\
**Replies:** 0\
**Last updated:** [March 17, 2023, 5:06pm UTC](https://discourse.julialang.org/t/cxxwrap-and-finalizers-for-specific-instances/96254 "2023-03-17T17:06:02Z")

</div>

I am using CxxWrap.jl and need to relinquish ownership for some particular instances, but not all, which is transferred to some other objects. CxxWrap has the possibility to disable the finalizer by adding the argument f…

---

## [How to force a precompilation of a CxxWrap package](https://discourse.julialang.org/t/how-to-force-a-precompilation-of-a-cxxwrap-package/95332)

<div class="topic-metadata">

**Author:** [@peremato](https://discourse.julialang.org/u/peremato)\
**Replies:** 0\
**Last updated:** [February 28, 2023, 1:42pm UTC](https://discourse.julialang.org/t/how-to-force-a-precompilation-of-a-cxxwrap-package/95332 "2023-02-28T13:42:10Z")

</div>

I am using CxxWrap to generate bindings for a C++ package, for which I create a wrapper dynamic library that is loaded in the julia module file with @wrapmodule(\<library\>). The problem is that re-creating the wrapper lib…

---

## [Pass by reference of map typed struct(CxxWrap.jl)](https://discourse.julialang.org/t/pass-by-reference-of-map-typed-struct-cxxwrap-jl/82545)

<div class="topic-metadata">

**Author:** [@kemu](https://discourse.julialang.org/u/kemu)\
**Replies:** 1\
**Last updated:** [February 17, 2023, 6:50pm UTC](https://discourse.julialang.org/t/pass-by-reference-of-map-typed-struct-cxxwrap-jl/82545 "2023-02-17T18:50:09Z")

</div>

pass by reference of map typed struct(CxxWrap.jl) Hi, I’m trying to pass the argument by reference from Julia to C++. This argument is simple struct, so I used map\_type at wrap module difinition. I am having trouble …

---

## [With CxxWrap, method cannot return an usable complex number](https://discourse.julialang.org/t/with-cxxwrap-method-cannot-return-an-usable-complex-number/94801)

<div class="topic-metadata">

**Author:** [@gdmsl](https://discourse.julialang.org/u/gdmsl)\
**Replies:** 0\
**Last updated:** [February 17, 2023, 5:57pm UTC](https://discourse.julialang.org/t/with-cxxwrap-method-cannot-return-an-usable-complex-number/94801 "2023-02-17T17:57:42Z")

</div>

Hi, I am trying to use CxxWrap to wrap a C++ library. I am wrapping a type that has a method that returns a std::complex. I have also wrapped the std::complex type, since it is not already in the CxxWrap library. The p…

---

## [Wrapping C++ struct with libcxxwrap-julia](https://discourse.julialang.org/t/wrapping-c-struct-with-libcxxwrap-julia/92795)

<div class="topic-metadata">

**Author:** [@sunayana](https://discourse.julialang.org/u/sunayana)\
**Replies:** 1\
**Last updated:** [January 20, 2023, 8:03am UTC](https://discourse.julialang.org/t/wrapping-c-struct-with-libcxxwrap-julia/92795 "2023-01-20T08:03:30Z")

</div>

Hello, I need some help with wrapping a C++ template struct (from richdem C++ library) into Julia such that it is seamlessly available in Julia to check values of and set values to. This is what I have so far: The tem…

---

## [Ccall c++ sort vector of String](https://discourse.julialang.org/t/ccall-c-sort-vector-of-string/74635)

<div class="topic-metadata">

**Author:** [@gitboy16](https://discourse.julialang.org/u/gitboy16)\
**Replies:** 36\
**Last updated:** [December 19, 2022, 9:58pm UTC](https://discourse.julialang.org/t/ccall-c-sort-vector-of-string/74635 "2022-12-19T21:58:29Z")

</div>

Hi, Would someone be able to provide an example on how to : 1/ pass a vector of strings to ccall 2/ sort the vector of strings using c++ std::sort 3/ get the sorted string vector back in Julia Thank you

---

## [CxxWrap can't find .dylib on MacOS](https://discourse.julialang.org/t/cxxwrap-cant-find-dylib-on-macos/86997)

<div class="topic-metadata">

**Author:** [@danny.s](https://discourse.julialang.org/u/danny.s)\
**Replies:** 3\
**Last updated:** [September 12, 2022, 2:41pm UTC](https://discourse.julialang.org/t/cxxwrap-cant-find-dylib-on-macos/86997 "2022-09-12T14:41:53Z")

</div>

I’m working on a C++ package (called MParT) for MacOS and Linux, as well as creating bindings to it in Julia. So far, I’ve had moderate success, where I can use Linux to \]add https://github.com/MeasureTransport/MParT.jl …

---

## [CxxWrap and IO and iostream](https://discourse.julialang.org/t/cxxwrap-and-io-and-iostream/87116)

<div class="topic-metadata">

**Author:** [@nabla](https://discourse.julialang.org/u/nabla)\
**Replies:** 0\
**Last updated:** [September 12, 2022, 7:54am UTC](https://discourse.julialang.org/t/cxxwrap-and-io-and-iostream/87116 "2022-09-12T07:54:22Z")

</div>

I love CxxWrap, but I can’t find anywhere in the tutorials or documentation how to wrap a read/write C++ method into Julia. More specifically: the C++ code I want to wrap has an object X with methods X.write(ostream &s) …

---

## [CxxWrap cannot wrap structure on dev. version of Julia?](https://discourse.julialang.org/t/cxxwrap-cannot-wrap-structure-on-dev-version-of-julia/86423)

<div class="topic-metadata">

**Author:** [@nabla](https://discourse.julialang.org/u/nabla)\
**Replies:** 1\
**Last updated:** [August 27, 2022, 10:21am UTC](https://discourse.julialang.org/t/cxxwrap-cannot-wrap-structure-on-dev-version-of-julia/86423 "2022-08-27T10:21:07Z")

</div>

I built, and tried to run, CxxWrap with the latest (github) version of Julia, Version 1.9.0-DEV.1189 (2022-08-26). I could build the example “testlib.cpp”, but ran into two problems: the structure doesn’t seem to be wr…

---

## [InitError: could not load library "...libcxxwrap\_julia\_stl.dll" on windows](https://discourse.julialang.org/t/initerror-could-not-load-library-libcxxwrap-julia-stl-dll-on-windows/74535)

<div class="topic-metadata">

**Author:** [@hiemstar](https://discourse.julialang.org/u/hiemstar)\
**Replies:** 7\
**Last updated:** [January 26, 2022, 3:07pm UTC](https://discourse.julialang.org/t/initerror-could-not-load-library-libcxxwrap-julia-stl-dll-on-windows/74535 "2022-01-26T15:07:30Z")

</div>

I successfully build libcxxwrap\_julia from source on Windows using cmake -DJulia\_EXECUTABLE="home/AppData/Local/Programs/Julia-1.6.3/bin/julia" .. -G "Visual Studio 16" cmake --build . --config=Release and have added a…

---

## [CxxWrap on windows](https://discourse.julialang.org/t/cxxwrap-on-windows/65178)

<div class="topic-metadata">

**Author:** [@gitboy16](https://discourse.julialang.org/u/gitboy16)\
**Replies:** 7\
**Last updated:** [January 16, 2022, 5:09am UTC](https://discourse.julialang.org/t/cxxwrap-on-windows/65178 "2022-01-16T05:09:13Z")

</div>

Hi, I am trying to use CxxWrap on windows. I am trying to reproduce the “hello world” on the github page. Questions: 1/ where is #include "jlcxx/jlcxx.hpp" ? 2/ how do I compile to a shared library? ( i have gcc) 3…

[Next page](https://discourse.julialang.org/tag/cxxwrap/780.md?match_all_tags=true&page=1&tags%5B%5D=cxxwrap)
