LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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

Reply
 
Search this Thread
Old 06-02-2011, 01:13 AM   #1
golmschenk
Member
 
Registered: Nov 2009
Posts: 144

Rep: Reputation: 15
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.
 
Old 06-02-2011, 01:19 AM   #2
dugan
Senior Member
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 4,908

Rep: Reputation: 1545Reputation: 1545Reputation: 1545Reputation: 1545Reputation: 1545Reputation: 1545Reputation: 1545Reputation: 1545Reputation: 1545Reputation: 1545Reputation: 1545
No.

This is one reason Java exists.
 
1 members found this post helpful.
Old 06-02-2011, 01:31 AM   #3
golmschenk
Member
 
Registered: Nov 2009
Posts: 144

Original Poster
Rep: Reputation: 15
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!
 
Old 06-02-2011, 05:31 AM   #4
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by golmschenk View Post
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.
 
Old 06-02-2011, 07:01 AM   #5
SigTerm
Member
 
Registered: Dec 2009
Distribution: Slackware 12.2
Posts: 379

Rep: Reputation: 233Reputation: 233Reputation: 233
Quote:
Originally Posted by golmschenk View Post
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.
 
Old 06-02-2011, 10:09 AM   #6
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by SigTerm View Post
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.
 
Old 06-02-2011, 10:39 AM   #7
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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
 
Old 06-02-2011, 10:58 AM   #8
SigTerm
Member
 
Registered: Dec 2009
Distribution: Slackware 12.2
Posts: 379

Rep: Reputation: 233Reputation: 233Reputation: 233
Quote:
Originally Posted by Sergei Steshenko View Post
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.
 
Old 06-02-2011, 11:01 AM   #9
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by SigTerm View Post
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.
 
Old 06-02-2011, 11:03 AM   #10
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 714Reputation: 714Reputation: 714Reputation: 714Reputation: 714Reputation: 714Reputation: 714
Quote:
Originally Posted by Sergei Steshenko View Post
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.
 
Old 06-02-2011, 11:04 AM   #11
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by paulsm4 View Post
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.
 
Old 06-03-2011, 12:10 AM   #12
SigTerm
Member
 
Registered: Dec 2009
Distribution: Slackware 12.2
Posts: 379

Rep: Reputation: 233Reputation: 233Reputation: 233
Quote:
Originally Posted by Sergei Steshenko View Post
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.
 
Old 06-03-2011, 03:41 AM   #13
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by SigTerm View Post
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.
 
Old 06-03-2011, 08:13 AM   #14
SigTerm
Member
 
Registered: Dec 2009
Distribution: Slackware 12.2
Posts: 379

Rep: Reputation: 233Reputation: 233Reputation: 233
Quote:
Originally Posted by Sergei Steshenko View Post
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 08:15 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cygwin g++-3.exe, gcc-3.exe corrupted to g++3.exe.dam and gcc-3.exe.dam pawanjanbandhu Linux - Newbie 2 12-03-2009 12:27 PM
cygwin g++-3.exe, gcc-3.exe corrupted to g++3.exe.dam and gcc-3.exe.dam pawanjanbandhu Linux - Software 1 11-17-2009 03:26 PM
need a portable linux distro to bring on portable usb hard drive... pippo17 Linux - Distributions 3 10-20-2008 07:41 AM
samba compatibility with microsoft srvtools.exe (usrmgr.exe and srvmgr.exe) checkmate3001 Linux - Software 1 09-06-2008 06:08 AM
SETUP.EXE/autorun.exe don't run in wine mst3kman Linux - Games 3 01-22-2006 03:20 PM


All times are GMT -5. The time now is 02:46 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration