cxx icon indicating copy to clipboard operation
cxx copied to clipboard

Solving 'Symbol Not Found' Error on Windows When 'bin' and 'lib' Coexist

Open whynothackme opened this issue 1 year ago • 3 comments

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.

whynothackme avatar Jun 16 '23 08:06 whynothackme

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.

nneesshh avatar Jul 17 '23 09:07 nneesshh

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.

nneesshh avatar Jul 17 '23 10:07 nneesshh

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

nneesshh avatar Jul 18 '23 02:07 nneesshh