Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Dynamic includes/linking

Reply
Thread Tools

Dynamic includes/linking

 
 
Ajinkya
Guest
Posts: n/a
 
      09-28-2007
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

 
Reply With Quote
 
 
 
 
Ben Bacarisse
Guest
Posts: n/a
 
      09-28-2007
Ajinkya <(E-Mail Removed)> 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.
 
Reply With Quote
 
 
 
 
Ajinkya
Guest
Posts: n/a
 
      09-28-2007
On Sep 28, 12:27 pm, Ben Bacarisse <(E-Mail Removed)> wrote:
> Ajinkya <(E-Mail Removed)> 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 -



 
Reply With Quote
 
Ben Bacarisse
Guest
Posts: n/a
 
      09-28-2007
Ajinkya <(E-Mail Removed)> writes:

> On Sep 28, 12:27 pm, Ben Bacarisse <(E-Mail Removed)> wrote:
>> Ajinkya <(E-Mail Removed)> 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.
 
Reply With Quote
 
Gordon Burditt
Guest
Posts: n/a
 
      09-28-2007
>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.

 
Reply With Quote
 
Ajinkya
Guest
Posts: n/a
 
      09-29-2007


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 ?

 
Reply With Quote
 
Gordon Burditt
Guest
Posts: n/a
 
      09-29-2007
>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.

 
Reply With Quote
 
Mark McIntyre
Guest
Posts: n/a
 
      09-29-2007
On Sat, 29 Sep 2007 03:32:17 -0000, in comp.lang.c , Ajinkya
<(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic Variables? OR Dynamic Controls =?Utf-8?B?VGVyb3M=?= ASP .Net 1 08-10-2004 01:13 PM
Dynamic control on aspx page, dynamic location Chris Thunell ASP .Net 3 07-21-2004 04:52 PM
VPN between 2 Cisco routers (1 static, 1 dynamic) with access from stat --> dynamic over ISDN Hans-Peter Walter Cisco 3 01-21-2004 02:12 PM
Does Pix or cisco router support dynamic-to-dynamic IPSec VPN? c Cisco 2 01-13-2004 01:53 AM
Re: Dynamic Table with Dynamic LinkButtons Rick Glos ASP .Net 0 07-08-2003 01:09 PM



Advertisments