can't get cygwin to compile
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: can't get cygwin to compile

  1. #1
    Join Date
    Apr 2008
    Posts
    3

    can't get cygwin to compile

    Hello gentlemen,

    I am a retard when it comes to programming, so I'm turning to you smart people to ask a question. I'm trying to use cygwin to compile a program. I can't even get it to compile hello world for me, so I know I'm gonna have trouble with the program I really want. First of all, I need to know why my cygwin isn't compiling for me. I type in g++ helloworld.cpp and it goes through about 500 lines of errors in about 2 seconds and then I don't get any exe file out of it at all.

    Secondly, I want to write a program that will make an LED blink from the printer port on my computer. Let me show you the code and tell me if it will work. I downloaded it from someone's site and modified it for my own purpose. I don't remember where. I want the program to wait 20 minutes then start blinking once every 20 seconds.

    Here's the code:

    //This example code shows how to switch a LED on/off in Visual C++.
    //We use two variables N and L explained below.


    #include <iostream.h> //The most important include to display data on screen.
    #include <conio.h> //Include for outp and inp functions for the printer port.
    #include <windows.h> //For _sleep functions for our time delay.

    #define addr 0x3BC //IMPORTANT: Normaly 378 is the most common address,
    //if not then insert your address instead of 378

    int main()
    {
    int freq; //Variable for time delay.
    int L; //Variable for counts of Blinking LED.
    int wait; //variable for time to wait before starting blinking.
    int length; //Variable for time the LED should remain lit



    L=30; //Blink 30 times
    wait=1200000; //Wait 20 minutes before starting to blink, (in ms)
    freq=20000; //Time to wait between blinks, (in ms)
    length=500; //Time to leave the LED on, (in ms)

    //Bottom code is the Juice! This will blink your LED the number of times you put in L.
    //The speed of blinks will depend on freq. As an example if you entered 500 milliseconds. The LED
    //will blink twice every second since 500 ms is half of 1000 ms (1000 milliseconds = 1sec)

    _sleep(wait);

    for (int i=1;i<=L;i++) //The loop. L times to blink.
    {
    _outp(addr,1); //Output is high in the first 'Data bit' of port(*), i.e Pin number 2 where you have connected the LED.
    _sleep(length); //Length mS delay between the high and low of LED.
    _outp(addr,0); //Output is low now
    _sleep(freq); //Pause again between the high,
    }
    return 0; //main returns nothing to you. ^_^
    }

  2. #2
    Join Date
    Apr 1999
    Posts
    27,427

    Re: can't get cygwin to compile

    Quote Originally Posted by unseen wombat
    Hello gentlemen,

    I am a retard when it comes to programming, so I'm turning to you smart people to ask a question. I'm trying to use cygwin to compile a program.
    This forum is for Visual C++, not cygwin or g++. The Non-Visual C++ forum is where you should have posted this question.
    I can't even get it to compile hello world for me,
    The following C++ program is a true "hello world" program.
    Code:
    #include <iostream>
    
    int main()
    {
        std::cout << "Hello World";
    }
    Get the above code as-is to compile. If you can't, there is no need to go any further. Note the use of <iostream> (not <iostream.h>) and namespaces. There is no such header as <iostream.h> for Visual C++ 7.2 and above, since it is a non-standard header. The correct header is <iostream>.

    First of all, I need to know why my cygwin isn't compiling for me. I type in g++ helloworld.cpp and it goes through about 500 lines of errors in about 2 seconds and then I don't get any exe file out of it at all.
    Let's see your program that you say doesn't compile. And please use code tags when posting code.
    Secondly, I want to write a program that will make an LED blink from the printer port on my computer. Let me show you the code and tell me if it will work. I downloaded it from someone's site and modified it for my own purpose. I don't remember where. I want the program to wait 20 minutes then start blinking once every 20 seconds.
    You don't learn programming this way, and that is by downloading something you have no idea if it even works, and worse, if it doesn't work not know why it doesn't work.
    Here's the code:

    //This example code shows how to switch a LED on/off in Visual C++.
    //We use two variables N and L explained below.

    #include <iostream.h> //The most important include to display data on screen.
    Again, the correct header file is <iostream>, not <iostream.h>. Given all of this, the comment mentions Visual C++, but you're using another compiler (and also, this will not compile for Visual C++, as the header <iostream.h> doesn't exist anymore).

    Regards,

    Paul McKenzie

  3. #3
    Join Date
    Apr 2008
    Posts
    3

    Re: can't get cygwin to compile

    Thanks Paul.

    Like I said, I'm a retard when it comes to programming. I don't mean to sound like a jerk, and I hope you don't take this that way, but I'm not really interested in learning the ins and outs of programming, all I want is something that will make these LED's blink from my parallel port. I'm making a lucid dreaming mask and I'd like to be able to control the amount of time that passes before they start blinking, and I'd like to be able to control the rate of blinking. To do this I need to write one program and be able to edit the source and recompile it when I need to.

    Sorry about putting the post in the wrong forum. I don't even hardly know what g++ is, and certainly not that it and cygwin were different from visual c++.

    So even though there's no iostream.h for visual c++, does that mean that it wouldn't compile for cygwin either?

    Here is my helloworld program, again, I copy pasted it from the internet into notepad.
    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
    	cout << "Hello World!" << endl;
    	return 0;
    }
    I get a ton of crazy errors when I compile it in cygwin, and they come up so fast that I can't even read them, and I can't resize the cygwin dos window.

    So regarding my LED program, will it not even compile in cygwin, since it was written for visual c++? (once I fix the iostream mistake)? I also keep reading about cygwin being used mostly for unix. If I do get it to compile, would it even work on my windows xp computer? Is there another free, small compiler that I should get? I just googled c++ compilers or something and cygwin was the first one that popped up.

    Thanks for helping me even though I don't know *** is going on and posted in the wrong forum. Could a mod please move this?
    Last edited by unseen wombat; April 15th, 2008 at 10:31 AM.

  4. #4
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Fairfax, VA
    Posts
    10,888

    Re: can't get cygwin to compile

    Cygwin is for compiling Unix programs on Windows. The resulting programs will only work on machines with Cygwin installed (usually).

    Incidentally, I believe Cygwin's command prompt is a Unix bash shell by default, not DOS.

  5. #5
    Join Date
    Apr 2008
    Posts
    3

    Re: can't get cygwin to compile

    crap. I want to distribute this to my friends also into lucid dreaming, who may not have cygwin. I don't want to require them to download it, so i need a different compiler. Any recommendations? One with no bells or whistles is fine by me.

  6. #6
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,634

    Re: can't get cygwin to compile

    Go for Visual Studio Express edition http://www.microsoft.com/express/vc/Default.aspx
    It's a full IDE but you will benefit a lot from using it. All compiler/linker errors you get will end up in a scrollable window for instance. Sooner or later you'll also find the debugger most useful.

  7. #7
    Join Date
    May 2007
    Posts
    800

    Re: can't get cygwin to compile

    ...but I'm not really interested in learning the ins and outs of programming,
    than I would suggest to drop C/C++ and try to use simple or more forgiving language, like python, C#, VB, Java. There is no shortcuts with C/C++ only pain.

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center