-
Notifications
You must be signed in to change notification settings - Fork 228
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
Issues with unresolved symbols when linking static net-snmp library (MSVC 2022, OpenSSL enabled) #905
Comments
As one can see here, building Net-SNMP as a static library works fine with OpenSSL 3.4.0: https://ci.appveyor.com/project/BVanAssche87257/net-snmp/builds/51128958/job/8n5yv7c90hr6p0d2 |
Thank you for your response. I understand that the static build of net-snmp with OpenSSL 3.4.0 works fine on your CI setup. However, the issue I am experiencing is not during the build of net-snmp itself, but rather when using the statically built net-snmp library in my own project. Specifically: When I attempt to link the statically built net-snmp library to my project and use the mentioned OIDs (e.g., usmAESPrivProtocol, usmHMACSHA1AuthProtocol), the linker throws errors about missing implementations for these protocols. Please let me know if there are any additional configuration steps or flags that I might be missing to ensure proper linkage with OpenSSL in a static build. Thank you! |
Are you using win32/build.bat or not? If not, please check whether
|
Thank you for your clarification regarding the _DLL definition and the decision to link OpenSSL dynamically or statically. I confirm that I used win32/build.bat with the following parameters:
I used pre-compiled OpenSSL 3.4.0, distributed as an installer. Could there be another potential cause, such as incorrect linkage to OpenSSL static libraries (libcrypto_static.lib and libssl_static.lib), or perhaps a misstep in the build script itself when handling these dependencies? I’d appreciate any suggestions or additional checks I can perform to ensure the static library is properly linked with OpenSSL. |
I think it's time to analyze the involved binaries and check where the undefined symbols occur. Is this a good tool for analyzing the Net-SNMP static libraries and the .obj files to see which binary is causing the undefined symbol error: https://dependencywalker.com/? |
As far as I know, Dependency Walker only works for *.exe and *.dll. For *.lib it gave me an error, without useful result. As shown in the attached screenshot, the following symbols are marked as "External" in the output of dumpbin:
I have searched for the implementation of these symbols in the other .lib files generated by the Net-SNMP build process, as well as in the OpenSSL 3.4.0 libraries, but I was unable to find them. I have also come across mentions of similar issues online regarding unresolved external symbols related to SNMP protocols, but unfortunately, I couldn't find a suitable solution for this specific case. Could this be a build configuration issue, or are these symbols expected to be implemented elsewhere? Any guidance would be much appreciated. |
I don't see any screenshot attached? Anyway, all the names mentioned above are arrays defined in snmplib/snmpusm.c. These arrays should be present in netsnmp.lib. Which library has been analyzed with dumpbin? netsnmp.lib or another library? In case it is another library, does netsnmp.lib occur after the other Net-SNMP static libraries on the linker command line? |
I have resolved the issue. I was under the impression that the .lib files in C:\usr were copies of the libraries being built. However, it turns out the correct libraries are located in Net-SNMP\win32\lib\release. Those libraries do indeed contain the necessary symbol implementations. This behavior was counter-intuitive to me, but now it makes sense. Thank you for your help and guidance! |
Hello,
I encountered a problem when building the net-snmp library as a static library with the following configuration:
When linking the resulting library to my project, I get unresolved symbol errors for several SNMPv3-related protocols, such as usmAESPrivProtocol, usmHMACSHA1AuthProtocol, usmHMACMD5AuthProtocol, and others.
These issues occur in a function that initializes SNMPv3 sessions in my code. The errors point to missing definitions for these symbols in the static net-snmp library.
Interestingly, this problem does not appear when building net-snmp as a dynamic library.
Steps to reproduce:
Expected behavior:
The static library should include all necessary symbols to support SNMPv3 functionality, including authentication and privacy protocols.
Actual behavior:
Unresolved symbols prevent successful linking of the static library to the project.
Additional context:
This issue seems specific to static builds.
Dynamic builds work as expected without any linking errors.
This issue has been observed since the recent fixes for building the project as a static library on Windows x64, and it can be consistently reproduced on the latest commits as of December 8th.
Let me know if you need further details or a minimal reproducible example.
Thank you!
The text was updated successfully, but these errors were encountered: