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

Learning C and Learning Make/Configure/Building/Linking

P: n/a
I have a problem with port forwarding and I have been working on it for over
2 weeks with no luck. I have found C programs that almost work and Java
programs that almost work, but nothing that does what I need. I've even
tried writing a port forwarder in Java and found problems that nobody seems
to have the answer to in forums. I need to make it work essentially the
same on both Windows and Linux.

There is one program, in C, that comes close to what I need. It is
compilable and even has binaries for Windows. The problem is it does not
have static binaries for Linux. Now, please, before someone starts saying,
"Go away. It's a Linux problem, as in Linux forums," first, I have asked
questions there and received almost no responses. Second, at this point,
my questions are more focused on C than on an OS. (I think that's why I
didn't get help in Linux forums -- it's more a C question.)

Basically what I need to do is to either be able to create static binaries
for Linux or find a way to make sure I can keep the libraries it is
compiled with available (the program would always be run from a CD) so it
can be somehow forced to use them instead of the regular system libraries.

I think my best bet is static binaries.

I've been programming in Perl and Java for 4-5 years now (all self taught).
It looks like the only solution left for me is to learn enough about C and
building C programs to do it myself. I've read a bit of C before and can
often follow the logic of C source code. But the books I've read had very
little on the ./configure && make && make install process, which is what I
think I need now.

How hard is it to learn the process in building a program?

How hard is it to make sure a program is built with static libraries in
stead of shared object libraries?

Is it possible to learn enough of this to be able to build a static binary
in a few days or a week?

And, lastly, what books or links would people recommend for this?

Thanks for any help on this.

Hal
Mar 19 '06 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Hal Vaughan <ha*@thresholddigital.com> writes:
There is one program, in C, that comes close to what I need. It is
compilable and even has binaries for Windows. The problem is it does not
have static binaries for Linux. Now, please, before someone starts saying,
"Go away. It's a Linux problem, as in Linux forums," first, I have asked
questions there and received almost no responses. Second, at this point,
my questions are more focused on C than on an OS. (I think that's why I
didn't get help in Linux forums -- it's more a C question.)


