kripken/emscripten — Issue #105: string doesn't export inside LLVM file
Author: BenoitT
Created: 2011-10-24 16:07:15+00:00
State: open

I'm using:

Windows 7 (no Cygwin or anything)
LLVM 3.0
EMScripten 3.0.71

Here is the code
=====
#include
#include

int main()
{
std::string s = "Test\n";
printf(s.c_str());

return 0;
}

Here is the error from Bugzilla
========
__ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcj is not a function
[Stopper sur une erreur] __ZNSt3__112basic_stringIcNS_1...torIcEEE6__initEPKcj($32, $50, $54);
Game.js (ligne 1440)
__ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcj is not a function
[Stopper sur une erreur] __ZNSt3__112basic_stringIcNS_1...torIcEEE6__initEPKcj($32, $50, $54);

Here is the definition of the missing function inside .ll file
=======
declare void @_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcj(%"class.std::__1::basic_string"*, i8*, i32)

Demangled version
=======
std::__1::basic_string, std::allocator >::__init(char const*, unsigned int)($17, $35, $39)

The function __init is not exported. I use the embeded headers and I don't know why it don't. The destructor seems to have the same problem.