On 12/20/06, Bo Peng
$ g++ -static -lboost_iostreams -lz -lbz2 test.cpp fails, and
$ g++ -static test.cpp -lboost_iostreams -lz -lbz2 succeeds. Why did
$ g++ -shared -lboost_iostream -lz -lbz2 test.cpp succeed is beyond me.
When you use static libraries, only the symbols you need are taken from the static libraries. In the first command line, it performs that process before compiling test.cpp, so no symbols are needed, so none are taken. In the second, it compiles test.cpp first so it knows which symbols you need from the static libraries. For the third case, linking to shared libraries doesn't only take the symbols needed, for obvious reasons, so all the symbols you need (and those you don't) are defined before test.cpp gets compiled. ~ Scott McMurray