asmaloney / libE57Format

Library for reading & writing the E57 file format
Boost Software License 1.0
137 stars 66 forks source link

Unresolved symbol when trying to build shared lib #213

Closed PascalRunde closed 1 year ago

PascalRunde commented 1 year ago

On windows: I get an error

Unresolved external symbol:  ""class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl e57::floatingPointToStr<double>(double,int)" (??$floatingPointToStr@N@e57@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@NH@Z)".

which seems to refer to the floatingPointToStr function template in Stringfunctions.cpp. I am not experienced with C++ and I can not find out how to solve this.

Note: I am using the latest commit on Master and disabled "Warnings_as_Errors" because there were some issues with E57Exception.

asmaloney commented 1 year ago

Thanks Pascal. I don't have Windows, but I'll take a look and see what might be wrong. Windows needs some strange magic that might be missing. 🪄

asmaloney commented 1 year ago

It's not the strange magic I was thinking - what version of MSVC are you building with? Can you include the CMake command you're using to build?

because there were some issues with E57Exception.

Could you please add an issue with the errors you're getting? It should build with that on.

The GitHub workflows are building fine with Windows, so I need to figure out what's different about your setup.

asmaloney commented 1 year ago

(Note: My last change is not related to this issue, though it is touching the same code.)

asmaloney commented 1 year ago

It turns out that the CI wasn't building Windows with shared libs, so that was part of the issue. I spent all day yesterday looking at Windows DLLs and trying to debug this with GitHub workflows.

Things Windows DLLs don't like:

I think I have fixed these (commits incoming) and it all builds, but for the life of me I can't get the test build for Windows with shared libraries to run on the CI and it gives no information. The paths all look correct (for the xerces DLL).

So I'm going to commit what I have and you can see if it fixes things on your end.

Fixes:

PascalRunde commented 1 year ago

Sorry for not responding yet, I have been ill at the weekend. Thank you very much for the fast response and effort. I will definitely have a look at it and try to fix the issue with the test build.

PascalRunde commented 1 year ago

Turns out the testE57.exe needs to find the E57Format.dll as well as the xerces-c_3_2.dll and there are two ways to do this: Either specify these within the PATH environment variable or copy them to the same folder as the testE57.exe. I copied them manually and the tests worked just fine.

asmaloney commented 1 year ago

I have been ill at the weekend

Hope you're feeling better!

Turns out the testE57.exe needs to find the E57Format.dll

🤦 Ah. Of course - it's being built in a different directory from the test. I guess the Linux & macOS builds handle this properly. I'll need to figure out how to add that path to the Windows CI. Thanks!

asmaloney commented 1 year ago

I think Windows shared libs should be working now.

The Windows shared lib builds must have been spewing warnings forever, but nobody reported them. Glad to get it fixed up.

Thanks for reporting this Pascal!