[Paraview] problem connecting to external c library

Brad King brad.king at kitware.com
Fri Nov 19 19:42:15 EST 2004


RAVINDRANATH LANKA wrote:
> I am writing a custom reader, vtkMyReader.cxx, that is referring to 
> functions from an external C library.
> I copied the  .cxx and .h files to VTK/IO directory.
> 
> I added the following to the CMakeLists.txt
> 
> INCLUDE_DIRECTORIES(/usr/local/myIncludes/)
> ADD_DEFINITIONS(-DMY_DEFINITIONS)
> TARGET_LINK_LIBRARIES( vtk${KIT} ${KIT_LIBS} /usr/local/myLibs/libLocal.a)
> 
> I also had to add the "INCLUDE_DIRECTORIES" and "ADD_DEFINITIONS" to 
> paraview*/CMakeLists.txt as 
> paraview*/Utilities/VTKClientServer/IO/Makefile required these values.
> 
> When I try to build paraview, I am getting the following error.
> -------------------------------------------------------------------------------------------------- 
> 
> Building executable /root/paraview-1.6.3-linux/bin/paraview...
> /root/paraview-1.6.3-linux/bin/libvtkIO.a(vtkMyReader.o)(.text+0x9cd): 
> In function `vtkMyReader::ReadGeometry()':
> : undefined reference to `mtxNewInvMap(int*, int)'

If it is a C library then you need to make sure it has the standard 
extern "C" specifications for C++ compilers.  Your library's header 
should look like this:

#ifndef myFoo_h
#define myFoo_h

#ifdef __cplusplus
extern "C"
{
#endif

int myFunction(int);

#ifdef __cplusplus
}
#endif

#endif

Otherwise the C++ compiler will generate a mangled symbol reference to 
the functions that cannot be resolved using the unmangled C symbols.

-Brad


More information about the ParaView mailing list