GNU Copiler

Z

ZikO

hi all

I have recently found something I was not conscious using GNU C compiler
v 4.4.0. I have created a simple program just to be run in command line.
However, when I tried to run it on someone's else computer, it asked me
about a library. I don't remember which one but I am not happy with that
because it means i cannot create a full standalone program. Whenever I
want to use it on any other computer it will required this library.

Do you have any suggestion how I could compile the program so that it
would be independent on any libraries? or which exact libraries are
required by programs compiled with GNU?

Thanks for any suggestion.

Regards
 
V

Victor Bazarov

ZikO said:
I have recently found something I was not conscious using GNU C compiler

C? This is a C++ newsgroup (in case you didn't know, they are different
languages).
v 4.4.0. I have created a simple program just to be run in command line.
However, when I tried to run it on someone's else computer, it asked me
about a library. I don't remember which one but I am not happy with that
because it means i cannot create a full standalone program. Whenever I
want to use it on any other computer it will required this library.

Do you have any suggestion how I could compile the program so that it
would be independent on any libraries? or which exact libraries are
required by programs compiled with GNU?

This question is better asked in the GNU C forum (gnu.gcc.help) or in
the forum for your OS.

In Windows world, for example, it is necessary to compile your program
with C run-time (CRT) library as "static" (versus "dynamic") to only
allow calls to Windows API to be resolved at run-time (and they always
should be since the dynamic libraries that provide the API are always
present).

V
 
Z

ZikO

Victor said:
C? This is a C++ newsgroup (in case you didn't know, they are different
languages).

This question is better asked in the GNU C forum (gnu.gcc.help) or in
the forum for your OS.

In Windows world, for example, it is necessary to compile your program
with C run-time (CRT) library as "static" (versus "dynamic") to only
allow calls to Windows API to be resolved at run-time (and they always
should be since the dynamic libraries that provide the API are always
present).

V

Thanks V but I am even more confused now.

Well, first thing, my program is in C++ not C, I only specified which
compiler I used, which is GNU and can also compile C++ programs by using
g++. I should have added those 2 little "+"s...

Second, I don't understand what static and dynamic libraries are. If you
would be so kind and explain it to me. Thanks.

Regards.
 
V

Victor Bazarov

ZikO said:
[..]
Well, first thing, my program is in C++ not C, I only specified which
compiler I used, which is GNU and can also compile C++ programs by using
g++. I should have added those 2 little "+"s...

OK, so now we're on the same page. You're actually using GNU C++. Good.
Second, I don't understand what static and dynamic libraries are. If you
would be so kind and explain it to me. Thanks.

See, that's the thing, those aren't really specified by the language
itself. They are a feature of the operating system on which your
program is running. That is, there are probably operating environments
that have no way of distinguishing between the two, and some have no
dynamic libraries whatsoever (AFAIK, and it's not much).

A dynamic library is a module that the OS can load into the process'
address space when your program starts (becomes a process), on demand,
thus placing more code for your program to call. A static library is
actually a set of object modules that can be linked to your program (and
become part of it) when your program is being created. In Unix world,
for instance, the static libraries often have the extension '.a'
("archive") and the dynamic ones '.so' ("shared object").

It is rather difficult to explain all possible nuances of using dynamic
libraries and static ones in a single newsgroup post, so you should seek
more information from other sources available, like books, for example.
It probably suffices to reiterate that static libraries contain code
that needs to be *linked* before your program is ready, and dynamic ones
contain code that is *linked* at the run-time.

So, to have your question on how to create a program that doesn't
require additional libraries answered, ask in the newsgroup for your OS.
Or to find out what libraries you need to run your program, ask in the
newsgroup for your OS. C++ *language* makes no effort to define what is
defined by the operating system or the compiler. Please forgive the
creators of the language for this major oversight.

V
 
Z

ZikO

Victor said:
ZikO said:
[..]
Well, first thing, my program is in C++ not C, I only specified which
compiler I used, which is GNU and can also compile C++ programs by using
g++. I should have added those 2 little "+"s...

OK, so now we're on the same page. You're actually using GNU C++. Good.
Second, I don't understand what static and dynamic libraries are. If you
would be so kind and explain it to me. Thanks.

See, that's the thing, those aren't really specified by the language
itself. They are a feature of the operating system on which your
program is running. That is, there are probably operating environments
that have no way of distinguishing between the two, and some have no
dynamic libraries whatsoever (AFAIK, and it's not much).

A dynamic library is a module that the OS can load into the process'
address space when your program starts (becomes a process), on demand,
thus placing more code for your program to call. A static library is
actually a set of object modules that can be linked to your program (and
become part of it) when your program is being created. In Unix world,
for instance, the static libraries often have the extension '.a'
("archive") and the dynamic ones '.so' ("shared object").

It is rather difficult to explain all possible nuances of using dynamic
libraries and static ones in a single newsgroup post, so you should seek
more information from other sources available, like books, for example.
It probably suffices to reiterate that static libraries contain code
that needs to be *linked* before your program is ready, and dynamic ones
contain code that is *linked* at the run-time.

So, to have your question on how to create a program that doesn't
require additional libraries answered, ask in the newsgroup for your OS.
Or to find out what libraries you need to run your program, ask in the
newsgroup for your OS. C++ *language* makes no effort to define what is
defined by the operating system or the compiler. Please forgive the
creators of the language for this major oversight.

V
Oh Dear ... It does not sound even familiar. Well, it's at least more I
knew before, though, it's new stuff for me. I will look into some web
pages to find something else.

Thanks for help.

Regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top