Mailing List Archive

Liniking problem
Hello,

Sorry for bother you again with lame question, but I'm stuck on linking with
libspf2.

I got these errors:

g++ -L/usr/local/lib -o"CstpSpf" ./src/SpfResolver.o ./src/cstp_spf.o
-lspf2
./src/SpfResolver.o: In function `SpfResolver':
/home/dunmer/workspace/CstpSpf/Debug/../src/SpfResolver.cpp:14: undefined
reference to `SPF_dns_resolv_new(SPF_dns_server_struct*, char const*, int)'
/home/dunmer/workspace/CstpSpf/Debug/../src/SpfResolver.cpp:16: undefined
reference to `SPF_dns_cache_new(SPF_dns_server_struct*, char const*, int,
int)'
/home/dunmer/workspace/CstpSpf/Debug/../src/SpfResolver.cpp:17: undefined
reference to `SPF_dns_set_conserve_cache(SPF_dns_server_struct*, int)

With this simple code:

this->spfResolvServer = SPF_dns_resolv_new(NULL, "spfResolv", DEBUG);
this->spfCacheServer = SPF_dns_cache_new(this->spfResolvServer, "spfCache",
DEBUG, CACHE_SIZE);
SPF_dns_set_conserve_cache(this->spfCacheServer, CACHE_CONSERVE);

DEBUG, CACHE_CONSERVE and CACHE_SIZE are my constants.
I have built and installed libspf and its located in /usr/local/lib. I tried
to move it to the /usr/lib with no success. I'm using Eclipse for C/C++ and
I have set libspf2 in libraries.
What am I doing wrong? Google didn't help. And what is with libspf2.org?

I will really appreciate your help. Thank you very much!



-------------------------------------------
Sender Policy Framework: http://www.openspf.org [http://www.openspf.org]
Modify Your Subscription: http://www.listbox.com/member/ [http://www.listbox.com/member/]

Archives: https://www.listbox.com/member/archive/735/=now
RSS Feed: https://www.listbox.com/member/archive/rss/735/1311532-17d8a1ba
Modify Your Subscription: https://www.listbox.com/member/?member_id=1311532&id_secret=1311532-f2ea6ed9
Unsubscribe Now: https://www.listbox.com/unsubscribe/?member_id=1311532&id_secret=1311532-bdbb122a&post_id=20101121162949:76A406EC-F5B6-11DF-B910-AE06C6F4DBAC
Powered by Listbox: http://www.listbox.com
Re: Liniking problem [ In reply to ]
On Sun, 21 Nov 2010, Dunmer wrote:

> Hello,
>
> Sorry for bother you again with lame question, but I'm stuck on linking with
> libspf2.
>
> I got these errors:
>
> g++ -L/usr/local/lib -o"CstpSpf" ./src/SpfResolver.o ./src/cstp_spf.o
> -lspf2
> ./src/SpfResolver.o: In function `SpfResolver':
> /home/dunmer/workspace/CstpSpf/Debug/../src/SpfResolver.cpp:14: undefined
> reference to `SPF_dns_resolv_new(SPF_dns_server_struct*, char const*, int)'
> /home/dunmer/workspace/CstpSpf/Debug/../src/SpfResolver.cpp:16: undefined
> reference to `SPF_dns_cache_new(SPF_dns_server_struct*, char const*, int,
> int)'
> /home/dunmer/workspace/CstpSpf/Debug/../src/SpfResolver.cpp:17: undefined
> reference to `SPF_dns_set_conserve_cache(SPF_dns_server_struct*, int)
>
> With this simple code:
>
> this->spfResolvServer = SPF_dns_resolv_new(NULL, "spfResolv", DEBUG);
> this->spfCacheServer = SPF_dns_cache_new(this->spfResolvServer, "spfCache",
> DEBUG, CACHE_SIZE);
> SPF_dns_set_conserve_cache(this->spfCacheServer, CACHE_CONSERVE);
>
> DEBUG, CACHE_CONSERVE and CACHE_SIZE are my constants.
> I have built and installed libspf and its located in /usr/local/lib. I tried
> to move it to the /usr/lib with no success. I'm using Eclipse for C/C++ and
> I have set libspf2 in libraries.
> What am I doing wrong? Google didn't help. And what is with libspf2.org?
>
> I will really appreciate your help. Thank you very much!

Not sure whats going on, libspf2 has those symbols on my box and i can
link a simple program (attached) with:

gcc -o fish -I/usr/local/include -L/usr/local/lib -lspf2 foo.c

It could be that your -o"CstpSpf" is being miss interpreted and needs a
space?

P.S. you can use 'ldd' to see which libraries a lib or binary is linked
against and 'nm' to see which symbols a library or program exports or
defines.

