Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: simple question

  1. #1
    Join Date
    May 2006
    Location
    here & there
    Beans
    96
    Distro
    Kubuntu 12.04 Precise Pangolin

    simple question

    hi there,

    i have a simple question, I just set up my new laptop with kubuntu 12.04 and installed the gcc.

    a few weeks ago i wrote some simple c code for school, which I was able to run on the old laptop just fine.

    now I have problems executing those files, saying I don't have enough permissions.

    theresa@kubuntu:~/c$ ls -lha musik.c
    -rwxrwxrwx 1 theresa theresa 349 Dez 25 2011 musik.c

    here's the code snippet that i'm trying to run (see it's very simple)
    Code:
    #include <stdio.h>
    
    int main()
    {
      printf("****** Meine Musiktitel ******\n\n");
      
      printf("N = Neuen Eintrag hinzufügen \n");
      printf("L = Eintrag löschen \n");
      printf("F = Musiktitel finden \n");
      printf("A = Alle Einträge anzeigen \n");
      printf("B = Programm beenden \n\n");
      
      printf("Ihre Wahl:");
      
      printf("\n\n");
      return 0;
    }

    When I try to run it by ./musik
    I'm getting a "can't execute this file."

    earlier i did a gcc -o musik.c musik

    this works fine on the old machine.
    Last edited by rockprincess; July 19th, 2012 at 01:23 PM.

  2. #2
    Join Date
    Sep 2006
    Beans
    8,627
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: simple question

    musik.c is the source code, it will not run itself but can be compiled using gcc into music. It is the output of gcc that you want to pay attention to and to try to run, not the input (source code).

  3. #3
    Join Date
    May 2006
    Location
    here & there
    Beans
    96
    Distro
    Kubuntu 12.04 Precise Pangolin

    Re: simple question

    Quote Originally Posted by Lars Noodén View Post
    musik.c is the source code, it will not run itself but can be compiled using gcc into music. It is the output of gcc that you want to pay attention to and to try to run, not the input (source code).
    sorry, this was a typo, I meant I was trying to run ./musik

    I still get the same error...

  4. #4
    Join Date
    Feb 2009
    Beans
    1,469

    Re: simple question

    If you really did

    Code:
    gcc -o musik.c musik
    you should have gotten an error, or musik.c should have been clobbered, or both. The argument following -o is the output file.

  5. #5
    Join Date
    May 2006
    Location
    here & there
    Beans
    96
    Distro
    Kubuntu 12.04 Precise Pangolin

    Re: simple question

    Quote Originally Posted by trent.josephsen View Post
    If you really did

    Code:
    gcc -o musik.c musik
    you should have gotten an error, or musik.c should have been clobbered, or both. The argument following -o is the output file.
    i didn't get an error....

    should then the correct syntax be?
    Code:
     gcc -c musik.c -o musik

  6. #6
    Join Date
    Nov 2011
    Location
    /dev/root
    Beans
    Hidden!

    Re: simple question

    If you run
    Code:
    gcc -o musik musik.c
    the output file (that is the executable file) is musik.

    Then it works when you run ./musik in the same directory (or if you move it to a directory in your path) you can run musik.

    It will work wherever you have compatible libraries (unless you compile it including the libraries into the program code).

  7. #7
    Join Date
    May 2006
    Location
    here & there
    Beans
    96
    Distro
    Kubuntu 12.04 Precise Pangolin

    Re: simple question

    Ok, I get tons of error messages (unfortunately there are only in german, so I won't post them here)....roughly translated they mean

    musik.c:18:582: Warning: Zero-Sign ignored (activated by default)

    Could it be that I'm missing some important libraries? Because it's working without any problem on the other machine.

  8. #8
    Join Date
    Nov 2011
    Location
    /dev/root
    Beans
    Hidden!

    Re: simple question

    Quote Originally Posted by rockprincess View Post
    Ok, I get tons of error messages (unfortunately there are only in german, so I won't post them here)....roughly translated they mean

    musik.c:18:582: Warning: Zero-Sign ignored (activated by default)

    Could it be that I'm missing some important libraries? Because it's working without any problem on the other machine.
    I think you may have different versions of the libraries. But what happens if you recompile from your source code? Or is your error output from when you compile from the source code?

  9. #9
    Join Date
    May 2006
    Location
    here & there
    Beans
    96
    Distro
    Kubuntu 12.04 Precise Pangolin

    Re: simple question

    Quote Originally Posted by sudodus View Post
    I think you may have different versions of the libraries. But what happens if you recompile from your source code? Or is your error output from when you compile from the source code?
    yeah, it's the error output when i run
    gcc -o musik musik.c

  10. #10
    Join Date
    Nov 2011
    Location
    /dev/root
    Beans
    Hidden!

    Re: simple question

    Quote Originally Posted by rockprincess View Post
    yeah, it's the error output when i run
    gcc -o musik musik.c
    It works for me without warning messages.
    Code:
    $ gcc -o musik musik.c
    $ ./musik
    ****** Meine Musiktitel ******
    
    N = Neuen Eintrag hinzufügen 
    L = Eintrag löschen 
    F = Musiktitel finden 
    A = Alle Einträge anzeigen 
    B = Programm beenden 
    
    Ihre Wahl:
    Can you run the program afterwards? (If only warning messages, it might be possible to run the program. Error messages will probably stop the compile and link process.)

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

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