Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
793 views
in Technique[技术] by (71.8m points)

visual studio - How to build GSL with msvc2010?

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...