Boost logo

Boost :

From: Boris Gubenko (Boris.Gubenko_at_[hidden])
Date: 2007-09-14 23:44:07


Beman Dawes wrote:
> Does anyone know what's going on here? Am I supposed to be passing some
> additional options to g++ when building or using shared libraries?

Well, you may need to set LD_LIBRARY_PATH env. variable or equivalent,
or link with -rpath. However, if callee.dll could not be found in runtime,
I'd expect a message from loader instead of a crash. For example, on a
Linux system:

bash-3.00$ g++ -o dll_test caller.cpp -L. -lcallee
bash-3.00$ dll_test
dll_test: error while loading shared libraries: libcallee.so: cannot open shared
object file: No such file or directory
bash-3.00$ export LD_LIBRARY_PATH=.
bash-3.00$ dll_test
all's well that ends well
bash-3.00$ export LD_LIBRARY_PATH=
bash-3.00$ g++ -Wl,-rpath . -o dll_test caller.cpp -L. -lcallee
bash-3.00$ dll_test
all's well that ends well
bash-3.00$

Anyway, I tried your example on HP-UX/ia64 with gcc 4.2.1 and it
worked, both static and dll.

Thanks,
  Boris

----- Original Message -----
From: "Beman Dawes" <bdawes_at_[hidden]>
To: "Boost mailing list" <boost_at_[hidden]>
Sent: Friday, September 14, 2007 4:15 PM
Subject: [boost] [gcc] bug causing filesystem crashes

> Below is a little program, made up of two files. It's a reduction of
> code causing filesystem crashes when compiled with g++ on some, but not
> all, platforms that gcc supports. It works fine with other compilers.
>
> The static version works fine, even with g++, and outputs "all's well
> that ends well".
>
> dll_test stackdumps at the line marked with the comment.
>
> Does anyone know what's going on here? Am I supposed to be passing some
> additional options to g++ when building or using shared libraries?
>
> Thanks,
>
> --Beman
>
> callee.cpp
> ==========
>
> #include <string>
>
> void f( std::string & s )
> {
> s = "all's well that ends well"; // dll_test crash!
> }
>
> caller.cpp
> ==========
>
> #include <string>
> #include <iostream>
>
> void f( std::string & s );
>
> int main()
> {
> std::string s;
> f(s);
> std::cout << s << std::endl;
> return 0;
> }
>
> Compile and test (cygwin)
> =========================
>
> g++ -o static_test caller.cpp callee.cpp
> static_test
>
> g++ -c callee.cpp
> g++ -shared -o callee.dll callee.o
> g++ -o dll_test caller.cpp -L./ -lcallee
> dll_test
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk