Re: Problem with libiconv

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thank you Mr. Glisse.

My libiconv.so file is in /usr/local/lib and it's a shared library.
How do I compile the source foo.c which contains iconv.h header? I
normally compile like this, 'gcc  -Wall -g foo.c -o foo' . I used
'gcc  -Wall -g -I/usr/local/lib foo.c -o foo' . but still there's same
error. Tried with  'gcc  -Wall -g -I/usr/local/include foo.c -o foo' ,
still the problem persists.


Rifat Mahmud

On Wed, Nov 3, 2010 at 5:02 PM, Marc Glisse <marc.glisse@xxxxxxxx> wrote:
> On Wed, 3 Nov 2010, Rifat Mahmud wrote:
>
>> I installed libiconv and used '#include<iconv.h>' in a source code.
>> After compiling gcc prints
>>
>> /tmp/ccgsye0A.o: In function `main':
>> /home/rifat/Documents/Sources/test1.c:12: undefined reference to
>> `libiconv_open'
>
> That's normal. When you want to use external functionality in a program, you
> need 2 things: a #include to tell your code about the interface of that
> functionality and a corresponding -l flag on the command line telling which
> library to take the functionality from.
> #include <math.h>  ----> gcc ... -lm
> #include <stdlib.h> ----> gcc ... -lc (this one is actually implicit)
> #include <iconv.h> ----> gcc ... -liconv (if you are using the iconv.h from
> libiconv, -lc otherwise)
>
>> How can I solve this problem. I probably didn't overwrite the system
>> iconv.h file, which is in /usr/local/include . I'm very much a rookie
>> in gcc, please help me out, Thank you.
>
> I doubt the system iconv.h is in /usr/local.
>
> --
> Marc Glisse
>



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux