How to call function in another project?

Posted on 2006-07-20
Last Modified: 2013-11-20
I need to combine two project to compile together, also one project may need to call few function from another project, is it possible, thanks.
Question by:turbot_yu
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
LVL 22

Expert Comment

ID: 17151898
>>need to call few function from another project

Whats exact problem for grabbing appropriate header / src files from another project and use them in your current one ? You can add header,src files in the new project, include appropriate header file in current project and then use that particular function..

LVL 22

Accepted Solution

mahesh1402 earned 300 total points
ID: 17151907
otherwise simple solution like following for just example :

/**************************** PROJ1 ************************************/


#include <stdio.h>
#include "func_def.h"

void main()

/****** func_def.c ********/
void fun()

/*************************** END OF PROJ1 ******************************/

If this project resides in : C:\Pro1
================================================== =========================

Now project 2:

/******************************* PROJ2 ********************************/

#include <stdio.h>
#include "..\pro1\func_def.h"   //include header file like this

void main()

/***************************** END OF PROJ2 ****************************/

Hope this helps

Author Comment

ID: 17152438
May I use namespace to solve it?
LVL 22

Expert Comment

ID: 17152494
well but with namespace also you need header and class src files to be present in your project or path...namespace will be more useful if you have classes with same name and you want to use all in your project...above described method is simplest way to achieve this..all you need is to just add header and src file in your project..include header file in src file where you want to use particular function..

LVL 44

Assisted Solution

AndyAinscow earned 200 total points
ID: 17159252
A standard way to allow multiple applications to use the same functions is to place the functions in a dll.
Create a third project, put the .cpp/.h files for the shared functions into that project (remove from the project they are currently in).

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Macro to save highlighted rows as a separate file 5 46
Process filename extension 3 208
Detect file exist or not 3 198
Excel file not created as expected 7 90
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

740 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