Developing a module using external libraries

Hey there,

@Lucius and I are currently developing a module for mrtrix which uses an external library to work properly (in this case OpenIGTLink). Because I’m relatively new to C++ development I had a lot of trouble with understanding the build process and adapting it to my needs.

At the moment I think that the compilation of my module works and that clang finds the correct header files for the module.

But unfortunately I can’t figure out where the problem with the linking step is. I get the following error message:

After invoking the configure script from the mrtrix root directory like this:

CFLAGS=-I/usr/local/include/igtl LDFLAGS=-L/usr/local/libs/igtl ./configure

and calling the ./build script from the module’s subfolder without any arguments (which I set up using a symbolic link to mrtrix/build like it was described in the tutorial) I get the following error message just after the compilation part of the build process finishes:

ERROR: (214/214) [LB] bin/mrview-igtlink
{long clang command}

failed with output

Undefined symbols for architecture x86_64:
  "igtl::MessageBase::GetPackSize()", referenced from:
      TrackingDataClient::connectBrainlab() in mrview-igtlink.o

The lib folder (/usr/local/lib/igtl) includes the following files:

Does someone have any advice?

Best regards,

You’re almost there – all you’re missing is the actual library name to link against (not just its location). Try this:

CFLAGS=-I/usr/local/include/igtl LDFLAGS="-L/usr/local/libs/igtl -lOpenIGTLink" ./configure

It works! Thanks a lot!