include c++ source files in a max external java project

Tiago Morgado's icon

hi guys

I would like to add a c++ source file to a java max external project and call it in the main file..
do you guys know a way to do such a thing..

greets
tiago morgado

efe's icon

You will need to rewrite the file. But not worries, from c++ to java is quite straight forward.

Hans Höglund's icon

You could also use the max messaging system (create a symbol in C++ and send messages to it from Java). This would of course require some knowledge of C++.

Roth's icon

I have not done it myself but know people who have: it is possible to create bindings to a compiled C library to call from your Java code. A quick google serach of "using c in java" seems to bring up some possibly helpful results.

Hans Höglund's icon

@Roth Indeed, this is possible using the Java Native Interface which allows a java to link to native code dynamically and vice versa. However, Max java objects already run inside a JVM created by Max. To communicate with Max externals you would need to send messages to symbols (see the SDK for details).

Tiago Morgado's icon

@ Roth @ Hans Höglund - thank you so much for the helpful tips.. In fact I am creating a database of math expressions in order to optimize non-linear situations, etc. I've coded mandelbrot, fibonacci, etc. I will code some more fractals, I will code some graphs, maybe some system for balancing of permutations (I don't know if you guys know something more specific about it).. and I want to pick up andré siers source code files in c++, from chaos-lib, in order, to include his externals in my database.. of course I will give him and the source code authors proper credit but there are actually a lot of work already done there.. and I would like to take advantage of it, once it is open source.. my object will probably be open source too

Tiago Morgado's icon

so that I can then, use neural networks, to optimize all the values for the expressions, and drive them in non linear situations for generative purposes