How to use a DLL on Qt 6 with MSVC 2019 64bit compiler?
-
I'm currently working on setting up a Vectornav VN-200 using the programming library that they provide on their website. The file that I downloaded did not come with any .lib or .dll files to link to, but it came with all of the .cpp and .h files needed for the project. So I manually added them into a new widget project.
However, when I attempt to build the files, I get these errors:
serialport.obj:-1: error: LNK2019: unresolved external symbol __imp_RegEnumValueW referenced in function "public: static class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > __cdecl vn::xplat::SerialPort::getPortNames(void)" (?getPortNames@SerialPort@xplat@vn@@SA?AV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@XZ)
serialport.obj:-1: error: LNK2019: unresolved external symbol __imp_RegOpenKeyExW referenced in function "public: static class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > __cdecl vn::xplat::SerialPort::getPortNames(void)" (?getPortNames@SerialPort@xplat@vn@@SA?AV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@XZ)
serialport.obj:-1: error: LNK2019: unresolved external symbol __imp_RegQueryInfoKeyW referenced in function "public: static class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > __cdecl vn::xplat::SerialPort::getPortNames(void)" (?getPortNames@SerialPort@xplat@vn@@SA?AV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@XZ)
I googled each of the functions, and they appear to come from a library in System32 called advapi32.dll, and I think the issue I'm having would be solved if I were able to get the compiler to include this library in my project. I found a guide to do it with a MinGW compiler on Qt 6, but I haven't found one on how to do it with the MSVC compiler that I have to use for this project. Any help would be appreciated.
-
@DubleDroxon442
did you link againstadvapi32.lib
? -
@raven-worx I tried to look for the advapi32.lib file in System32, but I only found the advapi32.dll file. Do I have to download a .lib version from the internet, or am I not looking in the right place?
-
You should not download any lib from somewhere in the internet. Advapi32.lib is normally shipped with the Windows SDK which is automatically installed with MSVC. Also a proper MinGW environment should supply this import lib.
-
@Christian-Ehrlicher I found the .lib file in the windows sdk, just like you told me and got the program compiled. Thank you very much!
-
oh and @raven-worx thank you too