Can't run compiled c-programs in linux mint

This is a discussion on Can't run compiled c-programs in linux mint within the Linux Programming forums, part of the Platform Specific Boards category; Hi. I'm having problems running a c program I made after compiling. What happens is this: $ gcc filename.c -o ...

  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    9

    Can't run compiled c-programs in linux mint

    Hi.

    I'm having problems running a c program I made after compiling.

    What happens is this:

    $ gcc filename.c -o filename
    $ filename
    filename: command not found

    So the code compiles, and everything seems to be fine. But for some reason i can't run the program afterwards. I guess there's some sort of package i haven't installed, but I can't figure out which. Can anyone help me?
    Last edited by duckdace; 10-09-2010 at 04:34 AM. Reason: Typoes

  2. #2
    Registered User
    Join Date
    Aug 2003
    Posts
    1,205
    you need to call a program with the directory it is in. In your example you would have to type
    ./filename
    if the program is located in a subdirectory you can do
    subdir/filename
    and so on.

  3. #3
    Registered User
    Join Date
    Oct 2010
    Posts
    9
    Ah, thanks. That explains it. I'm used to work on computers where this is not necessary, as long as I'm in the correct foldet.

  4. #4
    Registered User
    Join Date
    Jan 2011
    Posts
    2

    Question Having a similar problem

    I'm in the correct directory so I'm not sure what the problem is...

    I'm using a linux virtual machine, and I'm not sure if that has anything to do with it, maybe theres some set-up I have failed to do, but down to business.

    I am able to compile the program, price.c, and the computer makes "price". If I try to run the program by typing "price" into the terminal I get the error

    No command 'price' found, did you mean:
    Command 'prime' from package 'prime' (universe)
    price: command not found

    The weird thing is that the program has worked before on other linux machines. Really confused.

    Thank you.

  5. #5
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    So, did you read the thread you brought back from the dead and posted in? Generally in linux, . is not in your path. You need to explicitly say ./price, not just price.

  6. #6
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,650
    Seriously, tabstop. What the hell, right?

  7. #7
    Registered User
    Join Date
    Jan 2011
    Posts
    2
    Right my bad guys. Thanks for the help.

  8. #8
    Registered User
    Join Date
    Jan 2011
    Location
    MN
    Posts
    4
    On some systems, "." might be included in the path, "." being your present working directory.

    You can append it to your current search path by using

    Code:
    export PATH=$PATH:.
    And insert it into your ~/.bash_profile or ~/.bashrc file
    .bash_profile vs .bashrc

    Next time you log in, the new PATH will be used.

  9. #9
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,544
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Thinking of upgrading to linux...
    By Yarin in forum General Discussions
    Replies: 37
    Last Post: 07-24-2009, 11:40 AM
  2. Replies: 5
    Last Post: 10-25-2007, 12:27 PM
  3. Linux C++ Compiler
    By LiX in forum C++ Programming
    Replies: 12
    Last Post: 12-10-2004, 05:08 AM
  4. Programs run in dos. Why not windows?
    By marcusbankuti in forum C++ Programming
    Replies: 15
    Last Post: 08-11-2002, 07:33 PM
  5. code to run (linux) programs WITH arguments
    By N8760 in forum C++ Programming
    Replies: 3
    Last Post: 12-27-2001, 02:35 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21