LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Alternative to using Linux software package (https://www.linuxquestions.org/questions/linux-software-2/alternative-to-using-linux-software-package-905241/)

manaila 09-27-2011 09:47 AM

Alternative to using Linux software package
 
How can I be able to use the software package without first installing it? To be specific, I want to use xml parser,libxm2(
http://xmlsoft.org/sources/) in the my C code but I dont want to install it.

Nylex 09-27-2011 09:49 AM

You need the headers and shared object files present on your system if you're going to make use of them in your program. Why don't you want to install it? Can you give us more details about the problem you're having?

Nominal Animal 09-27-2011 01:30 PM

If you cannot install it system-wide, you can install it for yourself only in your home directory, and remove it completely afterwards.

Typically this means you configure it using ./configure --prefix=/home/myself/libxml2/ other options... and compile and install it there (as yourself). Check the configure options (with ./configure --help); you'll only need a static version of the library.

To compile your own programs, you'll need to tell the compiler to look for libraries ( -L directory ) and include files ( -I directory ) additionally under the libxml2 directory, in this case most likely using -L /home/myself/libxml2/lib -I /homemyself/libxml2/include .

If you compiled the libxml2 library statically (libxml2.a, I believe), then after compiling and linking your own program, you don't need the libxml2 files any longer.

You can use the ldd command to see which dynamic libraries binaries require at run time. If you follow my advice above, you should not have a dependency on libxml2; it should be included in your binary itself.

manaila 10-24-2011 09:03 AM

Quote:

Originally Posted by Nominal Animal (Post 4483700)
If you compiled the libxml2 library statically (libxml2.a, I believe), then after compiling and linking your own program, you don't need the libxml2 files any longer.

I have installed libcurl and I want to statically link it to my program but its like its not statically linked. This is how I compiled it:
Code:

[root@localhost ~]# curl-config --static-libs
/usr/local/lib/libcurl.a -L/usr/kerberos/lib -lidn -lssl -lcrypto -lldap -lrt -lssl -lcrypto -ldl -lz -lz
[root@localhost ~]# gcc -Wall -L/usr/kerberos/lib -lidn -lssl -lcrypto -lldap -lrt -lssl -lcrypto -ldl -lz -lz -o libcurlEx libcurlEx.c /usr/local/lib/libcurl.a
[root@localhost ~]# ldd libcurlEx
        linux-gate.so.1 =>  (0x00194000)
        libidn.so.11 => /usr/lib/libidn.so.11 (0x00342000)
        libssl.so.6 => /lib/libssl.so.6 (0x00afe000)
        libcrypto.so.6 => /lib/libcrypto.so.6 (0x009bf000)
        libldap-2.3.so.0 => /usr/lib/libldap-2.3.so.0 (0x074ee000)
        librt.so.1 => /lib/librt.so.1 (0x003ac000)
        libdl.so.2 => /lib/libdl.so.2 (0x002aa000)
        libz.so.1 => /lib/libz.so.1 (0x002f6000)
        libc.so.6 => /lib/libc.so.6 (0x003b5000)
        liblber-2.3.so.0 => /usr/lib/liblber-2.3.so.0 (0x071ef000)
        libgssapi_krb5.so.2 => /usr/lib/libgssapi_krb5.so.2 (0x0098f000)
        libkrb5.so.3 => /usr/lib/libkrb5.so.3 (0x00b54000)
        libcom_err.so.2 => /lib/libcom_err.so.2 (0x006e4000)
        libk5crypto.so.3 => /usr/lib/libk5crypto.so.3 (0x00bf3000)
        libresolv.so.2 => /lib/libresolv.so.2 (0x005ac000)
        libsasl2.so.2 => /usr/lib/libsasl2.so.2 (0x073a2000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x002dc000)
        /lib/ld-linux.so.2 (0x00135000)
        libkrb5support.so.0 => /usr/lib/libkrb5support.so.0 (0x00b45000)
        libkeyutils.so.1 => /lib/libkeyutils.so.1 (0x00c1b000)
        libcrypt.so.1 => /lib/libcrypt.so.1 (0x071bf000)

what is it that I missed?

abhishekbatra 10-24-2011 11:46 AM

To answer the original question, you can usually extract the contents of software packages by simply using an unzipping/decompressing tool as they are just a compressed archive. It is still always recommended that they be installed. It would be helpful if you show how you tried to statically link libcurl and what error you encoutered.

manaila 10-25-2011 01:41 AM

Quote:

Originally Posted by abhishekbatra (Post 4506713)
It would be helpful if you show how you tried to statically link libcurl and what error you encoutered.

Hi, abhishekbatra; I think I have shown in the previous post how I statically linked libcurl to my app, unless I don't understand you. Actually, as shown in the post, I did not get an error but when using the ldd command to find the shared library dependencies of the app, it gave me a doubt that my app is not statically linked.


All times are GMT -5. The time now is 09:30 PM.