Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows: Impossible to link with onnxruntime with different compiler version #21

Open
DamRsn opened this issue Mar 24, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@DamRsn
Copy link
Owner

DamRsn commented Mar 24, 2023

On Windows, I get an error when linking with provided onnxruntime.lib:

'onnxruntime.lib' was created by a different version of the compiler than other objects like NeuralNote_Standalone ...

My MSVC version is 19.29.30148.0

@tiborvass
Copy link
Collaborator

tiborvass commented Mar 24, 2023

Argh, this is because the static onnxruntime.lib was compiled with VS 2022 (MSVC 19.35.32215)

According to https://github.com/MicrosoftDocs/cpp-docs/blob/main/docs/porting/binary-compat-2015-2017.md, you would have this error when there's a compiler version mismatch even by a minor version.

Possible solutions:

  1. You build onnxruntime.lib yourself (pros: works, cons: much longer build time + extra steps for building)
  2. We compile onnxruntime.lib as part of NeuralNote repo's build scripts adding a lot more build time (pros: seamless build, cons: much longer build time)
  3. Investigate what happens if we turn off LTO flags such as /GL and /LTCG.
  4. Get rid of onnxruntime altogether. But I'll leave that to you to detail what it entails in a separate issue.

@olilarkin
Copy link

If you use github actions and do your build in the cloud, you can cache the ort-builder output so it doesn't take a long time to build if you didn't change the model. This is of course a bit annoying for local builds. Or just say it requires VS2022?

@tiborvass tiborvass changed the title Impossible to link with onnxruntime on Windows with different compiler version on Windows Windows: Impossible to link with onnxruntime with different compiler version Mar 25, 2023
@tiborvass
Copy link
Collaborator

@olilarkin thanks! I think this is more a concern for people trying to build locally.

@DamRsn DamRsn added the bug Something isn't working label Mar 29, 2023
@trirpi
Copy link
Contributor

trirpi commented Sep 8, 2023

Still having this problem currently on Windows. Any clue on how to build onnxruntime.lib yourself?

Would it suffice to follow these onnxruntime inferencing build instructions from within the ThirdParty directory before running build.bat?

@DamRsn
Copy link
Owner Author

DamRsn commented Sep 8, 2023

You can build onnxruntime.lib yourself by following the steps indicated in the readme (Build from source, Windows).

Using the instructions from onnxruntime documentation won't work as it will create a dynamic library.

@trirpi
Copy link
Contributor

trirpi commented Sep 9, 2023

Oh I see, didn't notice that part of the README was related to this issue. I did follow it but seems like I missed an error.

Had to install python 3.10 because the specific requirements.txt versions are not available anymore in 3.11 and had to update cmake from version 3.23 to the latest. Not sure if it was relevant but I also executed everything from the developer command prompt for VS 2022.

Now it builds, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants