Welcome to Dream.In.Code
Become a C++ Expert!

Join 149,929 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,785 people online right now. Registration is fast and FREE... Join Now!




Compiling C and C++ into one Program

 
Reply to this topicStart new topic

Compiling C and C++ into one Program

BryGuy638
3 Jan, 2008 - 03:45 PM
Post #1

New D.I.C Head
*

Joined: 19 Sep, 2007
Posts: 7


My Contributions
Alright, so, I've been doing quite a bit of coding for a research project that I'm working on. It's fairly complex, and has a lot of separate parts that all feed together in the end, so I have two different files. One is written in C++ (made serial communication easier) and one is in C (allowed me to use a helpful API).

I am compiling with GNU Compiler Collection under Ubuntu 7.10 (Gutsy Gibbon). I can send the calls that I use to compile them separately, the server is giving me some problems right now...

I would like to rewrite these files so that they do the processing and return values to a main class (still needs to be written), but I don't know how I would compile this. Is it as simple as simply using the include tag, or is there more work involved. Is it even possible to do what I want, or do I need to keep these sources as separate programs? I can provide the code that I currently have for each part if it would be of use, and am more than willing to answer any questions. Thanks for your help.

Bryan
User is offlineProfile CardPM
+Quote Post

Jingle
RE: Compiling C And C++ Into One Program
3 Jan, 2008 - 06:55 PM
Post #2

D.I.C Regular
***

Joined: 20 Oct, 2007
Posts: 250


My Contributions
QUOTE(BryGuy638 @ 3 Jan, 2008 - 04:45 PM) *

Alright, so, I've been doing quite a bit of coding for a research project that I'm working on. It's fairly complex, and has a lot of separate parts that all feed together in the end, so I have two different files. One is written in C++ (made serial communication easier) and one is in C (allowed me to use a helpful API).

I am compiling with GNU Compiler Collection under Ubuntu 7.10 (Gutsy Gibbon). I can send the calls that I use to compile them separately, the server is giving me some problems right now...

I would like to rewrite these files so that they do the processing and return values to a main class (still needs to be written), but I don't know how I would compile this. Is it as simple as simply using the include tag, or is there more work involved. Is it even possible to do what I want, or do I need to keep these sources as separate programs? I can provide the code that I currently have for each part if it would be of use, and am more than willing to answer any questions. Thanks for your help.

Bryan

it depends on what you are doing you could just call bolth of them a .cpp.
or you can compile them seperetly and link them.
this is not somthing i am comfortible giving advice on so good luk and im sorry i cant realy help much.
there are a bunch of sites on google you could try.maby they will help and maby not.
all i typed in is linking c to c++ and some look promising.

This post has been edited by Jingle: 3 Jan, 2008 - 06:56 PM
User is offlineProfile CardPM
+Quote Post

BryGuy638
RE: Compiling C And C++ Into One Program
3 Jan, 2008 - 11:19 PM
Post #3

New D.I.C Head
*

Joined: 19 Sep, 2007
Posts: 7


My Contributions
Got everything working, thanks for the help.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 1/8/09 03:19PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month