stdlib.h and unresolved externals
I'm working on a small jni project where and I'm trying to get the shared object to link up correctly. I was able to get it to work just fine until I added a reference to a std call. For example:
c code:
JNIEXPORT jint JNICALL Java_JNITest_gduif_1init (JNIEnv *env, jobject obj, jint flags){
std::string str = "test";
return flags;
}
My compile code is as follows
gcc34 -fPIC -I$JAVA_HOME/include -I$JAVA_HOME/include/linux -shared -o ../jnilibs/libJNITest.so JNITest.cpp
this code produces the following when i call nm -- demangle libJNITest.so
000017a4 d DW.ref.__gxx_personality_v0
00000540 T Java_JNITest_gduif_1init
000016a0 a _DYNAMIC
00001774 a _GLOBAL_OFFSET_TABLE_
w _Jv_RegisterClasses
U _Unwind_Resume@@GCC_3.0
U std::allocator<char>::allocator()
U std::allocator<char>::~allocator()
U std::basic_string<char, std::char_traits><char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)
U std::basic_string<char, std::char_traits><char>, std::allocator<char> >::~basic_string()
00001690 d __CTOR_END__
0000168c d __CTOR_LIST__
00001698 d __DTOR_END__
00001694 d __DTOR_LIST__
0000067c r __FRAME_END__
0000169c d __JCR_END__
0000169c d __JCR_LIST__
000017a8 A __bss_start
w __cxa_finalize@@GLIBC_2.1.3
000005cc t __do_global_ctors_aux
000004a8 t __do_global_dtors_aux
0000179c d __dso_handle
w __gmon_start__
U __gxx_personality_v0
000017a8 A _edata
000017ac A _end
000005fc T _fini
000003e8 T _init
00000480 t call_gmon_start
000017a8 b completed.1
00000504 t frame_dummy
000017a0 d p.0
It appears that the reference to std::string are causing some unresolved externals. I saw an example somewhere where someone used a --add-stdcall-alias option to their compile line, however I get errors saying that option is not valid for /usr/bin/ld
Anyone else have problems when using <stdlib.h> with jni code?
System specs:
Fedora Core 6
gcc 4.1.1
GNU ld version 2.17.50.0.6-2.fc6 20061020

