0

I built boost libraries with msvc. And I want to link to my program using mingw. As the title asked, how can I achieve that? When I try to link the boost libraries. The compiler suggests that it can't find symbols of the boost libraries.

mxmxlwlw
  • 327
  • 2
  • 15

1 Answers1

0

Quoting the mingw wiki here:

Object files and static libraries created with different compilers [...] often cannot be linked together. This issue is not specific to MinGW: many other compilers are mutually incompatible. Build everything from source with the same version of the same compiler if you can.

It is stated in the same page that if you want, you may use dynamic (shared) libraries from different compilers if you provide a C interface for the library you want to use. Then your program would use this interface (C wrapper library) to communicate with Boost, by including the header for this interface library with extern "C". Example of doing this can be found here.

In your case, however, this would not be preferable as you would have to expose everything you want to use from Boost one by one in the C interface that you would write yourself. You might find it much easier just compiling your libraries with the same compiler you are compiling your program with.

adenzila
  • 46
  • 7
  • So how should I do? Should I add extern "C" when include the boost libraries? Besides, my boost libraries is shared libraries. – mxmxlwlw Apr 25 '17 at 13:37
  • @mxmxlwlw My initial answer was a bit misleading, I've edited it to provide better explanation. – adenzila Apr 26 '17 at 15:00