-
Notifications
You must be signed in to change notification settings - Fork 8
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
Problems building on VS for Windows 10 #3
Comments
So the libhsm.vcxproj project file is very old and contains a lot of invalid file references directly to the Safenet Luna libraries. The following file references are completely invalid and need to be removed. I had meant to come back and clean this file up but never did. In addition the correct references need to be added back. You might want to just ignore this old project and create a new one to compile with MS C++ and Visual Studio. Alternatively you can cross compile with gcc or natively compile with gcc on a Windows target. This is a configuration that should work since this project ran exclusively on Windows before being ported to Linux. But it is possible there may need to be some precompiler directive tweeks to get it fully working. You also want to use the OS_WIN pre-processor directive. ChrystokiConfiguration.cpp / .h |
Ok thanks for the update. I give the gcc on windows a try.
…On Tue, Jun 30, 2020 at 3:40 PM Benton Stark ***@***.***> wrote:
So the libhsm.vcxproj project file is very old and contains a lot of
invalid file references directly to the Safenet Luna libraries. The
following file references are completely invalid and need to be removed. I
had meant to come back and clean this file up but never did. In addition
the correct references need to be added back. You might want to just ignore
this old project and create a new one to compile with MS C++ and Visual
Studio. Alternatively you can cross compile with gcc or natively compile
with gcc on a Windows target. This is a configuration that should work
since this project ran exclusively on Windows before being ported to Linux.
But it is possible there may need to be some precompiler directive tweeks
to get it fully working.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#3 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AF62FTYPRI2KXXWLQLYL3PTRZH2MZANCNFSM4OMIESCQ>
.
|
Hi @S0C1esq , have you ever recompiled libhsm.dll sucessfully? I have been trying to do this with much effort but always got errors, for instances when I tried to recompile the source code of "libhsm" library with Visual Studio 2013 on Windows 10, I've had such errors in "p11hsm.cpp":
@bentonstark could you please give me some hint to solve such problems? Really appreciate your help! |
This library first started out as a VS 2015 C++ library targeted for Windows 2008R2 to enable HSM access from C#. Since then I ported it and re-wrote it to compile on Linux with gcc and created an interface library in Python. I never ported it back to Windows so although it started on that platform it is bound to have some issues that need to be resolved if you compile with VS 2013 which is not fully C99 and C++11 compliant. Another option I have not tried is to use gcc and cross compile to Windows from Linux. Alternatively you could compile directly on Windows using gcc. I have not attempted either one of these options. Have you attempted to compile using gcc for Windows on Windows directly? https://solarianprogrammer.com/2019/11/05/install-gcc-windows/ |
error C3861: 'LoadLibrary': identifier not found error C2070: 'char []': illegal sizeof operand |
Hi @bentonstark , thank you for your rapid response! Honestly I have no experience with gcc and mingw, I just looked up tutorials/infos from the Internet. Could you point me the right way to go please? |
So first things, you did add a OS_WIN declaration to your command line so that's good. winsock.h is getting pulled into the build. You should be able to remove it by adding the #define WIN32_LEAN_AND_MEAN statement to the top of the p11hsm.h file as shown below. --- p11hsm.h The other issue is the reclaration of the snprintf function or lack of declaration. So when I compiled this thing with MSVC years ago, Microsoft supported snprintf but under the name _snprintf so I aliased it for windows builds only. It looks like the compiler is finding that definition for _snprintf in the file stdio.h but there is also now a snprintf that windows now supports in the stdio.h fil. Try commenting out the following #define for snprintf. |
You're so pro @bentonstark !
This answer explains that the dll may not be a COM DLL so there is no need to register it: Suppose that recompiling libhsm.dll is the prerequisite before using your py-hsm library, I'd like to have some questions related to py-hsm, so I'll post them in your github py-hsm project, hope to get your help! Thank you. |
It is not a COM object so you don't need to register it with the Windows registry. But it will need to be in the shell path for the Windows executable to find or in the same directory as the executable. For you the executable that will consume libhsm.dll via LoadLibrary() WIN32 API call will most likely be Python3.exe. You can set the Windows path variable globally via the following instructions. Or you can set the Windows Shell PATH variable for the current terminal session. So if libhsm.dll was located in C:\path-to-the-dll-directory you could set the path in your current shell and then run the following. Note that once your terminal session is closed the path will be removed. |
@bentonstark , I did the changes you suggested in the header files but I still get warnings same as @longnt89 :
What could be wrong with my manipulation ? |
Update : I could not make any progress using the command line (the warnings remained and the dll was not generated). |
You have redefinitions that you need to fix.
|
Hello,
Trying to build libHSM on Windows 10 to support py-HSM. Receiving the following errors below. Is there something else I need to configure first.
Thanks.
Severity Code Description Project File Line Suppression State
Error C1189 #error: Macro definition of snprintf conflicts with Standard Library function declaration libhsm c:\program files (x86)\windows kits\10\include\10.0.17763.0\ucrt\stdio.h 1935
Error (active) E0065 expected a ';' libhsm C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\cstdio 52
Error (active) E0035 #error directive: Macro definition of snprintf conflicts with Standard Library function declaration libhsm C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\stdio.h 1935
Error (active) E0655 the modifier "__inline" is not allowed on this declaration libhsm C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\stdio.h 1940
Error C1083 Cannot open source file: 'ChrystokiConfiguration.cpp': No such file or directory libhsm C:\Users\George\libhsm-master\src\c1xx 1
Error C1083 Cannot open source file: 'c_bridge.cpp': No such file or directory libhsm C:\Users\G\libhsm-master\src\c1xx 1
Error C1083 Cannot open source file: 'ckbridge.cpp': No such file or directory libhsm C:\Users\G\libhsm-master\src\c1xx 1
Error C1083 Cannot open source file: 'DynamicLibrary.cpp': No such file or directory libhsm C:\Users\G\libhsm-master\src\c1xx 1
Warning C4005 'EXTERN_C': macro redefinition libhsm c:\users\george\libhsm-master\src\p11hsm.h 35
Error C2733 'connect': second C linkage of overloaded function not allowed libhsm c:\users\G\libhsm-master\src\p11hsm.h 77
Warning C4005 'snprintf': macro redefinition libhsm c:\program files (x86)\windows kits\10\include\10.0.17763.0\ucrt\stdio.h 1933
The text was updated successfully, but these errors were encountered: