Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: cant compline the program using batch file  (Read 3990 times)

0 Members and 1 Guest are viewing this topic.

san_crazy

    Topic Starter


    Intermediate

    cant compline the program using batch file
    « on: July 01, 2008, 07:38:58 AM »
    hi friends,
    i tried to make a command string using batch file to run a C program. but i am not getting  wht exactly i do need.

    the batch file(say tcrun.bat) is as below

    @echo off
    cd c:\tc\bin
    tcc -Lc:\tc\lib -Ic:\tc\include


    and wrote this at command line to compile file.C
    tcrun.bat file.c

    but i got the error   
    Error: No file name is given

    someone please nail  the mistake out I am doing.

    regards
    san

    Dias de verano

    • Guest
    Re: cant compline the program using batch file
    « Reply #1 on: July 01, 2008, 08:41:19 AM »
    This is a mess

    Code: [Select]
    cd c:\tc\bin
    tcc -Lc:\tc\lib -Ic:\tc\include

    Sidewinder



      Guru

      Thanked: 139
    • Experience: Familiar
    • OS: Windows 10
    Re: cant compline the program using batch file
    « Reply #2 on: July 01, 2008, 09:03:11 AM »
    You are passing a command line argument that is not referenced in your batch file:

    Code: [Select]
    @echo off
    cd c:\tc\bin
    tcc %1

    The -L and -I switches are only needed when pointing to non-default directories.

    Good luck.  8)
    The true sign of intelligence is not knowledge but imagination.

    -- Albert Einstein

    san_crazy

      Topic Starter


      Intermediate

      Re: cant compline the program using batch file
      « Reply #3 on: July 01, 2008, 09:21:45 AM »
      thanks dude!!!
      could you please elaborate more why it was  not working along with -I -L options?
      and what does it mean by %l?

      regards
      san

      Sidewinder



        Guru

        Thanked: 139
      • Experience: Familiar
      • OS: Windows 10
      Re: cant compline the program using batch file
      « Reply #4 on: July 01, 2008, 09:46:43 AM »
      The -I and -L switches had nothing to do with your script not working. There was no reference to the passed argument (file.c). By using the command line reference (%1) in your script, the variable %1 will get replaced by whatever is passed as the first argument on the command line (file.c) in your case.

      Also your script used the -I and -L switches. The directories you pointed to are the defaults and will get searched automatically. No harm in using them, just less typing (read: less chance of error).

      Code: [Select]
      @echo off
      cd c:\tc\bin
      tcc -Lc:\tc\lib -Ic:\tc\include %1

      You can play around with the parameters. %1 might go before the switches.

      Good luck. 8)
      The true sign of intelligence is not knowledge but imagination.

      -- Albert Einstein

      san_crazy

        Topic Starter


        Intermediate

        Re: cant compline the program using batch file
        « Reply #5 on: July 01, 2008, 09:54:30 AM »
        I appreciate you
        thanks  a lot

        by the way....if we use tcc file.c directly then what the matter?
        is this a problem with batch file only?
        and what if we want to pass second argument?

        Sidewinder



          Guru

          Thanked: 139
        • Experience: Familiar
        • OS: Windows 10
        Re: cant compline the program using batch file
        « Reply #6 on: July 01, 2008, 11:31:42 AM »
        Quote
        by the way....if we use tcc file.c directly then what the matter?

        For this to work the tcc program needs to be in the current directory or on the path.

        It might be wise to use a path to the compiler and run your batch from the same directory where the source is located. This way you won't be tied to the directory where the compiler lives. The compiler will automatically search the lib and include directories, so unless you have header files or defs in other directories there is no need to use the switches.

        Code: [Select]
        @echo off
        c:\tc\bin\tcc  %1

        For a second parameter you can use the reference %2 in your batch file. The Tiny C Compiler uses mostly switches, what do plan on passing as the second parameter?

        Happy coding.  8)

        The true sign of intelligence is not knowledge but imagination.

        -- Albert Einstein

        san_crazy

          Topic Starter


          Intermediate

          Re: cant compline the program using batch file
          « Reply #7 on: July 01, 2008, 11:19:53 PM »

          For a second parameter you can use the reference %2 in your batch file. The Tiny C Compiler uses mostly switches, what do plan on passing as the second parameter?


          'cause i want to make a batch file that shut down my system after a desired duration.

          i used this shutdown.bat

          Code: [Select]
          @ echo off
           shutdown -s -f -m [computer name] %1 %2

          and used following command

          shutdown.bat -t "120"

          but this make system restart(not shutdown) immediately.
           
          beside, if i use the following then i get error.

          Code: [Select]
          @ echo off
           shutdown -s -f -m [computer name] -t %1

          shutdown.bat "120"



          san_crazy

            Topic Starter


            Intermediate

            Re: cant compline the program using batch file
            « Reply #8 on: July 03, 2008, 11:27:24 AM »
            please someone check this out and solve the problem

            Dias de verano

            • Guest
            Re: cant compline the program using batch file
            « Reply #9 on: July 03, 2008, 11:35:28 AM »
            please someone check this out and solve the problem

            And fix global warming and cure poverty and get me a pay rise.

            san_crazy, wait your turn!

            san_crazy

              Topic Starter


              Intermediate

              Re: cant compline the program using batch file
              « Reply #10 on: July 03, 2008, 11:48:14 AM »
              And fix global warming and cure poverty and get me a pay rise.

              san_crazy, wait your turn!


              i think you are the right person who can fix this problem, aren't u?

              Sidewinder



                Guru

                Thanked: 139
              • Experience: Familiar
              • OS: Windows 10
              Re: cant compline the program using batch file
              « Reply #11 on: July 03, 2008, 11:51:42 AM »
              Quote
              And fix global warming and cure poverty and get me a pay rise.

              If only.

              san_crazy, does this have anything to do with the compiler script earlier in this thread. You asked about a second parameter, and now you've gone off and changed the topic. In the future it might be better for everybody's sanity if you started a new thread when you change topics.

              You don't need the -m switch unless you're shutting down a remote machine on the network.

              Code: [Select]
              shutdown -t %1 -f  -s

              Run from the command prompt as batchfilename 120

              Do not name your batch file shutdown, otherwise you'll run the MS command instead of your batch file.

               8)

              The true sign of intelligence is not knowledge but imagination.

              -- Albert Einstein

              Dias de verano

              • Guest
              Re: cant compline the program using batch file
              « Reply #12 on: July 03, 2008, 11:56:16 AM »

              Do not name your batch file shutdown, otherwise you'll run the MS command instead of your batch file.

               8)


              Nice catch, SW. (Are you named after the snake or the missile?)

              san_crazy

                Topic Starter


                Intermediate

                Re: cant compline the program using batch file
                « Reply #13 on: July 03, 2008, 12:02:29 PM »

                san_crazy, does this have anything to do with the compiler script earlier in this thread. You asked about a second parameter, and now you've gone off and changed the topic. In the future it might be better for everybody's sanity if you started a new thread when you change topics.

                I'm sorry, I'll not repeat it again

                Quote

                You don't need the -m switch unless you're shutting down a remote machine on the network.

                Code: [Select]
                shutdown -t %1 -f  -s

                Run from the command prompt as batchfilename 120

                Do not name your batch file shutdown, otherwise you'll run the MS command instead of your batch file.

                 8)



                thanks anyway