Thread: Help in using multimedia timers in eclipse for c

  1. #1
    Registered User
    Join Date
    Sep 2011
    Posts
    17

    Help in using multimedia timers in eclipse for c

    I am writing a code using multimedia timer, where i have to include the library winmm.h with out that it will not work. But i am not getting how to include this in my c project. is it possible to link to that library through c project please any one help me in this. i stuck up with this.
    my code is here
    Code:
    :
    
    #include<sys/time.h>
    #include<stdio.h>
    #include<time.h>
    #include<string.h>
    #include<windows.h>
    #include <mmsystem.h>
     
     
     
    void run()
    {
          static long int i= 0;
          i++;
          time_t t;
          time(&t);
          printf("S.No %ld Date and Time is: %s\n",i, ctime(&t));
    }
    int main()
    {
     
          int timeinterval = 10;
          timeBeginPeriod(1);
          long cur = 0;
          long last = timeGetTime();
     
                while(1)
                {
                      cur = timeGetTime();
                      if ((cur - last) >= timeinterval)
                      {
                            run();
     
                            last = cur;
                            _sleep(5);
                      }
                }
              return 0;
     
    }

    Last edited by ushacy; 12-15-2011 at 03:50 AM.

  2. #2
    Registered User ledow's Avatar
    Join Date
    Dec 2011
    Posts
    435
    If you are trying to use external code, you need to include the library header in your code (i.e. #include "winmm.h"), which may require you to add "include" paths to Eclipse for the place where that file lies if they're not already set up.

    You also need to link against any library objects that contain the ACTUAL code for those functions. The file at Win32 Library by Function Name will help you find out what DLL they are in and thus what .def / .a / .o you need to add to your linker objects in the Eclipse project options (if any - I don't think you're loading DLL's dynamically here). That will also involve making sure Eclipse is looking in the right paths under Linker options for those files.

    That said, your code is using _sleep which I think is deprecated (according to my compiler) so it may not even exist on modern Windows systems anyway.

    - Compiler warnings are like "Bridge Out Ahead" warnings. DON'T just ignore them.
    - A compiler error is something SO stupid that the compiler genuinely can't carry on with its job. A compiler warning is the compiler saying "Well, that's bloody stupid but if you WANT to ignore me..." and carrying on.
    - The best debugging tool in the world is a bunch of printf()'s for everything important around the bits you think might be wrong.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Quick multimedia question
    By Finchie_88 in forum C++ Programming
    Replies: 3
    Last Post: 11-10-2004, 10:20 PM
  2. Windows Multimedia API - Audio Mixers
    By dit6a9 in forum Windows Programming
    Replies: 4
    Last Post: 09-16-2004, 08:47 PM
  3. Change multimedia keyboard shortcuts
    By bennyandthejets in forum Tech Board
    Replies: 1
    Last Post: 03-22-2004, 01:33 PM
  4. MultiMedia/MIDI tutorials using C#
    By Grayson_Peddie in forum C# Programming
    Replies: 8
    Last Post: 09-27-2003, 04:37 PM
  5. how to detect multimedia keys
    By kwazar in forum Windows Programming
    Replies: 1
    Last Post: 01-25-2003, 05:32 PM