Dynamic includes/linking

Discussion in 'C Programming' started by Ajinkya, Sep 28, 2007.

  1. Ajinkya

    Ajinkya Guest

    I have writen a program for a game called game.exe
    Now it includes a player part to which has to be a function to be
    writen by someone else.

    Now I want to provide this exe to some tester who will be writing his
    player function.

    I dont know his file name and his function name....he will have to
    include it.
    I am providing him the game.exe and a common file containing all the
    includes(which is in turn included in my code)
    He will have to include his file through this common includes file.

    But as includes are compile time even after changes in the common
    includes file doesnot change the exe behaviour.

    I want to dynamically include his file/code at runtime/dynamic through
    the common includes file...

    How can i go about regarding this problem ?

    Thanks,
    Ajinkya
     
    Ajinkya, Sep 28, 2007
    #1
    1. Advertising

  2. Ajinkya <> writes:

    > I have writen a program for a game called game.exe
    > Now it includes a player part to which has to be a function to be
    > writen by someone else.
    >
    > Now I want to provide this exe to some tester who will be writing his
    > player function.
    >
    > I dont know his file name and his function name....he will have to
    > include it.
    > I am providing him the game.exe and a common file containing all the
    > includes(which is in turn included in my code)
    > He will have to include his file through this common includes file.
    >
    > But as includes are compile time even after changes in the common
    > includes file doesnot change the exe behaviour.
    >
    > I want to dynamically include his file/code at runtime/dynamic through
    > the common includes file...
    >
    > How can i go about regarding this problem ?


    The facilities provided by standard C (the topic in this group) in the
    respect are rather limited (you can try to run a program, but not much
    more). You'll get more helpful answers in a group that discusses the
    facilities of your system. The .exe suggests you want a Windows
    programming group.

    --
    Ben.
     
    Ben Bacarisse, Sep 28, 2007
    #2
    1. Advertising

  3. Ajinkya

    Ajinkya Guest

    On Sep 28, 12:27 pm, Ben Bacarisse <> wrote:
    > Ajinkya <> writes:
    > > I have writen a program for a game called game.exe
    > > Now it includes a player part to which has to be a function to be
    > > writen by someone else.

    >
    > > Now I want to provide this exe to some tester who will be writing his
    > > player function.

    >
    > > I dont know his file name and his function name....he will have to
    > > include it.
    > > I am providing him the game.exe and a common file containing all the
    > > includes(which is in turn included in my code)
    > > He will have to include his file through this common includes file.

    >
    > > But as includes are compile time even after changes in the common
    > > includes file doesnot change the exe behaviour.

    >
    > > I want to dynamically include his file/code at runtime/dynamic through
    > > the common includes file...

    >
    > > How can i go about regarding this problem ?

    >
    > The facilities provided by standard C (the topic in this group) in the
    > respect are rather limited (you can try to run a program, but not much
    > more). You'll get more helpful answers in a group that discusses the
    > facilities of your system. The .exe suggests you want a Windows
    > programming group.

    Exactly...cause in unix there is a method i have found but it is
    platform dependent way.
    I want this to work in windows....is this anything related to dll ? I
    know rather nothing of dll but heard of it...just a guess...
    >
    > --
    > Ben.- Hide quoted text -
    >
    > - Show quoted text -
     
    Ajinkya, Sep 28, 2007
    #3
  4. Ajinkya <> writes:

    > On Sep 28, 12:27 pm, Ben Bacarisse <> wrote:
    >> Ajinkya <> writes:
    >> > I have writen a program for a game called game.exe
    >> > Now it includes a player part to which has to be a function to be
    >> > writen by someone else.

    >>
    >> > Now I want to provide this exe to some tester who will be writing his
    >> > player function.

    >>

    <snip>
    >> > I want to dynamically include his file/code at runtime/dynamic through
    >> > the common includes file...

    >>
    >> > How can i go about regarding this problem ?

    >>
    >> The facilities provided by standard C (the topic in this group) in the
    >> respect are rather limited

    <snip>
    >> The .exe suggests you want a Windows programming group.

    > Exactly...cause in unix there is a method i have found but it is
    > platform dependent way.
    > I want this to work in windows....is this anything related to dll ? I
    > know rather nothing of dll but heard of it...just a guess...


    No, there is nothing in standard C about DLLs.

    If you need a portable solution, maybe you can do it by linking (or
    even compiling) the "guest" code?

    If you need some more info about DLLs, post in a Windows programming group.

    PS. Don't quote sigs (the bit after the "-- ").
    PPS. Try to trim the message you reply to.

    --
    Ben.
     
    Ben Bacarisse, Sep 28, 2007
    #4
  5. >I have writen a program for a game called game.exe
    >Now it includes a player part to which has to be a function to be
    >writen by someone else.
    >
    >Now I want to provide this exe to some tester who will be writing his
    >player function.
    >
    >I dont know his file name and his function name....he will have to
    >include it.


    You might be able to use dynamic linking to link to a "plugin".
    However, this is not a part of standard C and will require
    system-specific features, if they are available. You may be able
    to accept the file name of the plugin as, say, a command-line
    argument.

    There is no "dynamic include".

    >I am providing him the game.exe and a common file containing all the
    >includes(which is in turn included in my code)
    >He will have to include his file through this common includes file.


    >But as includes are compile time even after changes in the common
    >includes file doesnot change the exe behaviour.


    Even for a plugin, changes in common includes require re-compilation
    of all the pieces that use them. It is best to find an interface for
    the plugin and not change it much.

    >I want to dynamically include his file/code at runtime/dynamic through
    >the common includes file...


    Plugins are usually done by separate compilation, not by including
    a whole bunch of files in one big compilation. Changing the code
    in the plugin requires recompilation of the plugin only.
     
    Gordon Burditt, Sep 29, 2007
    #5
  6. Ajinkya

    Ajinkya Guest

    Can you give me an example how this can be done ?
    I didnt get exactly what do you mean by a plugin..
    Can you give a small example of the design you are suggesting ?
     
    Ajinkya, Sep 29, 2007
    #6
  7. >Can you give me an example how this can be done ?

    There's no standard way to do this; it's all system-specific.

    >I didnt get exactly what do you mean by a plugin..


    In some implementations, you can call a function dlopen(), which
    takes a file path name as an argument, to load a shared object
    (plugin). This object is compiled and linked separately from the
    main executable. You may then call dlsym() or dlfunc() with the
    name of a symbol to get a function pointer to the function named,
    and use that pointer call the function.

    This is different from a "normal" shared library use, where no
    special calls are required by the program to use the library because
    it's all set up before the program starts running using the libraries
    specified to the linker.

    >Can you give a small example of the design you are suggesting ?


    Apache (the web server program) as implemented on FreeBSD (and
    presumably other BSD Unix variants and Linux) uses a number of
    plugins which can be specified in a configuration file at runtime.

    Although a lot of the details may be different, Windows *.dll files
    can be used in a similar way.
     
    Gordon Burditt, Sep 29, 2007
    #7
  8. On Sat, 29 Sep 2007 03:32:17 -0000, in comp.lang.c , Ajinkya
    <> wrote:

    >
    >
    >Can you give me an example how this can be done ?


    There's no standard way - you would need to ask the specialists in a
    group which is dedicated to your operating system and/or compiler.

    >I didnt get exactly what do you mean by a plugin..
    >Can you give a small example of the design you are suggesting ?


    http://en.wikipedia.org/wiki/Plugin

    --
    Mark McIntyre

    "Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are,
    by definition, not smart enough to debug it."
    --Brian Kernighan
     
    Mark McIntyre, Sep 29, 2007
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Achim Domma (SyynX Solutions GmbH)

    dynamic includes for different designs

    Achim Domma (SyynX Solutions GmbH), Jan 17, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    341
    Achim Domma (SyynX Solutions GmbH)
    Jan 17, 2006
  2. paddy
    Replies:
    1
    Views:
    334
    Mike Wahler
    Oct 4, 2004
  3. jason
    Replies:
    2
    Views:
    116
    jason
    Jul 2, 2003
  4. Gary Contois

    dynamic includes of asp code

    Gary Contois, Sep 19, 2003, in forum: ASP General
    Replies:
    4
    Views:
    162
    Evertjan.
    Sep 19, 2003
  5. Emre Sevinc
    Replies:
    2
    Views:
    230
    Emre Sevinc
    Aug 16, 2004
Loading...

Share This Page