I used to use Quantlib in Visual Studio on Windows, but recently transferred to Fedora Linux. I watched this video of setting up Quantlib in Eclipse On Ubuntu (https://www.youtube.com/watch?v=4NNc9mZ8Nro), but I noticed that in Fedora I could download and install the compiled rpm files for Quantlib and Boost. I would like to know how I can set up Quantlib in Code Blocks on Fedora 25 using these compiled rpm files.
I haven't used Code::Blocks, but the steps should be the same as for any other library; include in your sources the headers for the features you want to use, link the library with your compiled source, and make headers and libraries available to the compiler.
Starting from the end: the RPMs might have already installed QuantLib header files and libraries where the compiler can find them, so you probably won't have to worry about it. If that's not the case, find out where the RPMs installed QuantLib: headers and libraries might be in /usr/include/ and /usr/lib/, or /usr/local/include and /usr/local/lib. Add the include directory (which must contain the ql folder) to the include search paths for Code::Blocks, and the library directory (which must contain libQuantLib.*) to the library search paths.
The page at http://wiki.codeblocks.org/index.php/BoostWindowsQuickRef shows how to do it for Boost (look under the section "Add Boost search directories to your project"); you can do the same for QuantLib.
Once the search directories are set up, you have to include in your sources the QuantLib headers you need; for instance;
#include <ql/time/date.hpp>
if you want to use the Date class. Finally, add QuantLib to the list of libraries to link to your project. Again, this is done in the same way described for Boost on the page I linked above; look at the section "Include Boost headers and link with Boost libraries".
Related
I'm trying to port my CMake library to mac. I'm linking berkerly DB so I've installed it using brew and I'm able to find the appropriate paths (library, include etc) in cmake. They are
Berkerly
BERKELY_STATIC_LIBRARY /usr/local/lib/libdb.a
BERKELY_lIBRARY /usr/local/lib/libdb.dylib
BERKELY_INCLUDE_DIR /usr/local/include
However, my library doesn't compile because the dependency I am compiling includes db.h
#include <db.h>
which also exists at
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/db.h
and is being used in preference to the one at /usr/local/include. Is it be possible to force CMake to use the db.h from /usr/local/include instead of the other one?
I'm learning to use OpenCV (and C++) in Codeblocks. What confuses me, however, is that when I start to include header files from OpenCV in my main.cpp file, Codeblocks automatically suggests to me the files as shown in the image below.
I have not included any search paths to project build options, so how is this possible that Codeblocks can find the files? Is there some other variable working here that I'm unaware of?
Note that I'm a beginner with both Codeblocks and OpenCV and that I only have a little experience with C++.
Thank you
Of course when you install an IDE like code::blocks by default, it knows about standard path for library on your OS.
On my OS -> Ubuntu that is /usr/include
It only searches on a standard path, except you add one. If you install your library by command-line, it goes to the standard place, if you installed manually, then it depends on your option you added to installation. I can not see you screen-shot but it has access to /usr/include by default.
For more detail on Linux and OpenCV
And here is a screen-shot of codeblock on Ubuntu that I added some 3rd-party library
NOTE:
if you install any libraries by command-line, just use it.
But if you have installed them manually, you need to add 2 things to codeblock.
1. First is your path for header file
2. Second is your path for linker
And you see it in screen-shot that say: Search Directory
First is for header and second is for linker
I followed these instructions to install boost and to compile all libraries:
https://www.quantnet.com/threads/tutorial-quantlib-boost-installation-in-visual-studio-2012.11891/
Boost Installation The Boost library can be downloaded here.
Currently, the latest version available is Boost 1.52.0. You can build
boost by following the instruction here.
Alternative you can download
a pre-built lib from here. Once downloaded, copy the installer into
the Boost 1.52.0 folder and run it. Rename the folder to lib once
done.
So I downloaded boost 1.52, then copied that to C:\Program Files (x86)\boost\
I then downloaded the 1.52 64 bit installer and once downloaded, pasted that to:
C:\Program Files (x86)\boost\boost_1_52_0\boost_1_52_0\
I executed the installer- it said "extracting" and then many library names.
I then renamed the last folder to lib, so that I had:
C:\Program Files (x86)\boost\boost_1_52_0\lib\
In my VS2012 I then added the previous directory to my project. The project then starting parsing through the libraries and I had no linker errors. However, when building the project I still got:
LINK: fatal error LNK1104: cannot open file
'libboost_date_time-iw-mt-gd-1_52.lib'
(The only usage of boost in my project is file_mapping and mapped_region)
Help?
EDIT: I am aware about some libraries needing to be compiled separately in boost. I thought the above was to achieve this? If not, could someone please advise how because this really becomes a pain.
Boost has some libraries (most of them) used as source headers (.h files) that do not need to be pre-compiled, but there are also some libraries that need to be pre-compiled (.lib files). You can either download the libraries pre-compiled from the Boost website (http://www.boostpro.com/download/), although you might get some older versions from there, or compile them (the latest version or any of those available you want) on your own, although please have in mind that this might take some time, depending on your computer specs. See here for more: http://www.boost.org/doc/libs/1_54_0/libs/regex/doc/html/boost_regex/install.html.
After downloading the "normal" boost package, put the folders/files extracted on a folder and then assocciate it in VS2012 by putting the folder path in
(YourProject > Right-Click > Preferences >)General > VC++ Directories > Include Directories.
Then download and install the pre-compiled libraries (extract them on a folder) and then associate this folder with the VS, in
(YourProject > Right-Click > Preferences >) Linker > General > Additional Library Directories.
Of course, as mentioned before, you can also compile the packages you want, and then associate them with Visual Studio the same way.
I'm working on multiple projects at the same time (some libraries, and some games that depend on them). They're all on GitHub, in separate repos.
For convenience, I pull every repo in a "workspace folder", like this:
/home/myWorkspace/Library1/
/home/myWorkspace/Library2/
/home/myWorkspace/Library3/
/home/myWorkspace/App1/
/home/myWorkspace/App2/
I have FindLibrary1, FindLibrary2 and FindLibrary3 .cmake files, which, in order, look for the library in ../ (which corresponds to the "myWorkspace" folder), then /usr/lib/.
While on Windows CMake finds the libraries in myWorkspace/, on Linux, no matter what, installed libraries are always found first.
Since I'd like to work in myWorkspace/ folder, then installing the libraries after I'm done, I'd prefer CMake to find and link everything within the myWorkspace/ folder.
I'd also like CMake to search for the libraries in /usr/lib/ and /usr/local/lib/ if there is no myWorkspace/ folder, but if myWorkspace/ exists, it should have the priority.
Examples of CMake files I'm using:
SSVUtils: library with no dependancies
SSVUtils CMakeLists: https://github.com/SuperV1234/SSVUtils/blob/master/CMakeLists.txt
FindSSVUtils.cmake: https://github.com/SuperV1234/SSVUtils/blob/master/cmake/modules/FindSSVUtils.cmake
SSVUtilsJson: library that depends on SSVUtils and SSVJsonCpp
SSVUtilsJson CMakeLists: https://github.com/SuperV1234/SSVUtilsJson/blob/master/CMakeLists.txt
FindSSVUtilsJson.cmake: https://github.com/SuperV1234/SSVUtilsJson/blob/master/cmake/modules/FindSSVUtilsJson.cmake
Any ideas how I can prioritize the myWorkspace/ folder while still having the possibility to find libs in file system paths?
By default, find_path (or find_library, etc.) first checks for files in the system standard locations, before searching in the values provided in PATH. That's why "installed" libraries are always found first on Linux (but not on Windows, that doesn't have standard locations for installed libraries).
You can disable that behavior by using the NO_CMAKE_SYSTEM_PATH option: it will skip detection of files in standard locations.
Now... if you still want to use the installed libraries as a fallback when local versions are not found, you can do it in a two step process:
find_path(... NO_CMAKE_SYSTEM_PATH)
if (nothing_found)
find_path(...)
endif()
I am using ubuntu 12.04 and it has a version of boost (1.46.1)
installed to /usr/lib and include files in /usr/include.
I have compiled my own version (1.51.1) locally and have been using it fine up until now.
I am working on a new project which is using many includes in /usr/include and libs in /usr/lib so in my include path I have /usr/include and /home/aly/libs/boost/stage/include,
similarly in lib search paths I have /usr/lib and /home/aly/libs/boost/stage/lib. However when I add boost libraries to link it seems to be grabbing them from /usr/lib and it causing my code not to work.
If I remove /home/aly/libs/boost/stage/lib and /home/aly/libs/boost/stage/include
it works fine but now can't use the 1.51 features.
Is there an easy way around this problem?