Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
06-02-2011, 12:13 AM
|
#1
|
|
Member
Registered: Nov 2009
Posts: 144
Rep:
|
Portable C/C++ exe
I know that C/C++ programs usually need to be compiled specifically for the system they are going to be run on. However, I'm wondering if there's a way to get around this. I plan to make a program that preforms very simple manipulation of an image, but I would like to distribute it to people in the form of an exe. Is there an easy way to make the program run on any system without the user needing any knowledge of how to compile a C/C++ program? Can I easily package the program in a way that it can self compile?
Thanks for putting up with this question. I'm not used to making programs for people on windows or those who I won't expect to use a make file.
|
|
|
|
06-02-2011, 12:19 AM
|
#2
|
|
Senior Member
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 3,657
|
No.
This is one reason Java exists.
|
|
|
1 members found this post helpful.
|
06-02-2011, 12:31 AM
|
#3
|
|
Member
Registered: Nov 2009
Posts: 144
Original Poster
Rep:
|
I thought that might be the case. I've never used Java before, but I think I'll give it a try then. It's should end up being a simple program so I guess it's a good place to start anyway. Thanks for the quick reply!
|
|
|
|
06-02-2011, 04:31 AM
|
#4
|
|
Senior Member
Registered: May 2005
Posts: 4,392
|
Quote:
Originally Posted by golmschenk
I know that C/C++ programs usually need to be compiled specifically for the system they are going to be run on. However, I'm wondering if there's a way to get around this. I plan to make a program that preforms very simple manipulation of an image, but I would like to distribute it to people in the form of an exe. Is there an easy way to make the program run on any system without the user needing any knowledge of how to compile a C/C++ program? Can I easily package the program in a way that it can self compile?
Thanks for putting up with this question. I'm not used to making programs for people on windows or those who I won't expect to use a make file.
|
For a program to self-compile one needs development tools to be installed on the target machine. And all the libraries needed by your program.
|
|
|
|
06-02-2011, 06:01 AM
|
#5
|
|
Member
Registered: Dec 2009
Distribution: Slackware 12.2
Posts: 379
|
Quote:
Originally Posted by golmschenk
I know that C/C++ programs usually need to be compiled specifically for the system they are going to be run on. However, I'm wondering if there's a way to get around this. I plan to make a program that preforms very simple manipulation of an image, but I would like to distribute it to people in the form of an exe. Is there an easy way to make the program run on any system without the user needing any knowledge of how to compile a C/C++ program? Can I easily package the program in a way that it can self compile?
Thanks for putting up with this question. I'm not used to making programs for people on windows or those who I won't expect to use a make file.
|
Impossible. Use java.
|
|
|
|
06-02-2011, 09:09 AM
|
#6
|
|
Senior Member
Registered: May 2005
Posts: 4,392
|
Quote:
Originally Posted by SigTerm
Impossible. Use java.
|
Why impossible ? Java is just a program - as well as g++. So, instead of using Java one can supply g++ and all the needed sources and libraries - at least in theory.
|
|
|
|
06-02-2011, 09:39 AM
|
#7
|
|
Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,861
Rep: 
|
Quote:
|
So, instead of using Java one can supply g++ and all the needed sources and libraries - at least in theory.
|
Just like "instead of chewing them, one can eat string beans through your nose." At least in theory 
|
|
|
|
06-02-2011, 09:58 AM
|
#8
|
|
Member
Registered: Dec 2009
Distribution: Slackware 12.2
Posts: 379
|
Quote:
Originally Posted by Sergei Steshenko
Why impossible ? Java is just a program - as well as g++. So, instead of using Java one can supply g++ and all the needed sources and libraries - at least in theory.
|
Well, in practice, you'll have to severely limit number of supported platforms and impose strict minimal system requirements, and you still will end up with multiple versions of same program. You can't make an exe that will run anywhere - on any system + any platform + any architecture, with self-compilation you'll run into problem with different compiler versions. Also, last time I checked there is no portable version of g++ that'll run anywhere.
|
|
|
|
06-02-2011, 10:01 AM
|
#9
|
|
Senior Member
Registered: May 2005
Posts: 4,392
|
Quote:
Originally Posted by SigTerm
Well, in practice, you'll have to severely limit number of supported platforms and impose strict minimal system requirements, and you still will end up with multiple versions of same program. You can't make an exe that will run anywhere - on any system + any platform + any architecture, with self-compilation you'll run into problem with different compiler versions. Also, last time I checked there is no portable version of g++ that'll run anywhere.
|
Of course I can - that's for GNU autotools and cross-platform toolkits like Qt, WxWidgets, gtk+ exist for.
|
|
|
|
06-02-2011, 10:03 AM
|
#10
|
|
LQ 5k Club
Registered: Sep 2009
Distribution: Arch x86_64
Posts: 6,443
|
Quote:
Originally Posted by Sergei Steshenko
Of course I can - that's for GNU autotools and cross-platform toolkits like Qt, WxWidgets, gtk+ exist for.
|
An executable that relies on Qt doesn't run everywhere.
Source code using Qt can be compiled to an executable for any platform.
|
|
|
|
06-02-2011, 10:04 AM
|
#11
|
|
Senior Member
Registered: May 2005
Posts: 4,392
|
Quote:
Originally Posted by paulsm4
Just like "instead of chewing them, one can eat string beans through your nose." At least in theory 
|
Should I remind that "C" interpreters (not compilers) exist ? Then, for example, we translate C++ int "C" using LLVM and interpret the resulting "C" code.
|
|
|
|
06-02-2011, 11:10 PM
|
#12
|
|
Member
Registered: Dec 2009
Distribution: Slackware 12.2
Posts: 379
|
Quote:
Originally Posted by Sergei Steshenko
Of course I can - that's for GNU autotools and cross-platform toolkits like Qt, WxWidgets, gtk+ exist for.
|
That's what I was talking about when I said "impose system requirements".
It is possible to make a package that'll "probably" compile and run on a platform that has autotools + Qt + certain version of compiler(i.e. on platform that contains certain strictly specified packages/software), but you can't make a program, that'll "selfcompile" anywhere - simply because "every possible platform" also includes "platforms without autotools/Qt/compiler". That's why it is impossible to implement this project in general case.
|
|
|
|
06-03-2011, 02:41 AM
|
#13
|
|
Senior Member
Registered: May 2005
Posts: 4,392
|
Quote:
Originally Posted by SigTerm
That's what I was talking about when I said "impose system requirements".
It is possible to make a package that'll "probably" compile and run on a platform that has autotools + Qt + certain version of compiler(i.e. on platform that contains certain strictly specified packages/software), but you can't make a program, that'll "selfcompile" anywhere - simply because "every possible platform" also includes "platforms without autotools/Qt/compiler". That's why it is impossible to implement this project in general case.
|
But the project can be distributed with GNU autotools, Qt (or another GUI toolkit) in spurce form, compiler as binary. They are just files. That's why it is possible to implement this project in general case.
|
|
|
|
06-03-2011, 07:13 AM
|
#14
|
|
Member
Registered: Dec 2009
Distribution: Slackware 12.2
Posts: 379
|
Quote:
Originally Posted by Sergei Steshenko
But the project can be distributed with GNU autotools, Qt (or another GUI toolkit) in spurce form, compiler as binary. They are just files. That's why it is possible to implement this project in general case.
|
It is still not possible. To do so, you'll need to limit a number of supported platforms, distributions and architectures. Qt won't build on architecture without X, and compiler binary will run only on compatible platforms. It is possible to support a certain number of platforms(list of platforms). It is NOT possible to support every possible platform/distro.
Last edited by SigTerm; 06-03-2011 at 07:15 AM.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 12:19 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|