How to build GSL with msvc2010?

2019-01-22 13:54发布

I'm working with Qt 4.8.3 and QtCreator, which I've compiled with msvc2010 as per the instructions here. Now however I need to link to GSL (Gnu Scientific Library), but currently I only know how to build it with g++ which produces linker errors just as described here, undoubtedly for the reason given in the answer by @EvanTeran. However, in my case, building Qt with g++ via cygwin is probably not an option--I've just come off a multi-day nightmare during which I tried to do just this, but could not, as recorded here. Surely there is a way to build gsl with msvc2010, but how? I have VS 2012 Express installed (though I've never used it before) in case there's a solution using it.

EDIT: Looking at CMake, it seems the best I can to is to manually create an entire hierarchy of CMakeLists.txt files for GSL. That's just a little too much so instead I've put a 100pt. bounty on the question mentioned above. Solving my problem the Visual Studio route (here) OR with g++ will get the bounty and the answer to both questions.

Update: The answer below worked great, but not seamlessly, possibly because I actually needed to compile under VS2012. A few tweaks to the code were required, such as explicit casts, which were tolerated under the previous compiler apparently but not mine. Otherwise things proceeded pretty smoothly.

2条回答
SAY GOODBYE
2楼-- · 2019-01-22 14:31

I have implemented CMake build support for GSL here: https://github.com/ampl/gsl

CMake can either generate a Visual Studio solution or NMake makefiles. For example:

> git clone git://github.com/ampl/gsl.git
> cd gsl
> cmake .
-- Building for: Visual Studio 10
-- Check for working C compiler using: Visual Studio 10
-- Check for working C compiler using: Visual Studio 10 -- works
...

This generates the solution (GSL.sln) and project files for Visual Studio 2010.

This CMake build script is now included in the contrib directory of the GSL Git repository git://git.savannah.gnu.org/gsl.git.

As of May 2014, building shared libraries (DLLs) is supported as well with GSL_SHARED option.

查看更多
ゆ 、 Hurt°
3楼-- · 2019-01-22 14:54

You can use CMake and create your own build from this repository for whatever Visual Studio version you are using. Check out the answer by @vitaut for more details.

查看更多
登录 后发表回答