How to generate .lib files with mingw toolchain? - gcc

I have installed MingW GCC 4.8.1 in my system. I am trying to build the LLVM source code( with some extra modification). Cmake 2.8.12 is used to generate the makefiles and visual studio solution files. I am able to build the LLVM source (Rel 3.4.2) with Visual Studio 2010 And is generating both lib and dll file. But with MingW I am not able generate .lib files by simply running Make all.
How to make MingW generate .lib file while building the project ?

Use CMAKE_GNUtoMS. Add -DCMAKE_GNUtoMS=ON to the build command. See this CMake issue. As result, a .lib file will be generated along with the .dll.a file.

Related

CMake microsoft visual studio + gcc

I'm using cmake to build the project.
There is a CMakeLists where is used to build the project.
So, when I create a build folder, and use
cmake ..
the project solution is created, but with MVSC c++ compiler.
Is it possible to generate a solution with GCC compiler but in a Visual studio solution?

Boost VS2017 linking to the wrong DLL

I have a CMake file which does this:
find_package(Boost COMPONENTS system filesystem)
add_library(MyModule MODULE main.cpp)
target_include_directories(MyModule PUBLIC ${Boost_INCLUDE_DIRS})
target_link_libraries(MyModule Boost::system Boost::filesystem)
I'm using VS 2017 as my generator. When I generate the project file with cmake, it finds boost_system-vc141-mt-1_63.lib and I can see that it is in the linking rules of the vcxproj. However, when I try to compile I get this error:
LINK : fatal error LNK1104: cannot open file 'libboost_system-vc140-mt-1_63.lib
Note the different generators (vc140 vs vc141). I know my compiler has output the right values because I built boost from source, so I tried to just rename vc141 to vc140, but the error stayed the same. I also confirmed that vc140 is not referenced in the project file.
What's going on? How can I force boost to link to the correct version?
When building with Visual Studio, boost has some pragma statements which do the linking for you. This is called "Auto-linking" and it over-rides any command-line arguments you may be passing to the linker.
The solution is to define BOOST_ALL_NO_LIB. This can be done in two ways:
In source code before including boost headers as #define BOOST_ALL_NO_LIB.
It could be added to your cmake file as: add_definitions("-DBOOST_ALL_NO_LIB").
As of CMake 3.5: Use the disable_autolinking imported target:
target_link_libraries(MyModule Boost::system Boost::filesystem Boost::disable_autolinking)

boost linking with visual studio 2010

I have successfully built boost using bjam and visual studio 2010 using this command:
bjam --build-dir=c:\boost --build-type=complete --toolset=msvc-10.0 address-model=64 architecture=x86 --with-system
I have also set the stage/lib directory as the lib directory in visual studio.
However, the linker gives me this:
fatal error LNK1104: cannot open file 'libboost_filesystem-vc90-mt-gd-1_50.lib'
Why is it looking for 'vc90' versions of the libraries? the vc100 version is there in the directory.. how do I change that?
Thanks.
You can explicitly specify the paths to the libraries in project settings. First you need to include the library names that you want to link against in your project.
Now we have to specify the directories, where the libraries specified above can be found.
I hope, that helps.
Check the compiler setting (You have choices for vc90 (2008), vc100 (2010)) in your project's properties.

Using GMP on windows

I am trying to use GMP in a C++ program on windows, and I compiled it successfully with Cygwin, and I get an .a file, which is linux's version of a .lib file. Is there a way I can use this with the Visual C++ compiler, or is there a way to compile GMP for windows to produce a .lib file?
I don't know about creating a .lib file, but you may want to look at mpir. MPIR is a fork of GMP that compiles with Visual Studio 2008 and 2010.

Where to get PCL boost libraries with -mgw48 postfix?

I'm working with MinGW not Visual Studio to compile openCV libraries to use them in a Qt .pro project.
My problem is my library files in boost folder are all -vc100 while CMake is trying to find -mgw48 files.
My libraries are in this directory:
C:\Program Files\PCL 1.6.0\3rdParty\Boost\lib
and their name are like : boost_date_time-vc100-mt-1_49.lib
but I want them to be like : boost_date_time-mgw48-mt-1_49.lib
so that CMake could recognize them.
Where can I download PCL with -mgw48 libraries?

Resources