By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,123 Members | 1,256 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,123 IT Pros & Developers. It's quick & easy.

#include or System

P: n/a
Hello everybody,

I am writing a C++ code to do some Quantitative Genetics calculations
and I have to use another program (which is also a C++ code) inside my
program.
I have heard that it is possible to use #include and link the program
that I need. I can also use "system" and call any program from
inside my program but I don't know which one I have to use or which
one is working better.
I appreciate any comments about this issue.

Thanks,
Mohsen

Jul 4 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a

"Mohsen" <ja*******@gmail.comwrote in message
news:11**********************@v61g2000cwv.googlegr oups.com...
Hello everybody,

I am writing a C++ code to do some Quantitative Genetics calculations
and I have to use another program (which is also a C++ code) inside my
program.
I have heard that it is possible to use #include and link the program
that I need.
Since you use the term program, i assume you mean a compiled binary (.exe on
win32). So including a header file and linking is not possible.

If you have the source code for the program, it might be possible.
I can also use "system" and call any program from
inside my program but I don't know which one I have to use or which
one is working better.
I appreciate any comments about this issue.
Yes you can use system() or another alike function depending on the platform
to execute a external program. And in some way capture its output and
process it.

If i were in your shoes, i would probably write my own code that does the
same as the program you want to execute, and include that code inside my own
application.

//eric
Jul 4 '06 #2

P: n/a
"Mohsen" <ja*******@gmail.comwrote in message
news:11**********************@v61g2000cwv.googlegr oups.com...
Hello everybody,

I am writing a C++ code to do some Quantitative Genetics calculations
and I have to use another program (which is also a C++ code) inside my
program.
I have heard that it is possible to use #include and link the program
that I need. I can also use "system" and call any program from
inside my program but I don't know which one I have to use or which
one is working better.
I appreciate any comments about this issue.
You say "I have to use another program (which is also a C++ code) inside my
program."
It all depends on what you mean by this. If you have the source code to
other program, it would be best, IMO, to compile that with your source.
This will most likely take a little modification or understanding of the
other source (it would already have a main() and your program has a main()
and you can't have two mains, etc..). If the other program is designed
well, you should be able to just use the .cpp modules they have and include
the proper headers to be able to use the funcsions/classes/whatever.

If, you only have the executable program and not the source, then you would
need to use system (or some other means) to run the program and capture the
output. It may be as simple as redirecting the output to a text file your
program can then parse, if that would work for you.

Without more details as to exactly what you have and what you are trying to
do we can only give vague suggestions.
Jul 4 '06 #3

P: n/a
Hi again,

Thanks for your responses. It seems that I have one more option which
is having the second program inside my own program!
Actually I have the source code but NOW I don't know if it is better to
have it inside my program or I have better to have it in my header file
or call it using 'system'.
Any sugestions?

Cheers,
Mohsen


Jim Langston wrote:
"Mohsen" <ja*******@gmail.comwrote in message
news:11**********************@v61g2000cwv.googlegr oups.com...
Hello everybody,

I am writing a C++ code to do some Quantitative Genetics calculations
and I have to use another program (which is also a C++ code) inside my
program.
I have heard that it is possible to use #include and link the program
that I need. I can also use "system" and call any program from
inside my program but I don't know which one I have to use or which
one is working better.
I appreciate any comments about this issue.

You say "I have to use another program (which is also a C++ code) inside my
program."
It all depends on what you mean by this. If you have the source code to
other program, it would be best, IMO, to compile that with your source.
This will most likely take a little modification or understanding of the
other source (it would already have a main() and your program has a main()
and you can't have two mains, etc..). If the other program is designed
well, you should be able to just use the .cpp modules they have and include
the proper headers to be able to use the funcsions/classes/whatever.

If, you only have the executable program and not the source, then you would
need to use system (or some other means) to run the program and capture the
output. It may be as simple as redirecting the output to a text file your
program can then parse, if that would work for you.

Without more details as to exactly what you have and what you are trying to
do we can only give vague suggestions.
Jul 4 '06 #4

P: n/a
Thanks for your responses. It seems that I have one more option which
is having the second program inside my own program!
Actually I have the source code but NOW I don't know if it is better to
have it inside my program or I have better to have it in my header file
or call it using 'system'.
Any sugestions?
Since you have the source code it would be best to include it inside your
program.
Read and try to understand the code and take the parts you need if not the
license prohibits it.

You might need to alter a few things in the code (as Jim Langston wrote),
main(), maybe some screen output and such.

Btw. what does this other program you want to include do?

//eric
Jul 4 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.