Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Calling functions from another module

Posted on 2003-03-11
Medium Priority
Last Modified: 2010-04-15
 Hi there. I'm writing a sort of a strategy game in which every player writes his own client and they all compete in battles hosted by a server. My problem is that I want the clients to be written in c or pascal and the contestants will submit their source codes. So, I'll have to compile the .c and .pas files on my server. I heard that's possible to compile them into .obj files and then call some functions from the server. How do i use the linker to do that ? I'm using djcpp.

                               Thanks, Onu
Question by:onu0ro

Expert Comment

ID: 8117695
You need dynamic library. Rather than DJGPP, I suggest you to use Visual C++ or Borland C++ or Delphi that support DLL/ ActiveX.


Author Comment

ID: 8118642
 I also thought of this. But I can't tell the people to write dll's for clients. Nobody does that. I need to find a way to call the function from the .obj. I'm rather new to this, so I don't  even know if it's possible or not. Anyway, it's the .obj way that it's got to be.

Expert Comment

ID: 8119802
It is possible if you have them write it in C.  Just as you can have your code in separate modules, compiled into objs and then linked together, so can other people - especially if they are going to give you source code.  

However, a DLL makes things much easier for you, as it defines the exact method of interface between you and the other modules.  

You will need to define function prototypes in a header file for people to include in their project.  They should be told to NOT change the header file.  Expect to do ALOT of debugging...
LVL 46

Accepted Solution

Kent Olsen earned 80 total points
ID: 8120011
Do you envision all of the code running on your server with just status and control information being exchanged with the client or will the client software play an active part in the game?

In general, these steps should get you close.

Write a client program that fits into your game.  For now, it doesn't have to do much.  Compile it and all of the related modules.

Now take all of the compiled modules EXCEPT the client module that is "your player" and put them into a library.

Write a second client program.  Compile it, and link it with the standard (C/C++) libraries and your new library.

If this process works and you're able to successfully build a second client program you will have succeeded in building a library that will be the "core" for all of your player's clients.

Good Luck,

Expert Comment

ID: 8120062
Of course, if they are sending you source code, and you've predefined the function prototypes, nothing is preventing you from compiling them into a DLL - they don't have to do anything special except use your function prototypes.  A DLL and a static lib are not that different...

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
Suggested Courses

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question