Use MinGW static library (.a) within Visual studio environment - c++

I work on a project that generate several static libraries (.a) from MinGW with Scons project files.
And I need to use these libs into an other project that work on C++ Visual Studio 2013.
First I tried to just add MinGW lib to my VS project and obviously it didn't work out.
I read some things about using a ".def" file to switch from ".lib" to ".a" but found nothing about convertion from ".a" to ".lib". But I have no idea how to get this ".def" file.
Does anyone have some clue that what I am trying to realise is possible (use MinGW into VS2013) ? Or even a solution that can help me :)
Mathieu.

Related

cannot see the file 'SDL2.lib'

This question is not a duplicate of cannot open file 'SDL2.lib' which discusses this same error but my problem is that I don't have an SDL2.lib file, if I can just see it I can make this work
I'm trying to set up the development environment for SDL2 by following Lazy Foo's tutorial.
Setting up SDL 2 on Visual Studio 2010 Ultimate
The tutorial is for Visual Studio 2010, I'm using Visual Studio Community Edition 2017. Is that a problem?
The problem starts when linking the libraries, there is no x86 or x64 folder inside the lib directory of SDL2's Windows Development libraries that I downloaded from SDL version 2.0.8 (stable).
So I specified it as lib/ instead of lib/x86 as it says in the tutorial.
These are the files inside the lib folder
$ ls
cmake/ libSDL2.dll.a libSDL2_test.a libSDL2main.a pkgconfig/
libSDL2.a libSDL2.la libSDL2_test.la libSDL2main.la
When building VS2017 is throwing an error saying that Cannot open file 'SDL2.lib'. Yeah, there is no such file. Do I need to do an additional step to get this file?
When I configured for CodeBlocks it works fine. What exactly am I doing wrong here? This may have an obvious answer but I'm not able to find it.
Library name `libSDL2.dll.a' indicates that it is not meant for use with VS C++ ( for dynamic link you need dll + lib, for static link you need only the lib ). You can construct a lib file from dll using dumpbin.exe and lib.exe. Your options are:
1) Download SDL source file in zip format from GitHub and create you own binaries.
2) Use vcpkg and install in just one command line ( recommended).
3) Download the SDL binaries from internet. ( you can have linker issues if the project configurations doesn't matches yours)

Linking error while using dlib with libjpeg

I am studying Machine Learning and Pattern Recognition and using dlib library for that. I was trying one example code face_detection_ex.cpp provided with the library. I created a separate project under Visual Studio 2010 and included the face_detection_ex.cpp example and dlib\all\source.cpp files. It build fine. But, if I enable DLIB_JPEG_SUPPORT by
#define DLIB_JPEG_SUPPORT
then it will throw the linking error LNK2019 for all the functions of libjpeg library used by the dlib library. I tried #pragma comment(lib, libjpeg) and I also tried to include the library in project properties, but still the same.
After spending 1 day on this error, I switched to linux and try to work in that. But there also I am getting the same linking errors.
Then on the dlib release-note I read that libjpeg library is included in dlib's external folder and use dlib's cmake file for the example code and cmake will perform the static linking. I tried that and with cmake it is linking. I tried to find out how the linking is happening as I want it to work with visual studio and other compilers also but I couldn't find out why the libjpeg library is unable to link.
Any suggestion?
EDIT: Here it is mentioned how to use dlib with Visual Studio. And how to compile the example on linux. So, as I have to link with libjpeg library, I added the -ljpeg in the command.
You can use CMake to generate a Visual Studio project that is properly configured and that's the easiest way to do this if you want to use Visual Studio.
However, if you really want to configure the Visual Studio project by hand then all you need to do is add the files in the dlib/external/libjpeg folder to your Visual Studio project and also add the dlib/external/libjpeg folder to the include search path.

Visual Studio 2013 (vs120) asks for wrong boost libraries

I'm trying to compile one of my projects on Windows 7, using Visual Studio 2013. I've installed Boost 1.53 and setup the solution using cmake.
What happens is that now the compiled libraries of boost are in the form libboost_*-vc120-mt(-gd)-1_53.lib. In the linker project options, under the input tab, I have verified that the libraries that I need are there, and in fact the compiler is able to correctly read them.
However, for some reason that I absolutely can't understand, the linker is also trying to find libraries compiled as vc110. For example:
error LNK1104: cannot open file 'libboost_filesystem-vc110-mt-gd-1_53.lib'
The Platform Toolset that is listed in the project option is "Visual Studio 2013 (v120)". I couldn't find any reference to vc110 in any of the project options. Can you help me understand what is happening?
This post thankfully solves my question. I wasn't able to find it before. The solution is to edit the boost/config/auto_link.hpp because the code inside is not able to handle vc120, and ends up suggesting vc110
How do I specify, which version of boost library to link to?
The library name is autogenerated in the boost header version.hpp
Possibly the version wasn't rebuilt, or you are pointing at the wrong header version?
Instead of patching the config file try just defining a macro before the header inclusion .. this is what I did in my project
//#define BOOST_LIB_TOOLSET "vc100"
//#include

Boost C++ Libraries linker error libboost_serialization-vc100-mt-gd-1_47.lib

I'm using Boost C++ Libraries v1.47 to serialize an class (I used the installer and selected everything and for VS2010).
But I get a error from my Visual Studio 2010 linker "Lnk1104 Can not open libboost_serialization-vc100-mt-gd-1_47.lib". I set up the "c:\program files\boost\boost_1_47" for my includes and "c:\program files\boost\boost_1_47\lib" for my libs. I don't know what's going wrong.
Update
I don't know why but if I put the lib files from the boost directory to "c:\program files\Microsoft Visual Studio 10.0\VC\lib" everything work fine. Boost load the lib files
somehow dynamical.
If you cannot find the file on your computer with the windows searcher just ask anybody else who uses boost to give you a copy of that file (libboost_serialization-vc100-mt-gd-1_47.lib).
My friend from work used to have the same trouble after having installed boost, there was just not the file in the boost folder. At the same time I picked up the file successfully so we copied it to the right directory on his computer.
For some reason precompiled libs in the installer are named on format "boost-module-vc100..." and headers specify library name as "libboost_module-vc100...". So you should specify library name in project settings to make it linked correctly.
I solved this issue by compiling all boost libraries by myself. With modern PC it won't take too long to do.
to resolve this problem,
go to properties -> Linker -> General -> Additional Library Directories
Enter the path of boost:
Boost-path\stage\lib

Compiling OpenCV for Visual C++ 9.0

I looked at many places but could not find anything telling me how to buld the lib files. I know how to link them, but openCV install folder only contains .a files. I cant find an sln file or dsp. How can I make the lib files? Right now all the samples get linker problems because the lib files dont exist.
Thanks
The Windows installer (.exe) for OpenCV 2.0 does not come with the binaries pre-built for vc++, nor does it have the .vcproj files for using vc++ to build them. You need to have cmake, which is available for free on the web. I used the GUI. Use that to build .vcproj files with which you can compile everything in VC++ 2008 or whatever. There are some gotchas. The question has been asked and answered.
.a files are libraries. On a unix platform they're typically statically linked libraries.
If you're on windows however they should be .dll files. How did you compile OpenCV and does it support compiling on windows?
In order to create the .sln files you need to run CMake on the OpenCV folder containing makefiles.