crosire / blink

A tool which allows you to edit source code of any MSVC C++ project live at runtime
BSD 2-Clause "Simplified" License
1.1k stars 80 forks source link

won't work for a simple test. #30

Closed kalluwa closed 4 years ago

kalluwa commented 4 years ago

environment:

visual studio 2019 std:c++latest

code:

#include <iostream>
#include <windows.h>

void changefunction()
{
    static int n = 0;
    std::cout << n++ << std::endl;
    //std::cout << "add msg" << std::endl;
}
int main(int argc,char** argv)
{

    while (true)
    {
        changefunction();
        Sleep(1000);
    }

    return 0;
}

test step:

  1. blink.exe "C:\Users\kk\source\repos\ConsoleApplication1\x64\Debug\ConsoleApplication1.exe"
  2. uncomment " //std::cout << "add msg" << std::endl;"
  3. save file output:
    
    Launching in target application ...
    Entry point was written to address 0000024D24CE0000
    Reading PE import directory ...
    Reading PE debug info directory ...
    Found program debug database: C:\Users\kk\source\repos\ConsoleApplication1\x64\Debug\ConsoleApplication1.pdb
    Found source file: C:\Users\kk\source\repos\ConsoleApplication1\ConsoleApplication1.cpp
    Starting compiler process ...
    Started process with PID 10532
    Starting file system watcher for 'C:\Users\kk\source\repos\ConsoleApplication1' ...
    Detected modification to: C:\Users\kk\source\repos\ConsoleApplication1\ConsoleApplication1.cpp
    ConsoleApplication1.cpp

Finished compiling "C:\Users\kk\source\repos\ConsoleApplication1\ConsoleApplication1.temp.obj" with code 2.

program output:

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15


nothing changed here, is there any steps wrong?
crosire commented 4 years ago

Visual C++ 2019 unfortunately does not seem to write the target command-line to the OBJ file anymore, so blink cannot reconstruct it and falls back to the default. For that to work you need to run blink from within a Visual Studio developer command prompt (set up with the correct toolset, so e.g. use the "x64 Native Tools Command Prompt for VS 2019" for x64 applications) so that it can find the compiler. With that + the two latest commits that fix some things I can run your example and it works.

kalluwa commented 4 years ago

thanks a lot. it works now with "x64 Native Tools Command Prompt for VS 2019" .

Milerius commented 4 years ago

image

@crosire Same problem here, last version visual studio, last blink with the last commit but still the error occur + i have no details about the error from cl.exe