1

I know this error has been addressed a lot, but until now I couldn't solve it for my project. I am doing a Qt application and want to compile it with the MSVC compiler instead of MinGW (here is the reason).

When I built the programm, I get loads of errors of this kind (just an excerpt):

error: LNK2019: unresolved external symbol sdot_ referenced in function "double __cdecl arma::blas::dot<double>(unsigned int,double const *,double const *)" (??$dot@N@blas@arma@@YANIPEBN0@Z)
error: LNK2019: unresolved external symbol sgemv_ referenced in function "void __cdecl arma::blas::gemv<double>(char const *,int const *,int const *,double const *,double const *,int const *,double const *,int const *,double const *,double *,int const *)" (??$gemv@N@blas@arma@@YAXPEBDPEBH1PEBN21212PEAN1@Z)

and this warning: LNK4272: library machine type 'x86' conflicts with target machine type 'x64'.

This thread suggests running qmake and re-building the project, but this didn't change anything.

From here and here and as the warning suggests, I figured I have to change the target machine for the linker. However, everything I found explained it in Visual Studio. How do I do this in Qt Creator?

I would be very thankful for any hints.

EDIT: So my program uses the armadillo library and this is the cause of the problems. When I change compilers, I need to compile or link this library in a new way (right?). This blog post summarized the problem in 2 points (the second point is the cause of the errors):

  1. MSVC cannot directly link to a dll -> we need a so-called “import library”.

  2. Symbol Visibility: GCC/MinGW exports all symbols by default, MSVC exports no symbol by default.

So when using MSVC I have to link the import library (.lib) instead of the .dll in the case of MinGW. How can I do this in QtCreator?

This is my first time going deep with compilers and linkers, so I am very open for corrections, suggestions and solutions!

arved
  • 4,401
  • 4
  • 30
  • 53
Mariam
  • 342
  • 3
  • 18
  • 1
    This is a linkage error but the most probable cause is the fact that one library is compiled against MinGW. Have you installed the correct qt MSVC and recompiled arma? – Dragos Pop Aug 22 '18 at 10:03
  • @DragosPop sorry, but what is arma? and what defines MSVC as correct? The MSVC compiles other qt projects successfully. if this means it is correct, then yes, it is. – Mariam Aug 22 '18 at 10:27
  • I see that you use a library in the error message arma::blas::... I did a quick search and found it on the internet. Don't know how you are using it but search your includes and linker settings. – Dragos Pop Aug 22 '18 at 11:10
  • I found it here: http://arma.sourceforge.net/docs.html, it might be that you are not using it directly, but indirectly. For example mlpack is using it. Any way it seems to be a low level mat lib, so if you are using a library that could do a lot of calculations, that could depend on this Armadillo or whatever it's name. – Dragos Pop Aug 22 '18 at 11:21
  • yeah, actually I am building on a project that was started by someone else, and he uses the library for some calculations (just found out now). So I am suspecting this library is made for a specific compiler version or something like that and that's why it doesnt work with the new compiler? @DragosPop – Mariam Aug 22 '18 at 11:32
  • No, it is compiled for that specific compiler. You just have to compile it again, for Visual Studio. This however might not be so simple, you need to configure it's build system to compile to visual studio. However from the documentation VS seems to be supported: http://arma.sourceforge.net/download.html read the Windows part. – Dragos Pop Aug 22 '18 at 12:13
  • 1
    It seems that it also has a CMake file, this means it should be easy enough to open in QtCreator and build it to target visual studio. Don't know exactly how since I haven't used QtCreator in a while – Dragos Pop Aug 22 '18 at 12:16
  • @DragosPop thanks, yeah I definitely got a better understanding of the problem now. Just need to find out how to solve it! – Mariam Aug 22 '18 at 12:32

0 Answers0