JuliaInterop / CxxWrap.jl

Package to make C++ libraries available in Julia
Other
418 stars 67 forks source link

error running test_cxxwrap.cpp in Julia 1.9.2 #380

Open mind6 opened 1 year ago

mind6 commented 1 year ago

I used MSBuild version 17.7.2 and cl.exe to build libcxxwrap-julia on Windows, then I set ~.julia\dev\libcxxwrap_julia_jll\override to point to its build directory. I can get a hello world function like this to work:

#include <string>
#include <jlcxx/jlcxx.hpp>

std::string greet()
{
   return "hello, world";
}

JLCXX_MODULE define_julia_module(jlcxx::Module& mod)
{
  mod.method("greet", &greet);
}

But any one of the tests test_cxxwrap, test_module, test_type_init in \libcxxwrap-julia\test produces the following message:

C++ exception while wrapping module StdLib: Symbol for type CppBasicString was not found. A Value of type null was found instead. Searched modules: Main Base Base
InitError: Symbol for type CppBasicString was not found. A Value of type null was found instead. Searched modules: Main Base Base
during initialization of module StdLib

I'm not sure what's happening exactly. libcxxwrap-julia was built against the pre-built Julia binary in my "program files" directory. Should this be working? Should I try another version of Julia? Do I need to build Julia from source?

mind6 commented 1 year ago

I found this problem only occurs in vscode prompt with CMake Tools extension active. test_cxxwrap.exe works in any other Windows prompt, works in Windows explorer, and also works within Visual Studio 2022 IDE. Maybe this is a lower priority setup issue. I'd still like to know what I should be looking for to understand why it's having this problem in vscode?

barche commented 12 months ago

I have tested using vscode on my machine, and at least the ctests work, provided I set the override correctly. On Windows, it may be easier to use the Overrides.toml method (see end of the libcxxwrap-julia Readme). You also need to have the Julia bin dir in your path, but I don't think that's the problem here, the error you see appears when binaries compiled with different compilers are mixed.