--
[http://pointless.net/] [0x2ECA0975]


-------------------------------------------
Sender Policy Framework: http://www.openspf.org [http://www.openspf.org]
Modify Your Subscription: http://www.listbox.com/member/ [http://www.listbox.com/member/]

Archives: https://www.listbox.com/member/archive/735/=now
RSS Feed: https://www.listbox.com/member/archive/rss/735/1311532-17d8a1ba
Modify Your Subscription: https://www.listbox.com/member/?member_id=1311532&id_secret=1311532-f2ea6ed9
Unsubscribe Now: https://www.listbox.com/unsubscribe/?member_id=1311532&id_secret=1311532-bdbb122a&post_id=20101121184535:6E40C9E6-F5C9-11DF-8ADC-2C0CC6F4DBAC
Powered by Listbox: http://www.listbox.com
Re: Liniking problem [ In reply to ]
Thank you very much Jasper!

I can compile and link your foo.c without any problem, but I really don't
understand how it is possible.
Still can't compile my code and it's basically the same as yours, but in
three files (.h, .cpp and hello world main).

One diference:
You are using just #include <spf2/spf.h>, I'm using:

#include <spf2/spf.h>
#include <spf2/spf_dns.h>
#include <spf2/spf_dns_cache.h>
#include <spf2/spf_dns_resolv.h>

If I omit those 3, i got this error on compilation (so i don't even get to
linking):

Building file: ../src/SpfResolver.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/SpfResolver.d"
-MT"src/SpfResolver.d" -o"src/SpfResolver.o" "../src/SpfResolver.cpp"
../src/SpfResolver.cpp: In constructor
‘CstpSpf::SpfResolver::SpfResolver()’:
../src/SpfResolver.cpp:14:69: error: ‘SPF_dns_resolv_new’ was not declared
in this scope
../src/SpfResolver.cpp:16:95: error: ‘SPF_dns_cache_new’ was not declared in
this scope
../src/SpfResolver.cpp:17:65: error: ‘SPF_dns_set_conserve_cache’ was not
declared in this scope
make: *** [src/SpfResolver.o] Error 1

Missing space after -o isn't problem if you use quotes.
nm output contains ‘SPF_dns_resolv_new’, ‘SPF_dns_cache_new’
and ‘SPF_dns_set_conserve_cache’ too..

I'm attaching my three files, please look at them and try compile them,
maybe you will see where's the problem, because I am little desperate.
Thank you!

2010/11/22 Jasper Wallace <jasper@pointless.net>

> On Sun, 21 Nov 2010, Dunmer wrote:
>
> > Hello,
> >
> > Sorry for bother you again with lame question, but I'm stuck on linking
> with
> > libspf2.
> >
> > I got these errors:
> >
> > g++ -L/usr/local/lib -o"CstpSpf" ./src/SpfResolver.o ./src/cstp_spf.o
> > -lspf2
> > ./src/SpfResolver.o: In function `SpfResolver':
> > /home/dunmer/workspace/CstpSpf/Debug/../src/SpfResolver.cpp:14: undefined
> > reference to `SPF_dns_resolv_new(SPF_dns_server_struct*, char const*,
> int)'
> > /home/dunmer/workspace/CstpSpf/Debug/../src/SpfResolver.cpp:16: undefined
> > reference to `SPF_dns_cache_new(SPF_dns_server_struct*, char const*, int,
> > int)'
> > /home/dunmer/workspace/CstpSpf/Debug/../src/SpfResolver.cpp:17: undefined
> > reference to `SPF_dns_set_conserve_cache(SPF_dns_server_struct*, int)
> >
> > With this simple code:
> >
> > this->spfResolvServer = SPF_dns_resolv_new(NULL, "spfResolv", DEBUG);
> > this->spfCacheServer = SPF_dns_cache_new(this->spfResolvServer,
> "spfCache",
> > DEBUG, CACHE_SIZE);
> > SPF_dns_set_conserve_cache(this->spfCacheServer, CACHE_CONSERVE);
> >
> > DEBUG, CACHE_CONSERVE and CACHE_SIZE are my constants.
> > I have built and installed libspf and its located in /usr/local/lib. I
> tried
> > to move it to the /usr/lib with no success. I'm using Eclipse for C/C++
> and
> > I have set libspf2 in libraries.
> > What am I doing wrong? Google didn't help. And what is with libspf2.org?
> >
> > I will really appreciate your help. Thank you very much!
>
> Not sure whats going on, libspf2 has those symbols on my box and i can
> link a simple program (attached) with:
>
> gcc -o fish -I/usr/local/include -L/usr/local/lib -lspf2 foo.c
>
> It could be that your -o"CstpSpf" is being miss interpreted and needs a
> space?
>
> P.S. you can use 'ldd' to see which libraries a lib or binary is linked
> against and 'nm' to see which symbols a library or program exports or
> defines.
>
> --
> [http://pointless.net/] [0x2ECA0975]



-------------------------------------------
Sender Policy Framework: http://www.openspf.org [http://www.openspf.org]
Modify Your Subscription: http://www.listbox.com/member/ [http://www.listbox.com/member/]

Archives: https://www.listbox.com/member/archive/735/=now
RSS Feed: https://www.listbox.com/member/archive/rss/735/1311532-17d8a1ba
Modify Your Subscription: https://www.listbox.com/member/?member_id=1311532&id_secret=1311532-f2ea6ed9
Unsubscribe Now: https://www.listbox.com/unsubscribe/?member_id=1311532&id_secret=1311532-bdbb122a&post_id=20101122062134:A8D0E54E-F62A-11DF-98BC-8B776BDBCF6D
Powered by Listbox: http://www.listbox.com
Re: Liniking problem [ In reply to ]
Hi!

On Mon, Nov 22, 2010 at 12:21:29PM +0100, Dunmer wrote:
>Thank you very much Jasper!

>I can compile and link your foo.c without any problem, but I really don't
>understand how it is possible.
>Still can't compile my code and it's basically the same as yours, but in
>three files (.h, .cpp and hello world main).
^^^

That's the actual hint to your problem, rather than your different
includes.

Try ...

>One diference:
>You are using just #include <spf2/spf.h>, I'm using:

extern "C" {

// before your includes and ...

>#include <spf2/spf.h>
>#include <spf2/spf_dns.h>
>#include <spf2/spf_dns_cache.h>
>#include <spf2/spf_dns_resolv.h>

// ...
}
// after your includes.

>If I omit those 3, i got this error on compilation (so i don't even get to
>linking):

Of course, as you seem to use special DNS stuff.

>[... Compile errors snipped. ...]

Kind regards,

Hannah.


-------------------------------------------
Sender Policy Framework: http://www.openspf.org [http://www.openspf.org]
Modify Your Subscription: http://www.listbox.com/member/ [http://www.listbox.com/member/]

Archives: https://www.listbox.com/member/archive/735/=now
RSS Feed: https://www.listbox.com/member/archive/rss/735/1311532-17d8a1ba
Modify Your Subscription: https://www.listbox.com/member/?member_id=1311532&id_secret=1311532-f2ea6ed9
Unsubscribe Now: https://www.listbox.com/unsubscribe/?member_id=1311532&id_secret=1311532-bdbb122a&post_id=20101122065207:EF817D1A-F62E-11DF-905F-9697F559ED1D
Powered by Listbox: http://www.listbox.com
Re: Liniking problem [ In reply to ]
Thank you, that did the trick. I have wrote some code in C/C++ but never
used 'extern "C" { }' statement..

And about includes: Jasper is using the same functions as me without
additional includes..

Thank you guys again.

2010/11/22 <hannah@schlund.de>

> Hi!
>
> On Mon, Nov 22, 2010 at 12:21:29PM +0100, Dunmer wrote:
> >Thank you very much Jasper!
>
> >I can compile and link your foo.c without any problem, but I really don't
> >understand how it is possible.
> >Still can't compile my code and it's basically the same as yours, but in
> >three files (.h, .cpp and hello world main).
> ^^^
>
> That's the actual hint to your problem, rather than your different
> includes.
>
> Try ...
>
> >One diference:
> >You are using just #include <spf2/spf.h>, I'm using:
>
> extern "C" {
>
> // before your includes and ...
>
> >#include <spf2/spf.h>
> >#include <spf2/spf_dns.h>
> >#include <spf2/spf_dns_cache.h>
> >#include <spf2/spf_dns_resolv.h>
>
> // ...
> }
> // after your includes.
>
> >If I omit those 3, i got this error on compilation (so i don't even get to
> >linking):
>
> Of course, as you seem to use special DNS stuff.
>
> >[... Compile errors snipped. ...]
>
> Kind regards,
>
> Hannah.
>
>
> -------------------------------------------
> Sender Policy Framework: http://www.openspf.org [http://www.openspf.org]
> Modify Your Subscription: http://www.listbox.com/member/ [
> http://www.listbox.com/member/]
>
> Archives: https://www.listbox.com/member/archive/735/=now
> RSS Feed: https://www.listbox.com/member/archive/rss/735/19988005-5ed625ad
> Modify Your Subscription:
> https://www.listbox.com/member/?&
> Unsubscribe Now:
> https://www.listbox.com/unsubscribe/?&&post_id=20101122065207:EF817D1A-F62E-11DF-905F-9697F559ED1D
> Powered by Listbox: http://www.listbox.com
>



-------------------------------------------
Sender Policy Framework: http://www.openspf.org [http://www.openspf.org]
Modify Your Subscription: http://www.listbox.com/member/ [http://www.listbox.com/member/]

Archives: https://www.listbox.com/member/archive/735/=now
RSS Feed: https://www.listbox.com/member/archive/rss/735/1311532-17d8a1ba
Modify Your Subscription: https://www.listbox.com/member/?member_id=1311532&id_secret=1311532-f2ea6ed9
Unsubscribe Now: https://www.listbox.com/unsubscribe/?member_id=1311532&id_secret=1311532-bdbb122a&post_id=20101122075015:0CD9C004-F637-11DF-9A2A-B165F559ED1D
Powered by Listbox: http://www.listbox.com