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 mailto:nadvornik.ji@gmail.com nadvornik.ji@gmail.com
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
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
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 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?
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? And what about the bootstrap script which should find my UDF? How will that function? 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
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
Hi Sjoerd,
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).
I have a Makefile for the C++ code which does not use MonetDB libraries atm. I can imagine I will add some library calls to the code and add them to that Makefile, so I will have a my_function_xyz.so library with the .mal and .sql files attached. But how do I let the SQL interpreter know that there is a function called my_function_xyz, when I don't tell him via the bootstrap?
So that makes it a lot more complicated nd is therefore not recommended (by me). This means not using the bootstrap, or not including C++ code to the MonetDB at all?
Thank you very much for patience with me :). Cheers, Jiri
-----Original Message----- From: users-list [mailto:users-list- bounces+nadvornik.ji=gmail.com@monetdb.org] On Behalf Of Sjoerd Mullender Sent: 1. dubna 2015 11:12 To: users-list@monetdb.org Subject: Re: C++ user defined function
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
There are two steps to making an extension visible to the SQL front end of MonetDB. In the lib/monetdb5/autoload directory are *.mal files that get executed whenever the server starts up. Since they are executed in ASCII order, the files there start with a number to force the ordering. Put your .mail file there. It should probably contain something like "include module;" where module is the name of your extension module. You then need two more files in lib/monetdb5: module.mal that contains the MAL code, and lib_module.so that contains the (compiled of course) C or C++ code. Look at other files there and at the UDF example for inspiration. This part so far is for the MAL interpreter. You also need to tell the SQL front end. This is done by adding an .sql file to the lib/monetdb5/createdb directory. The files in there get executed only when a new database is created. Again, look at the UDF example for inspiration as to what to put in your .sql file. The upshot is that once you've done this, newly created database will have access to your extension. In order to add your extension to existing database, restart the server (so that it reads the new .mal files in .../autoload), then manually execute the contents of the .sql file that you added in the .../createdb directory. On 04/01/2015 11:25 AM, Jiří Nádvorník wrote:
Hi Sjoerd,
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).
I have a Makefile for the C++ code which does not use MonetDB libraries atm. I can imagine I will add some library calls to the code and add them to that Makefile, so I will have a my_function_xyz.so library with the .mal and .sql files attached.
But how do I let the SQL interpreter know that there is a function called my_function_xyz, when I don't tell him via the bootstrap?
So that makes it a lot more complicated nd is therefore not recommended (by me). This means not using the bootstrap, or not including C++ code to the MonetDB at all?
Thank you very much for patience with me :).
Cheers,
Jiri
-----Original Message----- From: users-list [mailto:users-list- bounces+nadvornik.ji=gmail.com@monetdb.org] On Behalf Of Sjoerd Mullender Sent: 1. dubna 2015 11:12 To: users-list@monetdb.org Subject: Re: C++ user defined function
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
_______________________________________________ users-list mailing list users-list@monetdb.org https://www.monetdb.org/mailman/listinfo/users-list
-- Sjoerd Mullender
Aha, Now it starts to make sense. And I do need the dev version of MonetDB to be able to do this? Will I be able to distribute the lib_module.so, my .mal and .sql files with an installation of MonetDB? Or will they have to be copied manually to a new installation. Thank you very much. Cheers, Jiri
-----Original Message----- From: users-list [mailto:users-list- bounces+nadvornik.ji=gmail.com@monetdb.org] On Behalf Of Sjoerd Mullender Sent: 1. dubna 2015 11:48 To: users-list@monetdb.org Subject: Re: C++ user defined function
There are two steps to making an extension visible to the SQL front end of MonetDB. In the lib/monetdb5/autoload directory are *.mal files that get executed whenever the server starts up. Since they are executed in ASCII order, the files there start with a number to force the ordering. Put your .mail file there. It should probably contain something like "include module;" where module is the name of your extension module. You then need two more files in lib/monetdb5: module.mal that contains the MAL code, and lib_module.so that contains the (compiled of course) C or C++ code. Look at other files there and at the UDF example for inspiration. This part so far is for the MAL interpreter. You also need to tell the SQL front end. This is done by adding an .sql file to the lib/monetdb5/createdb directory. The files in there get executed only when a new database is created. Again, look at the UDF example for inspiration as to what to put in your .sql file. The upshot is that once you've done this, newly created database will have access to your extension. In order to add your extension to existing database, restart the server (so that it reads the new .mal files in .../autoload), then manually execute the contents of the .sql file that you added in the .../createdb directory.
Hi Sjoerd,
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).
I have a Makefile for the C++ code which does not use MonetDB libraries atm. I can imagine I will add some library calls to the code and add them to
On 04/01/2015 11:25 AM, Jiří Nádvorník wrote: that Makefile, so I will have a my_function_xyz.so library with the .mal and .sql files attached.
But how do I let the SQL interpreter know that there is a function called
my_function_xyz, when I don't tell him via the bootstrap?
So that makes it a lot more complicated nd is therefore not recommended (by me). This means not using the bootstrap, or not including C++ code to the
MonetDB at all?
Thank you very much for patience with me :).
Cheers,
Jiri
-----Original Message----- From: users-list [mailto:users-list- bounces+nadvornik.ji=gmail.com@monetdb.org] On Behalf Of Sjoerd Mullender Sent: 1. dubna 2015 11:12 To: users-list@monetdb.org Subject: Re: C++ user defined function
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
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
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
can 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 C++ 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
using the "address" directive). 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
_______________________________________________ users-list mailing list users-list@monetdb.org https://www.monetdb.org/mailman/listinfo/users-list
-- Sjoerd Mullender
On 04/01/2015 12:40 PM, Jiří Nádvorník wrote:
Aha,
Now it starts to make sense. And I do need the dev version of MonetDB to be able to do this?
You need the dev packages if you need to include header files and link against the MonetDB library (and you need that if you need to manipulate BATs). So, yes, you need those packages.
Will I be able to distribute the lib_module.so, my .mal and .sql files with an installation of MonetDB? Or will they have to be copied manually to a new installation.
You could create a .deb package yourself and distribute that. Otherwise you'd have to copy the files manually.
Thank you very much.
Cheers,
Jiri
-----Original Message----- From: users-list [mailto:users-list- bounces+nadvornik.ji=gmail.com@monetdb.org] On Behalf Of Sjoerd Mullender Sent: 1. dubna 2015 11:48 To: users-list@monetdb.org Subject: Re: C++ user defined function
There are two steps to making an extension visible to the SQL front end of MonetDB. In the lib/monetdb5/autoload directory are *.mal files that get executed whenever the server starts up. Since they are executed in ASCII order, the files there start with a number to force the ordering. Put your .mail file there. It should probably contain something like "include module;" where module is the name of your extension module. You then need two more files in lib/monetdb5: module.mal that contains the MAL code, and lib_module.so that contains the (compiled of course) C or C++ code. Look at other files there and at the UDF example for inspiration. This part so far is for the MAL interpreter. You also need to tell the SQL front end. This is done by adding an .sql file to the lib/monetdb5/createdb directory. The files in there get executed only when a new database is created. Again, look at the UDF example for inspiration as to what to put in your .sql file. The upshot is that once you've done this, newly created database will have access to your extension. In order to add your extension to existing database, restart the server (so that it reads the new .mal files in .../autoload), then manually execute the contents of the .sql file that you added in the .../createdb directory.
Hi Sjoerd,
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).
I have a Makefile for the C++ code which does not use MonetDB libraries atm. I can imagine I will add some library calls to the code and add them to
On 04/01/2015 11:25 AM, Jiří Nádvorník wrote: that Makefile, so I will have a my_function_xyz.so library with the .mal and .sql files attached.
But how do I let the SQL interpreter know that there is a function called
my_function_xyz, when I don't tell him via the bootstrap?
So that makes it a lot more complicated nd is therefore not recommended (by me). This means not using the bootstrap, or not including C++ code to the
MonetDB at all?
Thank you very much for patience with me :).
Cheers,
Jiri
-----Original Message----- From: users-list [mailto:users-list- bounces+nadvornik.ji=gmail.com@monetdb.org] On Behalf Of Sjoerd Mullender Sent: 1. dubna 2015 11:12 To: users-list@monetdb.org Subject: Re: C++ user defined function
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
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
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
can 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 C++ 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
using the "address" directive). 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
_______________________________________________ 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
participants (4)
-
Alastair McKinley
-
Jiří Nádvorník
-
Martin Kersten
-
Sjoerd Mullender