Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use libraries compiled with visual studio in an application compiled by g++ (mingw)

Is it possible to use a library compiled by visual studio in an application compiled by g++ (mingw) on Windows?

like image 942
Jesse Vogt Avatar asked Jul 16 '09 14:07

Jesse Vogt


People also ask

Can I use MinGW in Visual Studio?

Getting started with MinGW is simple once you have installed the latest Visual Studio Preview. First, you will need to make sure that you select the C++ workload when you install Visual Studio. Next, you will need to download MinGW itself. There are actually many ways to install MinGW.

Is MinGW necessary for VS code?

You need to install MingW or GCC on your system in order to Run c,c ++ programs. VS Code is an IDE(integrated development environment) where you can compile and run those codes.

Should I use MinGW or MSVC?

MSVC is doing the compilation job significantly faster than MinGW-w64. The DLL sizes are comparable, if optimization is set to "-O2" for MinGW-w64, with "-O3" the DLLs from MinGW-w64 are larger. Binary files compiled with MinGW-w64 are performing significantly better than those compiled with MSVC.

How do I run a C++ program in Visual Studio?

Build and run your code in Visual Studio To build your project, choose Build Solution from the Build menu. The Output window shows the results of the build process. To run the code, on the menu bar, choose Debug, Start without debugging. A console window opens and then runs your app.


1 Answers

  • If the library is written in C++ and exposes a C++ interface: no (because the name-mangling differs between g++ and VC++).

  • If the library is a static library written in C (or with an extern "C" interface): yes, but certain caveats apply.

  • If the library is a DLL with a C interface: yes, but you'll have to create your own import library.

like image 52
Martin B Avatar answered Nov 10 '22 17:11

Martin B