0

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:

close.cpp line 56

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 :(

Anton Krouglov
  • 3,077
  • 2
  • 29
  • 50
  • Are you building the MSVC project in Debug mode or in Release mode? Whichever one, then maybe try the other? (Looks like you're in debug mode, from the shown error; the CUDD dll may demand only release-mode clients.) – Adrian Mole Sep 02 '23 at 15:11
  • Further, I think that, even if both DLL and EXE are built in "debug" mode, you won't necessarily have ABI compatibility between them, in terms of the debugger-mode additions. (Not sure, though.) In "release" mode, you should have ABI compatibility, if both are correctly targeted for the same Windows platform. – Adrian Mole Sep 02 '23 at 15:28
  • @AdrianMole indeed, it does not assert when running release config with MSVC; still output file is empty. Using stdout instead of file produces no output as well. – Anton Krouglov Sep 02 '23 at 15:40
  • What's the return value of the call to `Cudd_DumpDot()`? Should be `1` (success) or `0` (failure); if the latter, there's likely a `Cudd_xxx` call to get info on the error. – Adrian Mole Sep 02 '23 at 15:45
  • @AdrianMole it returns 1 when configuration is Debug; Release build fails at this call: `(process 16864) exited with code -1073740791`. It is C0000409. It is security exception. It have had said me that fopen is unsecure. So std lib calls are not working at MSVC? – Anton Krouglov Sep 02 '23 at 16:09
  • @AdrianMole print_dd function from same tutorial does work at both Release and Debug config – Anton Krouglov Sep 02 '23 at 16:18
  • I very much doubt you can pass a `FILE *` from MSVC code to MinGW code. They use different runtime libraries. – Paul Sanders Sep 02 '23 at 21:58

0 Answers0