Question

With JVMTI I am developing an agent to profile Java applications. Therefore a shared library libagent.so is compiled. Further I use the Qt framework:

For now it consists only by these two source files: agent.cpp and agentserver.cpp

However, when starting a Java application with my shared library libagent.so I get the error: undefined symbol: _ZTV11AgentServer (./libagent.so)

When I run ldd I get the same dependency problem:

ldd -d libagent.so 
linux-vdso.so.1 =>  (0x00007fffeb333000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007f8b6731b000)
libm.so.6 => /lib/libm.so.6 (0x00007f8b67098000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00007f8b66e81000)
libc.so.6 => /lib/libc.so.6 (0x00007f8b66afe000)
/lib64/ld-linux-x86-64.so.2 (0x00007f8b67844000)
undefined symbol: _ZTV11AgentServer (./libagent.so)

My current compile command is:

g++ $(CXXFLAGS) -fPIC -shared -o libagent.so $(INCPATH) ../src/agent.cpp ../src/agentserver.cpp

Where $(CXXFLAGS) is -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)

where $(DEFINES) is -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED

where $(INCPATH) is -I/home/konrad/qtsdk-2010.05/qt/mkspecs/linux-g++-64 -I../src -I/home/konrad/qtsdk-2010.05/qt/include/QtCore -I/home/konrad/qtsdk-2010.05/qt/include/QtNetwork -I/home/konrad/qtsdk-2010.05/qt/include/QtGui -I/home/konrad/qtsdk-2010.05/qt/include -I/usr/lib/jvm/java-6-openjdk/include -I/usr/lib/jvm/java-6-openjdk/include/linux -I. -I. -I../src -I.

I have put some time into researching this problems, but none solved this error.


This is the header code of the agentserver.cpp: agentserver.h

Was it helpful?

Solution

The error message is telling you that some element in AgentServer's vtable is undefined. The use of Q_OBJECT requires you to run moc on your source - and link to the qt libraries.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top