ProgrammingThis 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.
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello
How to compile a program (src) is as portable ?
Like vlc, kaffein, gimp...
???
You need to use portable libraries and language constructs present in your compiler(s) of choice for all platforms. Ideally use standard C/C++, ideally C89 if it's "C" (i.e. ANSI "C"), though C99 appears to be well supported well.
Try not to use system-specific system calls and primitives, use stuff like "Boost" (C++) library to have these system-specific stuff abstracted away.
Can you be a little more specific in what you mean by portable?
In your example, building vlc like that will succeed if you have the prerequisite libraries and headers installed... try compiling it on a bare bones, text-console only debian box and you'll see what I mean.
vlc in linux this is a compilation
./configure
make
make install
How do I compile with c99 as portable
thanks for answer
The "portable" word has a number of meanings.
One of them is portability across operating systems, another - (typically used in Windows world) independence from system libraries, the ability to run from any directory, no need of installation.
That second meaning is well reflected by "self contained".
The second is to explain your
When compiled the program is installed in the root
and Program can not move, but I want to be installed anywhere and relocatable
From your example above, what happens during the build of the executable is controlled by the MakeFile.
A simple compilation... gcc example.c -o example will output the executable in the current directory.
Some builds allow you to run as root or a limited user... in the latter case, they will install somewhere like /home/user/bin
You need to be a lot more detailed in what you are asking here. Provide examples and such. Sadly there are very few of us who transcend genius to godhood and as such have to rely upon standard methods of communication rather than psychic abilities.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.