My C/C++ perks are a bit rusty. Last time I have used them like 30 year ago :)
I have CUDD library built from sources at Win10 using MINGW64 environment from MSYS2.
git clone https://github.com/ivmai/cudd.git
cd cudd
autoreconf -f -i
mkdir build
cd build
../configure "CFLAGS=-fPIC -std=c99" --enable-silent-rules --enable-shared --enable-dddmp --enable-obj --prefix=/home/Anton/cudd.no_target/cudd/build
make -j4
make check
make install
I am following CUDD tutorial with Visual Studio 2022 as per this guide. Cudd is linked as DLL because static linking gives errors.
This code fails with assertion at fclose
:
/**
* Writes a dot file representing the argument DDs
* @param the node object
*/
void write_dd (DdNode *dd, char* filename)
{
FILE *outfile; // output file pointer for .dot file
outfile = fopen(filename,"w");
DdNode **ddnodearray = (DdNode**)malloc(sizeof(DdNode*)); // initialize the function array
ddnodearray[0] = dd;
Cudd_DumpDot(gbm, 1, ddnodearray, NULL, NULL, outfile); // dump the function to .dot file
free(ddnodearray);
fclose (outfile); // close the file */}
}
Assertion:
Same code compiles and runs without any problem when using gcc.
I have tried to compile and run CUDD tests. MSVC rains with I/O assertions. GCC works fine.
What am I missing?
My goal is to write a .NET wrapper for CUDD as existing one (PATBDD) is missing both ADD and DDDMP functions.
There are no .NET-native binary decision tree/diagram libraries with basic functions like BDT->ROBDD, manual/dynamic variable reordering etc :(