to calculate option price which use QuantLib,but QuantLib do not supported in goland.
"QuantLib is written in C++ with a clean object model, and is then exported to different languages such as C#, Java, Python, R, and Ruby."
https://www.quantlib.org/
QuantLib is exported to different languages using SWIG, which generates the necessary wrapper code. Unfortunately, SWIG for Go does not support the shared_ptr class, which is used everywhere in the interfaces. Therefore, QuantLib cannot support Go until this changes.
There is an issue open for SWIG on GitHub to add this feature (see https://github.com/swig/swig/issues/2030) but no working contributions so far.
Related
I'm trying to build a project which depends heavily on GalSim and is very time-consuming. I've tried the Python API and Numba decorators, but none of them is satisfying. So I want to call GalSim routines in C++. However, I can not find any instructions on how to build a C++ library from source code. I guess that is possible given that C++ source code and headers are already there. Does anyone know how to do that?
Thanks!
I'm trying to use LLVM to implement a compiler for a toy language. Something like the Kaleidoscope Tutorial. I'm using Visual Studio on 64 bit Windows.
I've managed to build LLVM and clang using VS, but now I want to use the LLVM libraries in my own project. It seems like a silly question but how to I do this? What compiler options do I need? What libraries should I link with etc. etc.
As far as I can see this isn't covered anywhere in the LLVM documentation although I could have easily missed it.
I discovered llvm-config which is designed to solve the problems I'm having. It often seems to give incorrect information (for instance llvm-config --includedir is wrong) but it at least gives me a list of libraries to link with.
I suppose I could also use CMake to generate project files, but CMake seems to be difficult to learn from free resources.
Ubuntu 16.04 comes with GCC 5.4 which does support c++11 and it is the default compiler. By default c++11 is not enabled in that particular version of GCC.
My intent is to use some of the binary libraries (not header only) from their repository (e.g. boost). In my projects I will enable c++ 11.
How were c++ libraries from the repository compiled? Is it possible to use them with c++ 11 enabled? I know that c++ libraries can be called from different languages (Java, Pythons, C# etc) by hiding all c++ stuff behind plain C interface. With boost it is not a case. If a certain function returns me a string or a vector or anything from STL then it is a problem. AFAIK STL objects binary representation depends on compiler flags (eg. std=c++11).
Thank you.
Which exact libraries are you talking about?
If you are talking about the standard library, libstdc++ is a part of gcc. It is always okay to link it no matter which standard you compile at. gcc also made a decision to include ABI tags, so that they can be ABI compatible with code compiled at C++11 and pre C++11. See for instance TC's really nice answer to a question I asked here:
Is this simple C++ program using <locale> correct?
If by
How were c++ libraries from the repository compiled?
you mean, how are all of the C++ libraries in the ubuntu repositories compiled, the answer is, it may be different for each one.
For instance if you want to use libfreetype6-dev or libsdl2-dev, these are C libraries, they will be okay to link to no matter what standard you target.
If you want to use libsilly-dev from CEGUI, that is a C++ library, and it is usually best to use the exact same compiler for your project and the C++ lib that you are linking to. If it appears in ubuntu repository, you can assume it was built with the default g++ version that ubuntu is shipping. If you need to use a different compiler, it's probably best to build the C++ lib yourself -- in general C++ is not ABI stable across different compilers, or even different versions of the same compiler.
If you want to use compiled boost libraries, it's probably best to use the libs they give you and use the compiler they give you. If you only use header-only boost, then the compiler doesn't matter since you don't actually have to link with something they built. So you then have more flexibility with respect to compilers.
Often, if you need to use C++ libraries, it's best to integrate their build system into yours so that it can be easily rebuilt from source and you only have to configure the compiler once. (At least in my experience.) This can save a lot of time when you decide to upgrade compilers later. If you use cmake then it's often feasible, but sometimes this can be hard, especially if you have a lot of C++ dependencies. If you don't use cmake, well, many libraries use cmake and it won't be that easy to integrate them this way. cmake is still kind of a pain anyways, so this might not be such a loss.
Is there a way of doing this?
Develop a library L1 written in Golang. L1 exports functions for C language.
Build L1 and generate .lib file for Visual C++.
Use L1 from Visual C++ code by calling C functions in L1.
I've never tried, and I'm using linux, but here is what I know:
According to the golang documentation you can compile go code into shared library (see go help buildmode also).
To be able to call go function from c code, go function shall be exported.
In order to compile your go code into a shared library, you need to get the go standard library into a shared one too:
go install -buildmode=shared std
This will compile all the go standard code into libstd.so (on linux, the name might change on windows).
And finally, you can use the following command to get your shared library:
go install -buildmode=shared -linkshared [packages]
The standard shared library can be found in:
GOROOT/pkg/GOOS_GOARCH_dylink/
and your shared library under:
GOPATH/pkg/GOOS_GOARCH_dylink/
That is for the go part.
Now, if you want to call this code from a C++ project, you'll need to create the C library that wraps the go library. You can use some tool for that (I've heard about SWIG, but never tried).
EDIT: You can do something similar with static go library, but since you did not specify the library type and you will use it from C++ code, I suppose you need a shared library.
I came across Microsoft's Portable Library Tools add-in for Visual Studio, but I see System.Xml.Linq is not in the supported list at this time (but does exist on my target platforms).
Knowing that I'm going to have to do some work myself to get multi-platform linq to xml support, does the PLT add-in do anything else for me?
The goal for portable library tools is to have the minimun set of dependencies in order to allow you to create a cool library for different type of projects. The idea is to not to have dependencies in this kind of library, just Dto, Model and some similar stuff are good examples of use