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

LNK2019 unresolved external symbol __imp_strncpy referenced in function gotoblas_dynamic_init #2825

Closed
realgarik opened this issue Sep 7, 2020 · 6 comments

Comments

@realgarik
Copy link

Hi,

I have some library, which is using the openBLAS and that library containing BLAS is linked statically to my test executable. Here I'm facing some strange linkage issue.
I'm using windows VS2017 x64, so I did an openBLAS build using <1. Native (MSVC) ABI> as it was described in build doc.
When I'm linking the libopenblas with my own static library to my executable, I'm facing the following linker issue:

LNK2019 unresolved external symbol __imp_strncpy referenced in function gotoblas_dynamic_init

After digging in the web I've found some solution to this issue to link "msvcrt.lib" as well.
After adding "msvcrt.lib" to my project's "Linker -> Inputs" solved the issue for Release target, but for Debug after linking the same "msvcrt.lib" I'm facing a lot of other linker issues:

Error LNK2001 unresolved external symbol _invalid_parameter
Error LNK2001 unresolved external symbol _calloc_dbg
Error LNK2001 unresolved external symbol _free_dbg
Error LNK2001 unresolved external symbol _malloc_dbg
Error LNK2001 unresolved external symbol _CrtDbgReport
Error LNK2001 unresolved external symbol _CrtDbgReportW

Has someone faced this kind of issue?
Thanks in advance

@martin-frbg
Copy link
Collaborator

Suspect there is either a "debug" version of msvcrt, or a dedicated library of debug symbols available in/for VS2017. This is unlikely to be an OpenBLAS-specific problem, try google.

@realgarik
Copy link
Author

Actually I was able to fix linkage issue by changing "C/C++ -> Code Generation -> Runtime Library" for both of my library and test application.
Previously it was set to be "Multi-threaded Debug (/MTd)"
Now by changing it to be "Multi-threaded Debug DLL (/MDd)" the linkage issues were gone.

I'm guessing that C runtime now will be loaded dynamically instead of the old static linkage with /MTd, not sure what kind of drawbacks it can produce, but anyway, now it works.

@caibf
Copy link

caibf commented Jan 26, 2021

Yeah. I meed the same problem. Great help for me. Thanks!
Just change to "Multi-threaded Debug DLL (/MD)", other than "Multi-threaded Debug DLL (/MT)" in the release mode.

@LAWRENCE-COPER
Copy link

I love you guys, It works for me too!!! This is amazing!

@sfc9982
Copy link

sfc9982 commented May 9, 2022

Really helpful!!!

@Saigut
Copy link

Saigut commented Aug 27, 2023

Hello, what if I want to link staticlly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants
@Saigut @caibf @martin-frbg @realgarik @sfc9982 @LAWRENCE-COPER and others