Mac Ports install of Boost seems not to work
Another easier method is to just use Mac Ports

.
Hi all,
I just completed a Mac Ports install of Boost on my Mac (Leopard).
gcc -v
Using built-in specs.
Target: i686-apple-darwin9
Configured with: /var/tmp/gcc/gcc-5490~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 5490)
All I did was:
> sudo port install boost
It seemed successful. Took a long time, maybe 45 mins. But now when I do a simple program (first.cpp):
#include <iostream>
#include<boost/any.hpp>
int main() {
boost::any a(5);
a = 7.67;
std:cout<<boost::any_cast<double>(a)<<std::endl;
}
and then try to compile:
g++ -o first first.cpp
I get this error:
first.cpp:2:24: error: boost/any.hpp: No such file or directory
first.cpp: In function int main():
first.cpp:4: error: boost has not been declared
first.cpp:4: error: any was not declared in this scope
first.cpp:4: error: expected `;' before a
first.cpp:5: error: a was not declared in this scope
first.cpp:6: error: cout was not declared in this scope
first.cpp:6: error: boost has not been declared
first.cpp:6: error: any_cast was not declared in this scope
first.cpp:6: error: expected primary-expression before double
first.cpp:6: error: expected `;' before double
Clearly, the compiler does not know where to find the new install of Boost.
I have seen several links with glib comments like "just link to this..." or "include that..", but I would deeply appreciate if someone would show me EXACTLY how that sample program should look in order to get it to properly include boost and compile.
When I do "ports info boost", I get back:
boost @1.37.0 (devel)
Variants: darwin, darwin_9, debug, docs, graphml, icu, openmpi, python24, python25, python26, st
Boost provides free portable peer-reviewed C++ libraries. The emphasis is on portable libraries which work well with the C++
Standard Library.
Homepage:
http://www.boost.org
Build Dependencies: boost-jam, gmake
Library Dependencies: zlib, bzip2
Platforms: darwin
Maintainers: sancho*****gmail
I'm convinced that I am simply new and naive and am missing something so simple that an idiot should know it. If someone has successfully installed Boost using Mac Ports, please explain to me precisely why this did not work. I am really stumped. I saw the other "tutorials" but my results do not match.
The most frustrating part is not understanding how to confirm the install, other than to successfully use Boost in a program. Most tutorials say "here's what you SHOULD see" and don't delve into "here's how to figure out what is wrong if you don't".
I esp need to use boost/regex.hpp and can't simply #include<boost/regex.hpp>. It's not that easy!
Best regards, thanks in advance,
John