1

I've seen similar questions like this asked here but none of them had any working answers and most of them were for Linux.

I'm making a Qt Widgets project in Qt Creator on Windows. I'm trying to link rpclib. I've included the library by right clicking my project and using the "Add Library" wizard as you can see here.

As long as the library is merely included and not used, it works fine. As soon as I'm trying to use a function from that library though, it gives me these errors.

Before including, I compiled the library as instructed in rpclib docs on Windows as you can see here.

How do I get it to work?

Leaves
  • 35
  • 1
  • 9
  • 1
    Did you build `rpclib` with the same toolchain (mingw64)? – mugiseyebrows Mar 23 '21 at 15:19
  • @mugiseyebrows I'm not quite sure, I just built it in powershell using CMake. How would I build it with mingw64? (Sorry for the stupid question, I'm not that experienced with C++) – Leaves Mar 23 '21 at 15:22
  • 1
    try to specify compiler for cmake explicitly https://stackoverflow.com/questions/45933732/how-to-specify-a-compiler-in-cmake – mugiseyebrows Mar 23 '21 at 15:24
  • This is a good point. msvc compiled c++ binaries will not be compatible with mingw. – drescherjm Mar 23 '21 at 16:00
  • ***if I can't find any working answers?*** You probably need to specify what you actually tried. Although if you compiled the library using Visual Studio Community that is likely your problem. – drescherjm Mar 23 '21 at 16:03
  • @mugiseyebrows Following up... I did figure out how to compile a MinGW makefile with cmake but when I build from that makefile I get a "librpc.a" file, which I don't think is compatible with Windows. I'm about to give up on this project, been trying to solve this for like 2 weeks. – Leaves Mar 23 '21 at 18:50
  • 1
    @Leaves librpc.a is a static library, you can link it with your application, just add `LIBS += -L/path/to/librpc_lib_dir -lrpc` and `INCLUDEPATH += /path/to/librpc_include` to .pro file – mugiseyebrows Mar 23 '21 at 19:05
  • An `.a` file is exactly what you want when using `mingw` as your compiler. – drescherjm Mar 23 '21 at 20:07
  • @drescherjm well now I'm just getting a bunch of error messages saying "undefined reference to __imp_... as seen here: https://i.imgur.com/wXVZ1X3.png – Leaves Mar 23 '21 at 23:21
  • Probably need to link with `ws2_32.lib` which is part of `winapi` [https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasend](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasend) This is in addition to the libraries you already use. – drescherjm Mar 23 '21 at 23:50
  • @drescherjm already have winmm and ws2_32 linked so thats weird – Leaves Mar 24 '21 at 08:06
  • The errors posted on the third-party resource went away. The question with a code and errors on third-party resources should be deleted. – 273K Feb 27 '23 at 18:14

0 Answers0