cxx
cxx copied to clipboard
Solving 'Symbol Not Found' Error on Windows When 'bin' and 'lib' Coexist
Under Windows, when 'bin' and 'lib' exist together, you might encounter an error that says it can't find the symbol. I've linked a minimal example here for you to take a look: https://github.com/whynothackme/test_cxx.git. If you delete lib.rs, you should be able to compile and link normally. However, if lib.rs exists, you'll probably encounter a 'symbol not found' error.
I got the same problem: https://github.com/dtolnay/cxx/issues/1247. It seems like it is an easy found problem, but I don't know how to tune it to work.
Now I move the bridge code into the lib.rs, and change the build.rs from "cxx_build::bridge("src/main.rs")" to "cxx_build::bridge("src/lib.rs")", it works.
Add "l static=cxxbridge-demo" to lib crate is not the proper way, it still doesn't work if the cpp code in a extern cpp lib. So just remember: only one crate per build.rs