2

I am creating a project which needs to use the libnoise headers. However I am having difficulty compiling.

I have put the headers into my src/ directory of my project, so I am able to include them with

#include "noise/noise.h"
#include "noise/noisegen.h"
#include "noiseutils.h"

But when I try and create a Perlin module noise::module::Perlin perlinModule;, I get the following compilation error:

PROJECTDIR\bin/../src/libnoise_wrapper.cpp:66: undefined reference to `noise::module::Perlin::Perlin()'
./src/libnoise_wrapper.o: In function `~Perlin':
PROJECTDIR\bin/../src/noise/module/perlin.h:160: undefined reference to `vtable for noise::module::Perlin'
PROJECTDIR\bin/../src/noise/module/perlin.h:160: undefined reference to `noise::module::Module::~Module()'
PROJECTDIR\bin/../src/noise/module/perlin.h:160: undefined reference to `vtable for noise::module::Perlin'
PROJECTDIR\bin/../src/noise/module/perlin.h:160: undefined reference to `noise::module::Module::~Module()

I have created a Project Include reference to the /src/noise folder as well as noiseutils.h file (which is in the src/ directory itself).

Are there any other configurations I am missing?

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
Sash
  • 4,448
  • 1
  • 17
  • 31
  • 1
    possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – πάντα ῥεῖ Jul 12 '14 at 14:39
  • 1
    @πάνταῥεῖ: please stop downvoting and close voting everything has the expression "unresolved external symbol" with that clearly bad "canonical duplicate". This is not constructive.. Even if it manages to get closed, I will instantly reopen it with the binding reopen vote. – László Papp Jul 13 '14 at 02:50

1 Answers1

1

"I have put the headers into my src/ directory of my project, so I am able to include them with "

That's not the usual way to do! You should have an installation of this library in your environment (there are some instructions how to do this for your particular case available in this tutorial from the libnoise online documentation), and add the additional include paths to search using the

Project Properties->C/C++ Build->Settings-><actual C++ Compiler>->Includes->Include paths (-I)

enter image description here settings.

"Are there any other configurations I am missing?"

Check the

Project Properties->C/C++ Build->Settings-><actual toolchain linker>->Libraries

enter image description here

properties page.

You'll need to provide noise in the Libraries list there, and eventually an additional Library search path pointing to the actual libs installation. The latter depends on how and where you have the libnoise installed in your environment.

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
  • I had to compile the libnoise library (see http://stackoverflow.com/questions/13280932/compiling-libnoise-on-windows-with-mingw) to be able to link it, which renders having the headers useless. But it worked, thanks or the help. – Sash Jul 12 '14 at 16:13
  • Out of curiosity, why would you not use the headers by themselves, instead of compiling the library? – Sash Jul 12 '14 at 16:15
  • 2
    @Sash In general you have 2 options: 1. Install the library for your current environment having the binary files. 2. Compile (and install) the library for your current environment (which results in the proper binary files). Both of these just use the header files, containing the necessary declarations for what's in the library binaries, to bind with your application linking against it. – πάντα ῥεῖ Jul 12 '14 at 16:19