0

I wrote a short program to measure the performance of a function. The code looks like this:

#include <iostream>
#include <chrono>

int main()
{
    auto start = std::chrono::high_resolution_clock::now();

    // Here is the test function

    auto end = std::chrono::high_resolution_clock::now();

    std::chrono::duration<double> elapsed = end - start;

    std::cout << result;
    std::cout << elapsed.count();
}

When I compile the code and start the .exe I get the following error:

The procedure entry point "_ZNSt6chrono3_V212system_clock3nowEv" could not be located in the dynamic link library "/my/path/main.exe".

I use MinGW to compile my code. I've already uninstalled MinGW and also deleted the environment variable.

The code works fine when I don't use the library.

Neal Mc Beal
  • 245
  • 3
  • 16
  • Try creating a simple batch file containing something like "echo 'test'" save it in the same location as your dll, then go to your application folder and type the name of the batch file, if it doesn't work then the path isn't set-up correctly. – SPlatten Oct 01 '19 at 12:46
  • @SPlatten: That's fairly bad advice. On Windows, you really should not need to set up the global search path. However, if you use DLL's with your EXE, you should install them all in the same folder. – MSalters Oct 01 '19 at 12:55
  • Hello u2. Since I'm a C++ beginner I'm not sure what you exactly mean @SPlatten. My environment variable is set under PATH to C:/MinGW/bin. – Neal Mc Beal Oct 01 '19 at 12:56
  • @Ted Lyngmo Since this program is really simple compile with g++ -o main.exe main.cpp. Not additional attributes. – Neal Mc Beal Oct 01 '19 at 12:56
  • @MSalters, the point was to test if the system could find the file. – SPlatten Oct 01 '19 at 12:57
  • @MSalters Ty for the solution. The link to the duplicate solved my problem. It works with -static-libstdc++ but can you tell me how to change it? I don't want to write all the time -static-libstdc++ if there is an easy change. – Neal Mc Beal Oct 01 '19 at 13:03
  • @NealMcBeal: Normally, you don't write that every time because compile settings are stored in some sort of build system, e.g. CMake. – MSalters Oct 01 '19 at 13:11

0 Answers0