
Since you're trying to build C++ code as an extension to MonetDB, you will need to build outside of the MonetDB sources. The MonetDB build system does not support building from C++. This means that you do not need to change any MonetDB sources at all. In fact, you don't need those sources to build your extension. You can just install the binary packages using apt-get, including a few dev packages (see below). On 04/01/2015 10:37 AM, Jiří Nádvorník wrote:
Hi Sjoerd, Alastair,
There is a chance that you could compile your UDF as a standalone shared lib with the C++ compiler with the top level interfaces declared extern "C" but I couldn't be sure it would work.
You should also be able to build MonetDB yourself and point to that for compilation of extra stuff. Just point the PKG_CONFIG_PATH environment variable to the directory where monetdb*.pc are installed before calling make in the directory with the above Makefile. You do need the program pkg-config somewhere in your search path.
Do I understand it correctly? The second paragraph tells, that I don't need to wrap the c++ code in C functions, but I can use a simple (g++) Makefile in my UDF folder?
I didn't address the issue of C stubs for C++ code. You do need something like that. The calling interface from the MAL interpreter to your code is based on the C calling interface and it uses the C name of the function that you create (and reference in your *.mal file using the "address" directive).
I don't quite get what do you mean by "the above Makefile". Is it the make used for the whole build in the MonetDB root folder (used with the configure)? Do I need to alter that configure script too?
The Makefile snippet that was included in my earlier message, quoted below.
If you install the development packages of MonetDB (on Fedora that is MonetDB-devel MonetDB5-server-devel MonetDB-stream-devel) you can compile outside of the MonetDB source tree using a quite simple Makefile.
So I need to install a package from apt-get? I thought I am installing from the sources via make install?
If you want to build outside the MonetDB sources, yes. Install monetdb5-server-dev, libmonetdb-stream-dev, libmonetdb-dev.
And what about the bootstrap script which should find my UDF? How will that function?
If you go for adding your code to the MonetDB source tree, then you should only need to change a Makefile.ag. However, the bootstrap stuff does not support creating a Makefile from a Makefile.ag for compiling C++ code. So that makes it a lot more complicated nd is therefore not recommended (by me).
Thank you very much for clarification.
Cheers,
Jiri
-----Original Message----- From: users-list [mailto:users-list- bounces+nadvornik.ji=gmail.com@monetdb.org] On Behalf Of Sjoerd Mullender Sent: 31. března 2015 19:41 To: users-list@monetdb.org Subject: Re: C++ user defined function
If you install the development packages of MonetDB (on Fedora that is MonetDB-devel MonetDB5-server-devel MonetDB-stream-devel) you can compile outside of the MonetDB source tree using a quite simple Makefile. Some key contents for the Makefile are (assuming there is a source file reverse.c and some .mal and .sql files that need to be installed):
LIBDIR = `pkg-config --variable=libdir monetdb5` CFLAGS = `pkg-config --cflags monetdb5` LDFLAGS = `pkg-config --libs monetdb5` lib_reverse.so: reverse.o $(CC) -fPIC -DPIC -o lib_reverse.so -shared reverse.o $(LDFLAGS) - Wl,-soname -Wl,lib_reverse.so reverse.o: reverse.c $(CC) -fPIC -DPIC $(CFLAGS) -c reverse.c install: lib_reverse.so cp reverse.mal lib_reverse.so $(LIBDIR)/monetdb5 cp 80_reverse.sql $(LIBDIR)/monetdb5/createdb cp 80_reverse.mal $(LIBDIR)/monetdb5/autoload
You should also be able to build MonetDB yourself and point to that for compilation of extra stuff. Just point the PKG_CONFIG_PATH environment variable to the directory where monetdb*.pc are installed before calling make in the directory with the above Makefile. You do need the program pkg-config somewhere in your search path.
On 03/31/2015 06:24 PM, Alastair McKinley wrote:
If you can separate the usage of MonetDB provided includes and functions from your core UDF logic you could build a small wrapper in C that links to a shared lib built with C++ with your interfaces declared extern "C".
There is a chance that you could compile your UDF as a standalone shared lib with the C++ compiler with the top level interfaces declared extern "C" but I couldn't be sure it would work.
Best regards,
Alastair
The resulting shared library should be loadable.
On Tue, 2015-03-31 at 17:50 +0200, Jiří Nádvorník wrote:
Hi,
I’m trying to write a function in C++ and I thought I would just provide a makefile for it in my custom folder in MonetDB/sql/backends/monet5/CUSTOM. But it seems like all of the Makefiles in UDF sample are generated by the bootstrap.
How do I get over this? I need to use external C++ libraries in the makefile..
Thank you for help.
Best regards,
Jiri Nadvornik Astronomical Institute AV CR Stellar department Czech Republic nadvornik.ji@gmail.com
_______________________________________________ users-list mailing list users-list@monetdb.org https://www.monetdb.org/mailman/listinfo/users-list
_______________________________________________ users-list mailing list users-list@monetdb.org https://www.monetdb.org/mailman/listinfo/users-list
-- Sjoerd Mullender
_______________________________________________ users-list mailing list users-list@monetdb.org https://www.monetdb.org/mailman/listinfo/users-list
-- Sjoerd Mullender