This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Bug on gcc with dlopen()
- From: Lionel Champalaune <Lionel dot Champalaune at sophia dot inria dot fr>
- To: bug-gcc at gnu dot org
- Date: Thu, 01 Aug 2002 09:34:42 +0200
- Subject: Bug on gcc with dlopen()
- Organization: INRIA Sophia Antipolis
Originator: Lionel Champalaune
Organization: INRIA Sophia Antipolis
Synopsis: problem on opening a shared library
Severity: non-critical
Priority: medium
Category: C++
Class: wrong-code
Release: GCC 3.1.1
Environment: i686-pc-linux
Description:
An error message appear when a shared library is opened.
> Error: ./libTestlib.so: undefined symbol:
_ZNSt19basic_ostringstreamIcSt11char_traitsIcESaIcEEC1ESt13_Ios_Openmode
This problem didn't appear with the 3.1 version.
Libtool is used, and it's in the generated compilation that the bug
appears.
This problem doesn't appear when the -g option to gcc is given.
By using g++ instead of gcc, the problem disappear. gcc is used by
libtool in a looklike utilization.
How-To-Repeat:
run the file Command:
>./Commandgcc
Fix:
Used g++ instead pf gcc in the second line:
>./Commandg++
#include <string>
#include <sstream>
void f()
{
std::ostringstream ost;
ost << "toto";
const std::string s = ost.str();
}
#include <dlfcn.h>
#include <iostream>
int
main()
{
void *handle = dlopen ("./libTestlib.so", RTLD_NOW);
char *error;
if ((error = dlerror())!=0) {
std::cerr << " Error: " << error << std::endl;
return 1;
}
}
g++ -c -o Testlib.lo Testlib.C
g++ -shared Testlib.lo -Wl,-soname -Wl,libTestlib.so -o libTestlib.so
g++ Testmain.C -ldl
./a.out
g++ -c -o Testlib.lo Testlib.C
gcc -shared Testlib.lo -Wl,-soname -Wl,libTestlib.so -o libTestlib.so
g++ Testmain.C -ldl
./a.out