0

i installed libnoise on windows with code::blocks

and at compiling it gives an error:

undefined reference to `noise::module::Perlin::Perlin()'
undefined reference to `noise::module::Perlin::GetValue(double, double, double) const'
undefined reference to `vtable for noise::module::Perlin'
undefined reference to `noise::module::Module::~Module()'

but the references are in the perlin.h header file

How can i fix this problem?

1 Answers1

0

On Windows, libnoise comes with a *.def file which takes care of exporting symbols. But as I tried to compile the lib in 64 bit this morning, it appeared that this mechanism did not work. I had to "manually" export class symbols :

Steps to export libnoise symbols :

. Define a preprocessor variable LIBNOISE_EXPORT when compiling the lib as a shared library, do not add it when compiling a project that uses the lib

. Add some export macros in a top-level header of the lib (basictypes.h for example):

#if defined(WIN32)
#   ifdef LIBNOISE_EXPORT
#       define LIBNOISE_DLL __declspec(dllexport)
#   else
#       define LIBNOISE_DLL __declspec(dllimport)
#   endif
#else
#   define LIBNOISE_DLL
#endif

. Add the LIBNOISE_DLL macro in front of class definition :

class LIBNOISE_DLL Perlin: public Module
{
   ...

And that did the trick for me

note : do not use the *.def file in your compilation process if you try this solution

azf
  • 2,179
  • 16
  • 22