0

I have a problem when i try to use function from my dll

I did everything as it says here: https://learn.microsoft.com/en-us/cpp/build/walkthrough-creating-and-using-a-dynamic-link-library-cpp?view=vs-2019

But when i'm trying to run the test app, i get the following error messages:

img1

img2

Here is my whole code:

test.cpp:

#include "pch.h"
#include <iostream>

#include "SP_DLL.h"

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

int main()
{
    symbol_count();
}

dlltest.h:

#pragma once

#include <iostream>
using namespace std;

extern "C" _declspec(dllexport) bool symbol_count();

dlltest.cpp:

#include "pch.h"
#include "SP_DLL.h"

bool symbol_count()
{

    char str[100];
    char symbol;
    size_t count = 0;

    cout << "Enter string: ";
    cin >> str;

    cout << endl << "Enter symbol to count: ";
    cin >> symbol;

    for each (auto el in str)
        if (el = symbol) count++;
    return true;
}

If it helps: when i'm trying to run empty symbol_count() (func have only code {return true;} and dll have no includes) there is the only one .dll not found.

SageCat
  • 315
  • 1
  • 13
  • The error message you've linked suggest that you haven't installed the necessary run-time support background on the target PC. Maybe see [here](https://stackoverflow.com/questions/58336827/how-to-run-a-c-program-i-wrote-on-another-computer/58336900#58336900) for some guidance. – Adrian Mole Nov 07 '19 at 16:05
  • @Adrian-ReinstateMonica, thanks for your message, but no. I'm runing app from VS using ctrl+F5. This problem only refers to running an app with dll reference. When i run standart apps everything is fine – SageCat Nov 07 '19 at 16:42
  • I suggestyou could try to downloaded the installed packages from [C++ Runtime v14 framework package for Desktop Bridge (Project Centennial)](https://www.microsoft.com/en-us/download/details.aspx?id=53175),which provided the "msvcp140_app.dll". And then copied "msvcp140_app.dll" from the "C:\ProgramFiles\WindowsApps\Microsoft.VCLibs.140.00____8wekyb3d8bbwe " directory, placed it into your project folder. – Jeaninez - MSFT Nov 08 '19 at 02:25
  • @Jeaninez-MSFT, oh, thank you, it's working! – SageCat Nov 08 '19 at 08:37

1 Answers1

0

I suggestyou could try to downloaded the installed packages from C++ Runtime v14 framework package for Desktop Bridge (Project Centennial),which provided the "msvcp140_app.dll". And then copied "msvcp140_app.dll" from the "C:\ProgramFiles\WindowsApps\Microsoft.VCLibs.140.00____8wekyb3d8bbwe " directory, placed it into your project folder.

– Jeaninez - MSFT Nov 8 at 2:25

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
SageCat
  • 315
  • 1
  • 13