Re: ld & my Makefile

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

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Mohsen Pahlevanzadeh wrote:
> I used g++ instead gcc -x c++. When i use -llibstdc++ at the end of
> link line , i receive following lines:
> ////////////////////////////////////////////////////////////////////
>  g++ -o urldump  urldump.o base64.o buf.o pcaputil.o chksum_ctl.o
> postgres.o linked_list.o   -lresolv -lnsl -lrpcsvc  -lpcap -lnet
> -lnids -L. -lpq -lpthread -llibstdc++ postgres.o:(.data+0x0):
> multiple definition of `conninfo'
> urldump.o:/home/mohsen/workspace/urldump/./urldump.c:309: first
> defined here /usr/bin/ld: cannot find -llibstdc++ collect2: ld
> returned 1 exit status make: *** [urldump] Error 1
>
> ////////////////////////////////////////////////////////////////////////
>
>
>
> And when i remove -llibstdc++ from the end of link line , i receive
>  following lines:
>
> //////////////////////////////////////////////////////////////////////////////
>  urldump.o: In function `flushing(void*)': urldump.c:(.text+0xce):
> undefined reference to `flush_to_db(int)' urldump.o: In function
> `process_http_request(tuple4*, unsigned char*, int)':
> urldump.c:(.text+0x359): undefined reference to `buf_init(buf*,
> unsigned char*, int)' urldump.c:(.text+0x378): undefined reference
> to `buf_tok(buf*, void*, int)' urldump.c:(.text+0x3a7): undefined
> reference to `buf_seek(buf*, int, int)' urldump.c:(.text+0x4f0):
> undefined reference to `base64_pton(char const*, unsigned char*,
> unsigned int)' urldump.c:(.text+0x5fe): undefined reference to
> `buf_tok(buf*, void*, int)' urldump.c:(.text+0x653): undefined
> reference to `libnet_host_lookup(unsigned long, unsigned short)'
> urldump.c:(.text+0x693): undefined reference to
> `libnet_host_lookup(unsigned long, unsigned short)'
> urldump.c:(.text+0x6b1): undefined reference to
> `libnet_host_lookup(unsigned long, unsigned short)'
> urldump.c:(.text+0x6d1): undefined reference to
> `filling_node(char*, char*, char*, char*, char*)'
> urldump.c:(.text+0x6ec): undefined reference to `buf_index(buf*,
> void*, int)' urldump.o: In function `main':
> urldump.c:(.text+0x8d9): undefined reference to `strconcat(char*,
> ...)' urldump.c:(.text+0x8e3): undefined reference to
> `pg_connect()' urldump.c:(.text+0xa15): undefined reference to
> `copy_argv(char**)' collect2: ld returned 1 exit status make: ***
> [urldump] Error 1
> ///////////////////////////////////////////////////////////////////
>
>
> What's happen? On Tue, 2009-10-13 at 14:25 -0700, Ian Lance Taylor
> wrote:
>> Mohsen Pahlevanzadeh <mohsen@xxxxxxxxxxxxxxxxx> writes:
>>
>>> On Tue, 2009-10-13 at 08:05 -0700, Ian Lance Taylor wrote:
>>>> Mohsen Pahlevanzadeh <mohsen@xxxxxxxxxxxxxxxxx> writes:
>>>>
>>>>> I wrote a program in C, Not C++.It work good.But when i use
>>>>> "-x c++" in Makefile, i receive following errors:
>>>> You have to link with the g++ driver.  Yes, this is
>>>> confusing.
>>>>
>>>>> CC      = gcc CFLAGS  =  -g  -Wall  -pthread
>>>>> -DHAVE_NET_ETHERNET_H -DLIBNET_LIL_ENDIAN
>>>>> -DDSNIFF_LIBDIR=\"$(libdir)/\" CPP     = -x c++ -llibstcd++
>>>>>
>>>> If you use this approach, -llibstdc++ must come at the end of
>>>> the link line.
>>>
>>> How do i solve my problem?I must use C++ not C,So i mandatory
>>> use g++ or -x c++.
>> I recommend that you use "g++" rather than "gcc -x c++".
>>
>> Ian
Ian is right, though I think your getting confused in how this works a
little you might want to try using automake to generate makefiles for
your project, so to make sure its done right.

- --Phil
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkrV52cACgkQAhcOgIaQQ2FdnACeKEXZvCNgyeptuLNStjasrGYC
ynIAn3Vaw7BHlyIdsAfaVGW/qqK7P2lN
=vUyS
-----END PGP SIGNATURE-----


[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