问题描述
我正在使用Qt 4.8.3和QtCreator,它们已按照.但是现在我需要链接到GSL(Gnu科学图书馆),但是目前我只知道如何用g ++构建它,这会产生链接器错误,正如此处.当然可以使用msvc2010构建gsl,但是如何?如果有解决方案,我已经安装了VS 2012 Express(尽管我从未使用过).
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.
编辑:看来CMake最好的办法就是手动为GSL创建整个CMakeLists.txt文件的层次结构.那只是太多了,所以我放了一个100pt.对上述问题的赏金.使用Visual Studio路由(此处)或使用g ++解决我的问题,将获得赏金和两个问题的答案.
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.
更新:以下答案很有效,但并非无缝进行,可能是因为我实际上需要在VS2012下进行编译.需要对代码进行一些调整,例如显式强制转换,显然在以前的编译器中是允许的,但我的不是.否则事情进行得很顺利.
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.
推荐答案
您可以使用CMake并从此存储库,用于您使用的任何Visual Studio版本.查看@vitaut的答案以获取更多详细信息.
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.
这篇关于如何使用msvc2010构建GSL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!