CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    May 2007
    Posts
    8

    Debugging a C# program that launches a Cygwin application

    Dear all,

    I have a program whose output depends on launching tleap, a non-Windows program that I have compiled for/with Cygwin. The relevant code is as follows:

    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Diagnostics;
    using System.IO;
    using System.Threading;
    
    namespace cyg_test
    {
        class Program
        {
            static void Main(string[] args)
            {
               string teLeap = "E:\\Cygwin\\home\\Danja\\Science\\amber11_surface\\bin\\teLeap.exe";
               List<string> argus = new List<string>();
    
                ProcessStartInfo run = new ProcessStartInfo();
                run.FileName = teLeap;
                argus.Add("-f");
                argus.Add("/home/blah.sh");
                Process MyProc = new Process();
                run.Arguments = string.Join(" ", argus.ToArray());
                using (Process process = Process.Start(run))
                {} // will put code in brackets
                Console.ReadLine();
            }
    When I execute this code by running my compiled program outside of the debugger, it works just fine. I get a "leap.log" file indicating that the program executed my blah.sh script. However, when I run the same program via the debugger, I get a popup window with the title "teLeap.exe - System Error" and contents "The program can't start because cygwin1.dll is missing from your computer."

    I googled the problem and found the solution of setting the "PATH" environment variable to the Cygwin bin directory. After I did this I was able to run the program as described above, but it didn't fix the problem of running it through the debugger. I would really like to be able to do this because I have a lot of code downstream of this function that I'd like to debug.

    Thanks a lot for any help,

    Dan

    Edit: I'm using Visual Studio 2012, .NET4.5
    Last edited by Danja; June 30th, 2013 at 12:23 AM.

  2. #2
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: Debugging a C# program that launches a Cygwin application

    If the application you try to debug is built with something else than MSVC you can't debug it in MSVC (unless that other thing really is MSVC compatible). Or more correct, you might be able to debug without any symbols if it's a windows application but in this case it's not. Since it's a cygwin application you have to use gdb.
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  3. #3
    Join Date
    Jun 2013
    Posts
    2

    Re: Debugging a C# program that launches a Cygwin application

    truyen sex dÃ*nh cho người đã trưởng thÃ*nh
    chú ý: chuyên mục truyện người lớn chỉ dÃ*nh cho 18+ mới được vÃ*o

  4. #4
    Join Date
    May 2007
    Posts
    8

    Re: Debugging a C# program that launches a Cygwin application

    Quote Originally Posted by S_M_A View Post
    If the application you try to debug is built with something else than MSVC you can't debug it in MSVC (unless that other thing really is MSVC compatible). Or more correct, you might be able to debug without any symbols if it's a windows application but in this case it's not. Since it's a cygwin application you have to use gdb.
    I don't need to debug it though; I already know that it works. All I want is for it to run as normal when I call it from my code. Is this not possible as well?

  5. #5
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: Debugging a C# program that launches a Cygwin application

    If teLeap.exe successfully starts from a windows shell (cmd.exe) it should be possible to run it from the debugger as well. Have you restarted MSVC after updating the environment?
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured