Re: Learning C and Learning Make/Configure/Building/Linking




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/manual/autoconf-2.57/html_mono/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

.



Relevant Pages

  • Re: [OT] Re: Learning C and Learning Make/Configure/Building/Linking
    ... tried writing a port forwarder in Java and found problems that nobody ... same on both Windows and Linux. ... binaries for Linux or find a way to make sure I can keep the libraries it ... I think my best bet is static binaries. ...
    (comp.lang.c)
  • Re: How did C++ beat the competition?
    ... IBM's Linux strategy has very little to do with C++. ... You can get their Java Application Server, ... When you come down to it, there are two poles of philosophy in software. ... Those libraries are what has been saving C++ so far. ...
    (comp.lang.cpp)
  • [OT] Re: Learning C and Learning Make/Configure/Building/Linking
    ... I have found C programs that almost work and Java ... same on both Windows and Linux. ... can be somehow forced to use them instead of the regular system libraries. ... I think my best bet is static binaries. ...
    (comp.lang.c)
  • Learning C and Learning Make/Configure/Building/Linking
    ... I have a problem with port forwarding and I have been working on it for over ... same on both Windows and Linux. ... Basically what I need to do is to either be able to create static binaries ... can be somehow forced to use them instead of the regular system libraries. ...
    (comp.lang.c)
  • jvm.dll vs java.dll
    ... libjvm.so and libjava.so on unix platforms (linux etc.) ... What is difference between 'jvm' and 'java' libraries? ... In order to use JNI Invocation API (creating JVM etc.), ...
    (comp.lang.java.programmer)