This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Bug on gcc with dlopen()


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]