Open skariel opened 9 years ago
There are no symbols exported in the code, I just checked with DLL export viewer. I manually exported the exactinit
function with __declspec(dllexport)
and although DLL export viewer does see it, Julia cannot find it. Maybe CL or MingW will work.
This seems to work:
#include "tetgen.h"
extern "C"{
__declspec(dllexport) void __cdecl tetrahedralize(char *switches, tetgenio *in, tetgenio *out);
}
__declspec(dllexport) void __cdecl tetrahedralize(char *switches, tetgenio *in, tetgenio *out){
tetrahedralize("pq1.414a0.1", in, out);
}
This should be sort of what we want right? I uploaded the x64 dll for you to try out.
julia> hdnl = dlopen("TetGenC")
Ptr{Void} @0x000000000414f190
julia> dlsym(hdnl, :tetrahedralize)
Ptr{Void} @0x00007ff9be531000
Should I upload the whole solution file?
yes please upload the VS solution, we have to make this work also with Makefiles right?
I'll start thinking of what functions we should export by looking at the tetgen command line tool, I believe only a few functions will give most of the needed functionality.
Done! Yes, they have a very simple API.
The function "tetrahedralize()" is the sole interface you need to know for calling TetGen in your program. It is declared in tetgen.h as follow: void tetrahedralize(char switches, tetgenio in, tetgenio *out); The parameter "switches" is a string containing the command line switches for this call. In this string, no initial dash '-' is required. The `Q' (quiet) switch is recommended in the final code. The parameters "in" and "out", which are two pointers pointing to objects of "tetgenio", describing the input and the output. "in" and "out" may never be null pointers.
We also might need to export some functions for creating the tetgenio objects. And then we should create Julia functions for each commandline switch, so that we can call it simply with arrays of points and what not.
I just added a makefile, it works also on Linux with the same source. We should rename and maybe restructure the folders so it is obvious that both VS and GCC build from same sources. Currently makefile
is inside the VS solution sources...
anyway, it works.
see here:
awesome! so the biggest remaining problem is, how to nicely wrap tetgenio.
note that in Linux the function has a leading underscore, it is called _tetrahedralize
So in the Julia code we'll need to test for Windows/Linux and call the correct function (unless we somehow fix it in the cpp side...)
Do you mean the tetgen library exports a different name for linux/windows?
I wasn't sure if you can overload tetrahedralize
with a C function with the same signature, so I changed the name in the wrapper (for both windows+linux).
We should probably rather call it c_tetrahedralize
, to make it more clear what's going on.
ahh OK, so its the same name for both. I didn't notice you changed them :)
I'll rename them to c_*
Sorry for the confusion!
How did you test this? This is a C++ library (which I totally forgot at first), so we shouldn't find the symbols with dlsym.