Met LNK2019 error when building a project which contains libs(built via msvc2017 32) with Kit msvc2015 32bits
-
Hi All,
I am trying to use grpc in QT.
I met the link error below (sorry that it's Chinese...):
crypto.lib(windows.obj):-1: error: LNK2019: 无法解析的外部符号 _SystemFunction036@8,该符号在函数 _CRYPTO_sysrand 中被引用Actually crypto.lib was build via VS2017 Win32 according to the grpc document(the part "cmake: Using Visual Studio 2015 or 2017..."), however, since there is no Kit for VS2017 32 bit, so I use Kit 2015 32 bit instead and get this link error.
So it seems that we still net QT 32 bit for VS2017... am I right?
Any insight would be very much appreciated! -
If you followed the instructions by the letter you have a 64bit build of gRPC, did you check that it is not the case before building your 32 bit application with it ?
-
If you followed the instructions by the letter you have a 64bit build of gRPC, did you check that it is not the case before building your 32 bit application with it ?
@SGaist
Thank you very much for your reply.
"If you followed the instructions by the letter you have a 64bit build of gRPC"
Actually I follow the steps mentioned in the part "cmake: Using Visual Studio 2015 or 2017 (can only bui...“ and only get a grpc.sln. I didn't use Ninja or msys2.
Anyway I am sure that the libs are generated by grpc.sln Win32 Debug vs2017.
(I tired to build grpc.sln in vs2017 using x64 debug but failed.)I also tried to build the qt project with the kit msvc2017 64bit and got the expected error:
libprotobufd.lib(generated_message_util.obj):-1: error: LNK1112: 模块计算机类型“x86”与目标计算机类型“x64”冲突
(sorry for the Chinese again, it says libprotobufd.lib is x86 which confilicts with the target type x64)I am sorry if my another post is duplicate and confusing. I made that post before I know I got the notification of your reply. I hadn't thought you could reply to me so quickly! Really appreciate!
Best Regards,
Moon -
If you followed the instructions by the letter you have a 64bit build of gRPC, did you check that it is not the case before building your 32 bit application with it ?
@SGaist
Just in case you wanna reproduce it, you can use https://github.com/Microsoft/vcpkg to download the grpc libs. -
I moved all answers here.
As for your problem it's exactly what I wrote, you are mixing different architectures. In this case it has noting to do with the compiler you use.
What errors did you get when building your dependencies in 64bit ?
-
I moved all answers here.
As for your problem it's exactly what I wrote, you are mixing different architectures. In this case it has noting to do with the compiler you use.
What errors did you get when building your dependencies in 64bit ?
@SGaist
I am pretty sure that the grpc libs were generated via building grpc.sln via vs2017 default configuration (Debug Win32).
The grpc.sln was generated by [ cmake .. -G "Visual Studio 15 2017" -DCMAKE_BUILD_TYPE=Release ] mentioned in the mentioned grpc document.And these libs can be used for a Helloworld project in vs2017.
If I tried to build grpc.sln in vs2017 with the configuration Debug x64,
(below is some configuration of projects' Debug x64:
/OUT:"C:\cppWorkspace\grpc.build\x64\Debug\gpr.lib" /MACHINE:X64 /NOLOGO
/OUT:"C:\cppWorkspace\grpc.build\x64\Debug\grpc.lib" /MACHINE:X64 /NOLOGO )the link errors look like below:
96>x64\Debug\main.obj : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'x86'
96>Done building project "protoc.vcxproj" -- FAILED.
...
Severity Code Description Project File Line Suppression State
Error LNK1112 module machine type 'x64' conflicts with target machine type 'x86' dsa C:\cppWorkspace\grpc.build\third_party\boringssl\crypto\dsa\x64\Debug\dsa.obj 1
Error LNK1112 module machine type 'x64' conflicts with target machine type 'x86' ec_extra C:\cppWorkspace\grpc.build\third_party\boringssl\crypto\ec_extra\x64\Debug\ec_asn1.obj 1
... -
I moved all answers here.
As for your problem it's exactly what I wrote, you are mixing different architectures. In this case it has noting to do with the compiler you use.
What errors did you get when building your dependencies in 64bit ?
@SGaist
The root cause seems to be that in QT my compiler cannot find the Advapi32.lib.
However, in VS2017, it can be found.
...zlibd.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib"...I think maybe it is a bug of QT, or shall we add QT 32 bit for vs20117link text?
After add this lib C:\Program Files (x86)\Windows Kits\10\Lib\10.0.16299.0\um\x86\advapi32 to the project, the link error is solved.
Related links:
https://irclog.whitequark.org/crystal-lang/2018-01-17My QT version is
Qt Creator 4.5.0
Based on Qt 5.10.0 (MSVC 2015, 32 bit)
Built on Dec 4 2017 04:12:22 -
@SGaist
The root cause seems to be that in QT my compiler cannot find the Advapi32.lib.
However, in VS2017, it can be found.
...zlibd.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib"...I think maybe it is a bug of QT, or shall we add QT 32 bit for vs20117link text?
After add this lib C:\Program Files (x86)\Windows Kits\10\Lib\10.0.16299.0\um\x86\advapi32 to the project, the link error is solved.
Related links:
https://irclog.whitequark.org/crystal-lang/2018-01-17My QT version is
Qt Creator 4.5.0
Based on Qt 5.10.0 (MSVC 2015, 32 bit)
Built on Dec 4 2017 04:12:22@GingerMoon said in Met LNK2019 error when building a project which contains libs(built via msvc2017 32) with Kit msvc2015 32bits:
My QT version is
Qt Creator 4.5.0
Based on Qt 5.10.0 (MSVC 2015, 32 bit)
Built on Dec 4 2017 04:12:22This is not your Qt version, this is Qt version which was used to build QtCreator.
Which Qt version did you install?
You can check this in your Kit configurations. -
@GingerMoon said in Met LNK2019 error when building a project which contains libs(built via msvc2017 32) with Kit msvc2015 32bits:
My QT version is
Qt Creator 4.5.0
Based on Qt 5.10.0 (MSVC 2015, 32 bit)
Built on Dec 4 2017 04:12:22This is not your Qt version, this is Qt version which was used to build QtCreator.
Which Qt version did you install?
You can check this in your Kit configurations.@jsulm
Thank you for the notice.
It's Qt 5.10.0 MSVC2015 32bit.