|
From: Jonathan S. <sw...@gm...> - 2022-05-02 12:33:45
|
Hi Chirag, Did you follow the instructions in the CMake output and 'Add the installation prefix of "QuantLib" to CMAKE_PREFIX_PATH or set "QuantLib_DIR" to a directory containing one of the above files'? If C:/local/QuantLib-1.24/cmake-build-debug-visualstudio2017 is your CMake build directory, then the 'above files' will be found in the cmake directory under that build directory. If that doesn't work then the best I can do is point you to the documentation on CMake config mode[1] and wish you luck, as I won't be able to offer much further help remotely. By the way, the quantlib-vcpkg-example repo that you found is an example of how to link your project to QuantLib installed through vcpkg, which you haven't used. If you'd like to, you can try out vcpkg, and it may make your life easier in the long run, but be aware that it has a learning curve of its own to grapple with first. [1] https://cmake.org/cmake/help/latest/command/find_package.html#config-mode-search-procedure Jonathan On Mon, May 2, 2022 at 1:43 PM <chi...@ya...> wrote: > Hi Jonathan – thank you for your kind advice. I finally managed to build > Quantlib in CLion and the lib file is found as below. All the Examples > folder also works fine. > > > > > > > > 1. I am creating a project outside root Quantlib folder & don’t have a > problem finding the Boost files as I have used several Boost projects > before which work fine. I cannot seem to find and link the Quantlib > library. ( I created a new project called TestQLCLion). Can you please > advise how to modify the CMake file below please ? I tried several times > but keep failing. > > > > > > cmake_minimum_required(VERSION 3.20) > project(TestQLCLion) > set(CMAKE_CXX_STANDARD 14) > set(BOOST_ROOT "C:/local/boost_1_65_0") > set(Boost_INCLUDE_DIR "C:/local/boost_1_65_0" ) > set(Boost_LIBRARY_DIR "C:/local/boost_1_65_0/lib32-msvc-14.1" ) > find_package(Boost 1.65.0 REQUIRED) > > > > *#include_directories(C:/local/QuantLib-1.24/cmake-build-debug-visualstudio2017/ql)* > include_directories(C:/local/QuantLib-1.24/) > find_package(QuantLib CONFIG REQUIRED) > > add_executable(TestQLCLion main.cpp) > target_include_directories(TestQLCLion PRIVATE ${Boost_INCLUDE_DIRS}) > target_link_libraries(TestQLCLion PRIVATE ${Boost_LIBRARIES}) > target_link_libraries(TestQLCLion PRIVATE QuantLib::QuantLib) > > > > > > Thank you for your kind assistance. > > > > > > I also tried another one of your gists to link to the library directly but > fails > > > https://github.com/sweemer/quantlib-vcpkg-example/blob/025760be5befe150274ce7369066d581ffb50cf5/CMakeLists.txt > > > > *From:* Jonathan Sweemer <sw...@gm...> > *Sent:* Thursday, January 20, 2022 8:44 PM > *To:* Chirag Desai <chi...@ya...> > *Cc:* QuantLib users <qua...@li...> > *Subject:* Re: [Quantlib-users] Quantlib in CLion > > > > I took a quick look at your CMakeLists.txt file and fixed it up here: > https://gist.github.com/sweemer/dff4b0294eff698a3d670811549d3c35 > > > > For my gist to work you'll need to download the latest version 1.25 of > QuantLib. The gist may not work perfectly but it should be a good starting > point. > > > > You will want to spend some time to review the CMake documentation[1] for > how to set the include and link properties for your project as there are > many more details that cannot be covered here. > > > > As far as CLion is concerned, I'm not sure how to get it working, but > based on the blog link that you shared, the first step seems to be to tell > CMake to configure your build with the correct compiler[2]. > > > > [1] https://cmake.org/cmake/help/latest/module/FindBoost.html#examples > > [2] https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER.html > > > > > > On Thu, Jan 20, 2022 at 1:33 PM <chi...@ya...> wrote: > > Hi Jonathan > > > > Thank you for your kind advice. I already have inserted the macros below. > Based on Luigi’s reply, it seems the Boost headers alone are sufficient (if > I am not building the test-libraries) and that’s works fine for me in CLion > as well. So now my focus is to build Quantlib using mingw in CLion. > > > > Can you please recommend how I can modify the existing CMake file to build > Quantlib using CMake ? > > > > i) Do I modify the existing CMakeLists.txt file that comes > with Quantlib with recommendations from Dimitri’s blog ? Or write a new > CMake file ? > > > > https://blog.jetbrains.com/clion/2015/12/quantlib-clion/ > > > > > > > > Option 2: (since everything works fine in Visual Studio, I thought of > trying my luck) > > > > I switched the compiler itself in CLion from my default mingw to Visual > Studio 2017. I then modified the CMakeLists.txt file(which is attached in > this email) but it doesn’t work > > as in the main.cpp the #include <ql/quantlib.hpp> can’t find it > > > > fatal error C1083: Cannot open include file: 'ql/quantlib.hpp': No such > file or directory > > NMAKE : fatal error U1077: > 'C:\PROGRA~2\MIB055~1\2017\COMMUN~1\VC\Tools\MSVC\1416~1.270\bin\Hostx86\x86\cl.exe' > : return code '0x2' > > Stop. > > NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual > Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\nmake.exe"' > : return code '0x2' > > Stop > > > > Thank you for your kind help > > > > > > > > *From:* Jonathan Sweemer <sw...@gm...> > *Sent:* Wednesday, January 19, 2022 8:34 PM > *To:* Chirag Desai <chi...@ya...> > *Cc:* qua...@li... > *Subject:* Re: [Quantlib-users] Quantlib in CLion > > > > Hi Chirag, > > > > The first step is to successfully build Boost using a toolchain compatible > with CLion. I have never done this before but the StackOverflow link you > pasted seems to provide reasonable instructions. > > > > Once you have built Boost, then you can use the BOOST_INCLUDEDIR, > BOOST_LIBRARY_DIR, and/or BOOST_ROOT variables to tell CMake where to > find the Boost installation when configuring QuantLib. See [1] for more > details on these variables. > > > > Regarding whether a header-only Boost installation is sufficient, > unfortunately no, QuantLib still depends on some pre-compiled Boost > libraries, but this may change in the future. See [2] for the latest list > of Boost library dependencies. > > > > [1] https://cmake.org/cmake/help/latest/module/FindBoost.html > > [2] https://github.com/lballabio/QuantLib/blob/master/CMakeLists.txt#L118 > > > > > > > > On Wed, Jan 19, 2022 at 8:16 PM Chirag Desai via QuantLib-users < > qua...@li...> wrote: > > Hi Quantlib Users > > > > Hope all is well. I am trying to get more involved in the Quantlib project > with my interest in quantitative finance. > > > > I have been able to get it to work in Windows VS2017 but I am trying to > make it work in CLion using CMake with no success. > > > > 1) I can't even get Boost to compile in CLion using CMake. I am only able > to use the header only Boost files in CLion > > > > https://stackoverflow.com/questions/36519453/setup-boost-in-clion > > > > 2) I tried following this blog by Dimitry but I guess I first need to make > Boost work (or are the header only Boost files sufficient ?). The > instructions are not very clear. > > > > https://blog.jetbrains.com/clion/2015/12/quantlib-clion/ > > > > May I kindly check if this is something somebody can guide me on please ? > > > > Thank you for your guidance > > Chirag > > > > _______________________________________________ > QuantLib-users mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-users > > |