469,612 Members | 1,602 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,612 developers. It's quick & easy.

Dynamic includes/linking

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

Sep 28 '07 #1
7 2220
Ajinkya <ka*********@gmail.comwrites:
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.
Sep 28 '07 #2
On Sep 28, 12:27 pm, Ben Bacarisse <ben.use...@bsb.me.ukwrote:
Ajinkya <kaleajin...@gmail.comwrites:
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 -

Sep 28 '07 #3
Ajinkya <ka*********@gmail.comwrites:
On Sep 28, 12:27 pm, Ben Bacarisse <ben.use...@bsb.me.ukwrote:
>Ajinkya <kaleajin...@gmail.comwrites:
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.
Sep 28 '07 #4
>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.

Sep 28 '07 #5


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 ?

Sep 29 '07 #6
>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.

Sep 29 '07 #7
On Sat, 29 Sep 2007 03:32:17 -0000, in comp.lang.c , Ajinkya
<ka*********@gmail.comwrote:
>

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
Sep 29 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Jeff Hagelberg | last post: by
reply views Thread by Dibyendu Roy | last post: by
5 posts views Thread by Sam Steingold | last post: by
reply views Thread by Pascal Costanza | last post: by
11 posts views Thread by Sean M. DonCarlos | last post: by
1 post views Thread by zpinhead | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.