Search code examples
c++eclipsewindows-7visual-studio-2015ampl

MVCP100D.dll missing when running exe file generated by C++ code in Eclipse


I am trying to integrate AMPL with C/C++ using AMPL-API. I created a Makefile project in Eclipse which uses MinGW CC to compile the code.

Here is my C++ code:

#include <iostream>
#include "ampl/ampl.h"

using namespace std;

int main() {
    ampl::AMPL ampl;

    // Read the model and data files.
    std::string modelDirectory = "models";
    ampl.read(modelDirectory + "/diet/diet.mod");
    ampl.readData(modelDirectory + "/diet/diet.dat");

    // Solve
    ampl.solve();

    // Get objective entity by AMPL name
    ampl::Objective totalcost = ampl.getObjective("total_cost");
    // Print it
    std::cout << "Objective is: " << totalcost.value() << std::endl;
}

Following is my Makefile:

CC = g++
CFLAGS = -O2 -g -Wall -fmessage-length=0
INCLUDES = -I "C:\\Local\\AMPL\\amplide.mswin32\\amplide.mswin32\\amplapi\\include"
OBJS = AMPL.o
LIBS =  -lampl1.2.2 
TARGET = AMPL.exe
$(TARGET):  $(OBJS)
    $(CC) -L "./" -o $(TARGET) $(OBJS) $(LIBS)
AMPL.o: AMPL.cpp
    $(CC) $(CFLAGS) $(INCLUDES) -c AMPL.cpp
all:    $(TARGET)
clean:
    rm -f $(OBJS) $(TARGET)

Contents of my project directory are:

  • .settings/
  • models/
    • diet/
      • diet.dat
      • diet.mod
  • .cproject
  • .project
  • AMPL.cpp
  • AMPL.exe
  • AMPL.o
  • ampl1.2.2.lib
  • Makefile

I am having a 32-bit Windows 7 machine which have both Eclipse Mars 2.0 and Visual Studio 2015 installed on it. Whenever I run exe file, it says MVCP100D.dll is missing. I looked on web and found that this error generally comes when Visual C++ Redistributable are missing. But my system has redistributable installed on it. Please help me with this.

Update: I tried to execute same code over Visual Studio 2015 and there also it is able to compile, however, I am unable to run *.exe file. It also says MVCP100D.dll is missing. I am not sure why this error is coming, please help!!

Update: Downloading the updated version works in Visual Studio 2015 but facing a separate problem specified in other post: Undefined reference to (error) in C++ Eclipse but working in Visual Studio 2015


Solution

  • This is a bug in the beta version of the AMPL C++ API. As a quick fix, the updated distribution available for download from http://ampl.com/products/api includes these DLLs. A permanent fix will be available in the next corrective release.