Boost logo

Boost Users :

From: atifm (atifvelocity_at_[hidden])
Date: 2008-08-27 22:07:43


Looks like you might be using the wrong bind.

Instead of the following header:
#include <boost/bind.hpp>

Try this header from the lambda package:
#include <boost/lambda/bind.hpp>

Had the same problem earlier today, and it corrected it.

Good luck
-Atif

Ken Smith-8 wrote:
>
> Here is my environment.
>
> % g++ -v
> Using built-in specs.
> Target: i686-apple-darwin9
> Configured with: /var/tmp/gcc/gcc-5483~1/src/configure
> --disable-checking -enable-werror --prefix=/usr --mandir=/share/man
> --enable-languages=c,objc,c++,obj-c++
> --program-transform-name=/^[cg][^.-]*$/s/$/-4.0/
> --with-gxx-include-dir=/include/c++/4.0.0 --with-slibdir=/usr/lib
> --build=i686-apple-darwin9 --with-arch=apple --with-tune=generic
> --host=i686-apple-darwin9 --target=i686-apple-darwin9
> Thread model: posix
> gcc version 4.0.1 (Apple Inc. build 5483)
>
> Boost 1.35.0
> (also produced same issue with Boost 1.34.1)
>
> Here is the code.
>
> 1 #include <boost/lambda/lambda.hpp>
> 2 #include <boost/lambda/construct.hpp>
> 3 #if defined(INCLUDE_BOOST_BIND)
> 4 # include <boost/bind.hpp>
> 5 #endif
> 6 #include <iostream>
> 7 #include <iterator>
> 8 #include <algorithm>
> 30
> 31 int main()
> 32 {
> 33 using namespace std;
> 34 using namespace boost::lambda;
> 35
> 36 typedef std::istream_iterator<int> in;
> 37 std::for_each(in(std::cin), in(), std::cout << (_1 * 3) << " " );
> 76 }
>
> (The astute reader will note discontinuity in the line numbering.
> This is a playground for my exploration with boost. All elided lines
> are #if 0'ed.
>
> Here is the compile command line and the compilation error, both
> edited for clarity.
> g++ -c -g -Wall -fexceptions -DINCLUDE_BOOST_BIND
> -I/path/to/boost-1.35.0/include main.cpp -o main.o
> main.cpp: In function 'int main()':
> main.cpp:37: error: '_1' was not declared in this scope
>
> I have seen these related articles from the archives of this list but
> none of the suggestions eliminated the error. I added the inclusion
> of boost/lambda/construct.hpp per one of the suggestions there. Its
> inclusion or exclusion doesn't change the behavior.
>
> http://thread.gmane.org/gmane.comp.lib.boost.user/35128
> http://thread.gmane.org/gmane.comp.lib.boost.user/16630
> http://thread.gmane.org/gmane.comp.lib.boost.user/16887
>
> As you may imagine, the elided (and commented out) lines contain
> actual uses of boost/bind.hpp but it is a mystery to me that simple
> inclusion of a header file would cause otherwise working code to stop
> compiling.
>
> This compile command (same as above but with -D removed):
>
> g++ -c -g -Wall -fexceptions -I/path/to/boost-1.35.0/include main.cpp -o
> main.o
>
> runs to completion and the subsequent link is successful.
>
> Any ideas?
>
> Thanks in advance,
> Ken
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>

-- 
View this message in context: http://www.nabble.com/Simply-including-boost-bind.hpp-causes-compilation-error-tp17164341p19193087.html
Sent from the Boost - Users mailing list archive at Nabble.com.

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net