Thread: Real basic compile/run question

  1. #1
    Registered User
    Join Date
    Oct 2009
    Posts
    30

    Real basic compile/run question

    I'm still new to C and am having trouble running a compiled program.

    In the past when I compile on Linux I never specified a name of the file, so I would run the program with this command line argument:
    ./a.out

    Now when I compile, I am adding "-o myPgm" to the command line argument. How do I run the program now?

    Again, the OS is Linux.

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300


    ./myPgm

    You need to use ./ to specify an executable in the current working directory. This is to prevent confusion with binaries in the $PATH environment variable.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Basic question about GSL ODE func RK4
    By cosmich in forum Game Programming
    Replies: 1
    Last Post: 05-07-2007, 02:27 AM
  2. Basic C question ---- URGENT
    By x135 in forum Linux Programming
    Replies: 3
    Last Post: 03-25-2006, 11:05 PM
  3. Visual Basic Question?
    By ob1cnobe in forum C++ Programming
    Replies: 2
    Last Post: 07-03-2002, 09:31 AM
  4. A very basic question
    By AshFooYoung in forum C Programming
    Replies: 8
    Last Post: 10-07-2001, 03:37 PM