Thread: Adding Library to Linux

  1. #16
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by bithub View Post
    Keyword here being using. I'm willing to bet you have not been doing application development on Linux for a decade, otherwise you would feel our pain here.
    Obviously you did not read the story! Or tell much of one, TBH. If it is a pain for you, give up; stick to what works best with you and be happy with that. I think that would be better than making the thing over as closed source because then you can get paid, or everything more compatible so then you can write the program which everyone apparently needs so much from you, esp. if that means trashing the diversity and rapid, continuous evolution that are such a huge part of what makes linux interesting to use.

    I too could complain the world should better pave the way for my programming career, but *sigh* I won't.
    Last edited by MK27; 07-28-2009 at 05:05 PM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  2. #17
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    What the hell are you rambling about? Your post makes almost zero sense...

    >> Obviously you did not read the story! Or tell much of one, TBH.
    What story? Are we swapping stories now?

    >> If it is a pain for you, give up; stick to what works best with you and be happy with that.
    What?

    I think that would be better than making the thing over as closed source because then you can get paid, or everything more compatible so then you can write the program which everyone apparently needs so much from you, esp. if that means trashing the diversity and rapid, continuous evolution that are such a huge part of what makes linux interesting to use.
    Did that sentence make sense in your head when you were typing it out? The only thing I could get out of that is it has something to do with closed vs. open source (which has nothing to do with the discussion).

    I'm just going to assume that you've been drinking, because normally your posts are fairly readable.

  3. #18
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by bithub View Post
    I'm just going to assume that you've been drinking, because normally your posts are fairly readable.
    Clearly I ticked someone off again! I even admit to aiming a little here!

    They are all readable, it is mostly a matter of whether you want to ignore the obvious or not. Avoid the big words and long phrases, everything will be okay in the morning.


    TCH.
    Last edited by MK27; 07-28-2009 at 05:24 PM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  4. #19
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    You didn't tick me off; I was being honest. I actually have no clue what any of your last post meant. It's nice to know all the stupid crap you post is just to get a rise out of people though.

  5. #20
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by bithub View Post
    It's nice to know all the stupid crap you post is just to get a rise out of people though.
    Not at all; that is just an occasional bonus (or a consolation: maybe you are not the intended audience for this one). By "aim" I fancied myself a purveyor of insightful criticism. You really need to read that story. Force yourself to read the first two paragraphs* before you decide anything.

    If you had read the thread from the beginning, maybe it would have been clearer, but in any case I feel no regret or need to explain myself -- just ignore me, bithub, if you can

    *Upto: "And the higher the challenge, the greater the demands. And such men were in fact available—if not the crowds of them which this construction could have used, at least in great numbers."
    Last edited by MK27; 07-28-2009 at 05:38 PM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  6. #21
    Registered User
    Join Date
    Jul 2009
    Posts
    61

    Thumbs up

    HI EVERY ONE,
    I think my questions are a little .... I did this:
    cp MyLibraries /usr/lib/ and ldconfig /usr/lib/
    It worked! the linked file is now mentioning to Qt 4.5

    I'm new to linux and new more in programming in linux, I think 2 things in linux is a little hard to handle: 1) you have to compile your program on every single computer Imagine that I have both Qt and Boost in my code! User will be dead to compile these libraries and is forced to to have knowledge about compiling, linking and .... 2) Libraries and distributions are changing too fast and conflicting between versions hurt anybody

    How about talking about these matters? I enjoy and of course a lot from you.

    Thanks

  7. #22
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by hosseinyounesi View Post
    HI EVERY ONE,
    I think my questions are a little .... I did this:
    cp MyLibraries /usr/lib/ and ldconfig /usr/lib/
    It worked! the linked file is now mentioning to Qt 4.5
    That's good. Again, just don't copy the softlinks to that Qt library. That way, the default will still be the old one, which is still present, and system apps compiled against it will still use that one.

    I'm new to linux and new more in programming in linux, I think 2 things in linux is a little hard to handle: 1) you have to compile your program on every single computer Imagine that I have both Qt and Boost in my code! User will be dead to compile these libraries and is forced to to have knowledge about compiling, linking and ....
    You don't have to compile per user, you compile per distribution. Here's part of the reason why: your program will compile on the other system (almost certainly -- and if it does, that makes you doubly lazy since you have no real reason to use a different Qt). Then it will be linked against the local, installed version of Qt already on the system. That binary will be fine for all other systems using that distribution. Why does that matter? Look at some output from top:
    Code:
    USER      VIRT  RES  SHR %MEM   TIME %CPU  PPID S   PID
    root      192m  13m 8172  0.7   0:00  0.0     1 S  1625
    The percentage of mem used there is partially determined by how much of the total size includes shared memory -- that is, loaded library objects of which GUI libraries tend to form a massive part. Shared memory is good -- it reflects the fact that the system must only load one copy of (eg) libstdc++.so.5; all of the apps which use the C++ library share this memory UNLESS they are using some other version -- which despite what your impressions may be in this regard, is very unusual. 99% of the installed software uses the pre-installed versions of the libraries. You should examine how much your app uses relative to applications that deliver a similar level of function, etc.

    If the GUI on that system is using Qt, which some Integrated Desktop Environments do (KDE I think), by adding a second Qt library because you were too lazy to do a per distro binary package, you will now have an entire extra Qt library (which is much much bigger than your app's binary itself) loaded into memory just for that application! If things like quality, integrity, etc, are not important to you, I guess that is okay.

    Vis. a source package, if you make one using autotools that uses a configure script and a makefile, the user does not have to know anything about linking, etc. -- they just run a configure script. If a library is missing, the script should tell them so they can install it. The script has a range of acceptable Qt versions (since it will probably be fine anywhere with 4.0+, and does not really need exactly 4.5), and the binary is compiled with whichever one is found. There is no point in regarding users as too stupid. But again, if you do a per distribution binary you do not have to worry about this, unless you want to use the source package yourself to make it easier to do the per distro builds. If you have a proper source package, it is even possible to submit it to an official packager who works for the distribution, and that person will probably make a binary package for you (eg, the .rpm). They won't necessarily include it in the distro or keep it in a repository, but they probably will make an official package for you if the source is open and organized in a proper autotools generated source "tarball".

    Of course, that means a little more work but why bother when:
    2) Libraries and distributions are changing too fast and conflicting between versions hurt anybody
    You can just choose the first excuse you find.

    As is, your solution may run into problems if the Qt binary you copy in does not work with the existing glibc or some other dependency, because it was not compiled against them. That is a real and common problem of the closed source apps brewbuck referred to as anyone who as used linux for any period of time will be familiar with (they sometimes simply do not work; you could link everything statically, so your package just got way bigger and will hog even more memory unnecessarily). "Linux" is very diverse; there is no way you will have much success trying to get one single binary to run on every single system. You need to at least compile a couple, eg, one for debian and one for fedora, and possibly one for older and newer release of same since those are at least once a year.

    There is also a 32-bit vs 64 bit question, which will leave you with no choices.

    In reality, if you just wrote this to be used on a couple of particular computers you know about, your method is fine (altho, if this is the case, why don't you just compile the source on each machine yourself?) but please be aware of this memory usage issue.
    Last edited by MK27; 07-29-2009 at 09:54 AM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  8. #23
    Registered User
    Join Date
    Jul 2009
    Posts
    61

    Smile

    Thank you MK27 REALLY
    Your description was just fine, but this sentence:
    If a library is missing, the script should tell them so they can install it
    This can be very hard according to the distribution and the different versions, maybe conflict between versions and so on. I'm writing this program for a private place that handing these matters will be hard for them But still you are right about probable crashing or problems with glibc.

    Thank you again

  9. #24
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by hosseinyounesi View Post
    This can be very hard according to the distribution and the different versions, maybe conflict between versions and so on.
    No, it's actually not that much work -- altho learning to do it the first time is, because autotools is not very well documented anywhere. But once you understand it, it's as simple as this:
    Code:
    # Checks for libraries.
    GTK_REQUIRED_VERSION=2.12.0
    That's the minimum version that is known to work, this goes in "configure.ac". When the configure script generated from this by autoconf is run, if the min development libraries are not installed, you get a message like "configure could not find gtk-lib-devel >= 2.12...aborting". Then you know you have to install your distro's gtk-lib-devel package. Which is the only real hassle about compiling from source -- you do need to have development library headers installed, not just the library runtime packages.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  10. #25
    Registered User
    Join Date
    Jul 2009
    Posts
    61

    Question

    Well, how can make configure and makefile files? I'm now using KDEVELOP, it makes these files but there is a problem: automake versions conflict or is not compatible I solved this problem by using autoreconf -fvi Other IDEs in Linux don't do this
    Any EASY way to do this? Or wayS?

    Thanks

  11. #26
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by hosseinyounesi View Post
    Well, how can make configure and makefile files? I'm now using KDEVELOP, it makes these files but there is a problem: automake versions conflict or is not compatible I solved this problem by using autoreconf -fvi Other IDEs in Linux don't do this
    Any EASY way to do this? Or wayS?
    I don't use an IDE (and I don't program C++) so... Anyway I've only done the whole autotools routine a few times, with things that I actually distributed (and it worked). Here's my notes:
    Code:
    need:
    Makefile.am for each dir
    /configure.ac (could use autoscan)
    
    then in order:
    aclocal
    automake -ac
    autoheader
    automake -ac again
    autoconf
    the actual commands are in bold. The reason for the second automake is that you need to run it before autoheader, but you need the file produced by autoheader (config.h.in) to do the automake properly.

    The only manual work is writing the Makefile.am and configure.ac files. Here are the two links I used and bookmarked:
    Introduction to GNU Build Tools (automake, autoconf, and configure Script)
    GNU Automake By Example
    Plus a little bit reading the man pages. When you're done you have a directory like this:
    Code:
    aclocal.m4  
    autom4te.cache  
    compile      
    configure     
    COPYING   
    install-sh   
    Makefile.in  
    NEWS    
    src/
    AUTHORS     
    ChangeLog       
    config.h.in  
    configure.ac  
    depcomp  
    INSTALL  
    Makefile.am  
    missing
    Most of which autotools does. src/ contains the .c and .h files and another Makefile.am, and the file produced by automake from it, Makefile.in. If you've ever downloaded a source packaged and compiled it this should be familiar (if not, find something and try it, it's easy). Now the end user just unzips the tar ball and types:

    ./configure
    make
    make install


    And maybe gets to watch gcc doing strange things for a minute. The Makefile can contain instructions for installing various components, like documentation, images, etc. in the right places in the filesystem.
    Last edited by MK27; 07-31-2009 at 08:56 AM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  12. #27
    Registered User
    Join Date
    Jul 2009
    Posts
    61

    Thumbs up

    Thank you,

    I'm now going to first learn then try it out

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. dlopen, dlsym does not work in Linux as expected
    By balakv in forum C Programming
    Replies: 2
    Last Post: 04-03-2007, 12:44 AM
  2. SVN Import Causes Crash
    By Tonto in forum Tech Board
    Replies: 6
    Last Post: 11-01-2006, 03:44 PM
  3. Problems adding a user in linux
    By axr0284 in forum Tech Board
    Replies: 1
    Last Post: 12-10-2004, 09:13 AM
  4. installing linux for the first time
    By Micko in forum Tech Board
    Replies: 9
    Last Post: 12-06-2004, 05:15 AM
  5. linux vs linux?
    By Dreamerv3 in forum Linux Programming
    Replies: 5
    Last Post: 01-22-2002, 09:39 AM