MacPorts installs C/C++ headers in /opt/local/include directory which is not the system default. It means that you have to explicitly tell GCC where to look for headers you are using. You can do that by specifying "-isystem" or "-I" command line options:
-isystem dir
Search dir for header files, after all directories specified
by -I but before the standard system
directories. Mark it as a system
directory, so that it gets the same special treatment as is
applied to the standard system
directories. If dir begins with "=",
then
the "=" will be replaced by the sysroot prefix; see --sysroot and
-isysroot.
-Idir
Add the directory dir to the head of the list of directories to
be searched for header files. This
can be used to override a system
header file, substituting your own version, since these
directories are searched before the
system header file directories.
However,
you should not use this option to add directories that contain
vendor-supplied system header files
(use -isystem for that). If you
use more than one -I option, the directories are scanned in
left-to-right order; the standard
system directories come after.
If a standard system include directory, or a directory
specified with -isystem, is also
specified with -I, the -I option will
be
ignored. The directory will still be searched but as a system
directory at its normal position in
the system include chain. This is
to ensure that GCC's procedure to fix buggy system headers
and the ordering for the include_next
directive are not inadvertently
changed. If you really need to change the search order for
system directories, use the -nostdinc
and/or -isystem options.
I recommend using -isystem because it disables some warnings you cannot fix without modifying the code. For example, using std::auto_ptr if you compile your code with -std=c++0x etcetera.
The same goes for libraries. You have to tell GCC where to find them using -L option.