It really is a Linux problem. It is easy to change the link step
of a program build to use static libraries. You should be able
to figure it out, in fact, from the C compiler documentation.
--
int main(void){char p[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv wxyz.\
\n",*q="kl BIcNBFr.NKEzjwCIxNJC";int i=sizeof p/2;char *strchr();int putchar(\
);while(*q){i+=strchr(p,*q++)-p;if(i>=(int)sizeof p)i-=sizeof p-1;putchar(p[i]\
);}return 0;}
Mar 19 '06 #2

P: n/a
Ben Pfaff wrote:
Hal Vaughan <ha*@thresholddigital.com> writes:
There is one program, in C, that comes close to what I need. It is
compilable and even has binaries for Windows. The problem is it does not
have static binaries for Linux. Now, please, before someone starts
saying,
"Go away. It's a Linux problem, as in Linux forums," first, I have asked
questions there and received almost no responses. Second, at this point,
my questions are more focused on C than on an OS. (I think that's why I
didn't get help in Linux forums -- it's more a C question.)
It really is a Linux problem.


As I said, yes, I see that. The problem is I've been working on this thing
for 2 weeks, going on about 5 hrs sleep a night with this and other coding
that must be done, and what I need is help. The Linux forums are low
traffic and don't seem to have people who can help.
It is easy to change the link step
of a program build to use static libraries. You should be able
to figure it out, in fact, from the C compiler documentation.


Even if it uses make? This program has a configure file that is over 24,000
lines long and a huge make file. I've tried going through them to find out
what to change. With your suggestion I'll start checking compiler (gcc)
docs.

Thanks, even for a small pointer. To be honest (and not to be judgmental),
it is more help than I've ever gotten on any C forums before this.

Hal
Mar 19 '06 #3

P: n/a
Hal Vaughan wrote:
I have a problem with port forwarding and I have been working on it for over
2 weeks with no luck. I have found C programs that almost work and Java
programs that almost work, but nothing that does what I need. I've even
tried writing a port forwarder in Java and found problems that nobody seems
to have the answer to in forums. I need to make it work essentially the
same on both Windows and Linux.

There is one program, in C, that comes close to what I need. It is
compilable and even has binaries for Windows. The problem is it does not
have static binaries for Linux. Now, please, before someone starts saying,
"Go away. It's a Linux problem, as in Linux forums," first, I have asked
questions there and received almost no responses. Second, at this point,
my questions are more focused on C than on an OS. (I think that's why I
didn't get help in Linux forums -- it's more a C question.)
Like Ben Pfaff said: nope, it really isn't. It a compilation environment
question, but not a language question.
Basically what I need to do is to either be able to create static binaries
for Linux or find a way to make sure I can keep the libraries it is
compiled with available (the program would always be run from a CD) so it
can be somehow forced to use them instead of the regular system libraries.

I think my best bet is static binaries.
Yes, if you intend to run the program from a live system with different
library versions you'll need to link statically. If you can boot from the CD
and set up your own environment, you can of course arrange dynamic linking
from there.
I've been programming in Perl and Java for 4-5 years now (all self taught).
It looks like the only solution left for me is to learn enough about C and
building C programs to do it myself. I've read a bit of C before and can
often follow the logic of C source code. But the books I've read had very
little on the ./configure && make && make install process, which is what I
think I need now.
Then you don't really want to learn C, per se. You're talking the standard
Unix build process. Try a good book on Unix or GCC. (Sorry, I don't have any
reading tips handy; I'm mostly self-taught too. :-)
How hard is it to learn the process in building a program?
If you're designing the process, pretty easy. Make is quite basic.

If not, arbitrarily hard. Some programs have build processes nobody really
understands. I'm not kidding. Make plus shell scripts give you unlimited
potential for shooting yourself in the foot, arm, leg, head and still have
enough ammo left to finish Quake on nightmare level.
How hard is it to make sure a program is built with static libraries in
stead of shared object libraries?

Depends. If the program is designed to work with dynamic libraries (using
dlopen() and friends), it's obviously impossible without modifying the
source. But this would be rare.

For a total idiot's approach, try 'env CFLAGS="${CFLAGS} -static" make'. If
you're lucky, this may actually produce static binaries. If not, you'll need
to delve into the makefile. Good luck.

S.
Mar 19 '06 #4

P: n/a
Skarmander wrote:
Hal Vaughan wrote:
I have a problem with port forwarding and I have been working on it for
over
2 weeks with no luck. *I have found C programs that almost work and Java
programs that almost work, but nothing that does what I need. *I've even
tried writing a port forwarder in Java and found problems that nobody
seems
to have the answer to in forums. *I need to make it work essentially the
same on both Windows and Linux.

There is one program, in C, that comes close to what I need. *It is
compilable and even has binaries for Windows. *The problem is it does not
have static binaries for Linux. *Now, please, before someone starts
saying,
"Go away. *It's a Linux problem, as in Linux forums," first, I have asked
questions there and received almost no responses. *Second, at this point,
my questions are more focused on C than on an OS. *(I think that's why I
didn't get help in Linux forums -- it's more a C question.)

Like Ben Pfaff said: nope, it really isn't. It a compilation environment
question, but not a language question.


Just your wording of compilation environment is a big help. *I've worked
heavily in Java and Perl, and such a thing is not an issue with those
languages, so to try to get a handle on something like that is rather
difficult and having the problem or issue labeled specifically is a huge
help.
Basically what I need to do is to either be able to create static
binaries for Linux or find a way to make sure I can keep the libraries it
is compiled with available (the program would always be run from a CD) so
it can be somehow forced to use them instead of the regular system
libraries.

I think my best bet is static binaries.

Yes, if you intend to run the program from a live system with different
library versions you'll need to link statically. If you can boot from the
CD and set up your own environment, you can of course arrange dynamic
linking from there.


That's what I'm hoping to do. *I figured static, but this is so unfamiliar
to me even having that confirmed is a big help.
I've been programming in Perl and Java for 4-5 years now (all self
taught). It looks like the only solution left for me is to learn enough
about C and
building C programs to do it myself. *I've read a bit of C before and can
often follow the logic of C source code. *But the books I've read had
very little on the ./configure && make && make install process, which is
what I think I need now.

Then you don't really want to learn C, per se. You're talking the standard
Unix build process. Try a good book on Unix or GCC. (Sorry, I don't have
any reading tips handy; I'm mostly self-taught too. :-)


No tips, but, again, giving me name, such as your phrase "the standard Unix
build process" helps a clueless newbie like me to identify more about where
to look for an answer. *It seems small, but I've gotten so many, "Sorry,
not here, go elsewhere" answers in forums that have proved helpless, I've
begun to wonder why the posters even bothered. *They're not helping anyone,
other than telling me to get lost, and, while it is clear they know a lot
more about the situation than I do, aren't even offering enough to help a
newbie figure out where specifically to look. *It's almost as if there's a
lot of people who get off on saying, "Sorry, we can't help you and we don't
care enough to even help you find where to look."
How hard is it to learn the process in building a program?

If you're designing the process, pretty easy. Make is quite basic.

If not, arbitrarily hard. Some programs have build processes nobody really
understands. I'm not kidding. Make plus shell scripts give you unlimited
potential for shooting yourself in the foot, arm, leg, head and still have
enough ammo left to finish Quake on nightmare level.


I can understand that. *Unfortunately, I'm working with someone else's code,
and the programmer himself, while on a mailing list, is about as helpful as
a brick to a drowning man.
How hard is it to make sure a program is built with static libraries in
stead of shared object libraries?

Depends. If the program is designed to work with dynamic libraries (using
dlopen() and friends), it's obviously impossible without modifying the
source. But this would be rare.

For a total idiot's approach, try 'env CFLAGS="${CFLAGS} -static" make'.
If you're lucky, this may actually produce static binaries. If not, you'll
need to delve into the makefile. Good luck.


Thanks. *I'll see what that does.

While you may not have been able to give me but one or two specific
suggestions, thank you for the effort. *It speaks well of you that when I
said I was new and didn't know what to, instead of just telling me to fsck
off, you made the effort to provide me with help by naming the process or
situation and giving me a concrete area of what to look for or to work
with, rather than just an RTFM -- which, for someone who has been working
on this for a while and not made any headway is frustrating.

Thank you.

Hal
Mar 20 '06 #5

P: n/a
On Sun, 19 Mar 2006 15:48:27 -0500, Hal Vaughan wrote:
I have a problem with port forwarding and I have been working on it for over
2 weeks with no luck. I have found C programs that almost work and Java
programs that almost work, but nothing that does what I need. I've even
tried writing a port forwarder in Java and found problems that nobody seems
to have the answer to in forums. I need to make it work essentially the
same on both Windows and Linux.


This is the wrong forum. For Unix programming questions try
comp.unix.programmer; comp.os.linux.development.apps might be
useful too (though, the technical specificity is often lacking, if you're
questions are about build processes for GNU autotools or other
GNU/Linux non-programming stuff you might get quicker help). You'll get
much more help in the right forum, and often wrong answers in the wrong
forum.

Also, next time round be more specific. People can't answer broad
questions and general personal statements. You say "port forwarding", and
I still don't have any idea what you want or what you're trying to
accomplish (often two different things). Maybe a Cisco router will help,
or information on packet filter configuration.

- Bill

Mar 20 '06 #6

P: n/a
Hal Vaughan <ha*@thresholddigital.com> writes:
Ben Pfaff wrote:

[...]
It is easy to change the link step
of a program build to use static libraries. You should be able
to figure it out, in fact, from the C compiler documentation.


Even if it uses make? This program has a configure file that is over 24,000
lines long and a huge make file. I've tried going through them to find out
what to change. With your suggestion I'll start checking compiler (gcc)
docs.


You might also try comp.unix.programmer (your situation sounds like it
could probably apply to any Unix-like system) and/or gnu.gcc.help.
comp.unix.programmer is fairly active; I sometimes hang out there
myself.

If the configure file is 24,000 lines long, it's unlikely that either
it or the make file is hand-written. Find out what they were
generated from. <OT><HINT>GNU autoconf</HINT></OT>

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Mar 20 '06 #7

P: n/a

Hal Vaughan skrev:
Skarmander wrote:
Hal Vaughan wrote:
I have a problem with port forwarding and I have been working on it for
over
2 weeks with no luck. I have found C programs that almost work and Java
programs that almost work, but nothing that does what I need. I've even
tried writing a port forwarder in Java and found problems that nobody
seems
to have the answer to in forums. I need to make it work essentially the
same on both Windows and Linux.

There is one program, in C, that comes close to what I need. It is
compilable and even has binaries for Windows. The problem is it does not
have static binaries for Linux. Now, please, before someone starts
saying,
"Go away. It's a Linux problem, as in Linux forums," first, I have asked
questions there and received almost no responses. Second, at this point,
my questions are more focused on C than on an OS. (I think that's why I
didn't get help in Linux forums -- it's more a C question.)
Like Ben Pfaff said: nope, it really isn't. It a compilation environment
question, but not a language question.


Just your wording of compilation environment is a big help. I've worked
heavily in Java and Perl, and such a thing is not an issue with those
languages, so to try to get a handle on something like that is rather
difficult and having the problem or issue labeled specifically is a huge
help.
Basically what I need to do is to either be able to create static
binaries for Linux or find a way to make sure I can keep the libraries it
is compiled with available (the program would always be run from a CD) so
it can be somehow forced to use them instead of the regular system
libraries.

I think my best bet is static binaries.

Yes, if you intend to run the program from a live system with different
library versions you'll need to link statically. If you can boot from the
CD and set up your own environment, you can of course arrange dynamic
linking from there.


That's what I'm hoping to do. I figured static, but this is so unfamiliar
to me even having that confirmed is a big help.
I've been programming in Perl and Java for 4-5 years now (all self
taught). It looks like the only solution left for me is to learn enough
about C and
building C programs to do it myself. I've read a bit of C before and can
often follow the logic of C source code. But the books I've read had
very little on the ./configure && make && make install process, which is
what I think I need now.

Then you don't really want to learn C, per se. You're talking the standard
Unix build process. Try a good book on Unix or GCC. (Sorry, I don't have
any reading tips handy; I'm mostly self-taught too. :-)


No tips, but, again, giving me name, such as your phrase "the standard Unix
build process" helps a clueless newbie like me to identify more about where
to look for an answer. It seems small, but I've gotten so many, "Sorry,
not here, go elsewhere" answers in forums that have proved helpless, I've
begun to wonder why the posters even bothered. They're not helping anyone,
other than telling me to get lost, and, while it is clear they know a lot
more about the situation than I do, aren't even offering enough to help a
newbie figure out where specifically to look. It's almost as if there's a
lot of people who get off on saying, "Sorry, we can't help you and we don't
care enough to even help you find where to look."
How hard is it to learn the process in building a program?

If you're designing the process, pretty easy. Make is quite basic.

If not, arbitrarily hard. Some programs have build processes nobody really
understands. I'm not kidding. Make plus shell scripts give you unlimited
potential for shooting yourself in the foot, arm, leg, head and still have
enough ammo left to finish Quake on nightmare level.


I can understand that. Unfortunately, I'm working with someone else's code,
and the programmer himself, while on a mailing list, is about as helpful as
a brick to a drowning man.
How hard is it to make sure a program is built with static libraries in
stead of shared object libraries?

Depends. If the program is designed to work with dynamic libraries (using
dlopen() and friends), it's obviously impossible without modifying the
source. But this would be rare.

For a total idiot's approach, try 'env CFLAGS="${CFLAGS} -static" make'.
If you're lucky, this may actually produce static binaries. If not, you'll
need to delve into the makefile. Good luck.


Thanks. I'll see what that does.

While you may not have been able to give me but one or two specific
suggestions, thank you for the effort. It speaks well of you that when I
said I was new and didn't know what to, instead of just telling me to fsck
off, you made the effort to provide me with help by naming the process or
situation and giving me a concrete area of what to look for or to work
with, rather than just an RTFM -- which, for someone who has been working
on this for a while and not made any headway is frustrating.

Thank you.


A couple of pointers:

1). Check if there is a file called Makefile.am. If you find it, the
software you are using uses Automake. Good luck. You'll need it.

1). Check if there is a file called either 'configure.ac' or
'configure.in' somewhere in the directory tree. If you find it, that
means the software you are using uses Autoconf. Do not try to
understand the 'configure' file, learn a bit about Autoconf and try
reading 'configure.ac' or 'configure.in'. The Autoconf manual:
http://www.gnu.org/software/autoconf.../autoconf.html,
a tutorial: http://roo.no-ip.org/howtos/autoconf.php.

2). Linkers produce static binaries by default. If the software
currently uses dynamic linking, you should be able to find the specific
switches, e.g. by searching for '-Bdirect'. Try reading the manual for
the 'ld' command.

Hal


Mar 21 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.