Compiling MIDACO with MS Visual Studio C/C++
Compiling MIDACO with MS Visual Studio in C/C++ is easy. Below you can find a detailed instruction.
Note: Some MS Visual Studio versions treat the fopen command as error and expect fopen_s instead.
A small modification in the midaco.c source code is then required to compile MIDACO in MS Visual Studio.
Step 1: In the midaco.c file, change the fopen command to fopen_s by commenting out line 5002 and enabling line 5003 instead. The result should look like following:
Step 2: The example benchmark problems (e.g. example_MINLPc.cpp) execute very fast (below 0.1 second). By default, the example problems do not have a "pause" command at the end of execution. Therefore, running the example problem in MS Visual Studio will cause the console window to shut down very quickly. In order to pause the console window, add the following command at the end of the example problem source code:
printf("\n Pause"); getchar();
Note that the printf and getchar() command will require to include stdio.h and stdlib.h like this:
#include <stdio.h>
#include <stdlib.h>
Step 3: Open MS Visual Studio and create new project Win 32 Console Application (Visual C++)
Step 4: Select Next > (Application Settings)
Step 5: Select Empty project and Finish
Step 6: Add midaco.c and some example as Exisiting item to source files
Step 7: Build and debug / run as usual
Hint 1: You may find the MIDACO text output files in the MS Visual Project Debug or Release folder.
Hint 2: You may use the MS Visual Studio project preferences for -O3 compilation [ contact us for details ]
Hint 3: You may use the Intel Fortran compiler instead of visual C++ analog to above description.
Hint 4: In case the following error appears:
“LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup”
it can be easily fixed by changing VS: Properties -> Linker -> System -> SubSystem from Windows to Console
(/SUBSYSTEM:WINDOWS) >>>---change---to--->>> (/SUBSYSTEM:CONSOLE)