0

So, I got this project that I was making using CodeBlocks but I'm migrating it to Netbeans because the first IDE is very bad for compiling (imo). I'm on Ubuntu 14, added the code on a blank new c++ project on netbeans and It was fine, found all the definitions of functions, etc, but When I F6'd it the build log returned me undefined reference to <function name>

Then I tried what was suggested on this site, didn't worked...

Here is the code of the project, sorry for the mess, it was my first time using github: https://github.com/FabioNevesRezende/GraphVertexColoring

  • 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) – Captain Obvlious Dec 08 '15 at 23:12
  • @CaptainObvlious I think that is indeed a problem of linking but I don't know how to solve it in this case, I installed allegro on ubuntu a long time ago don't remember how anymore (probably by terminal) but it is installed on my home folder. I think it is just a matter of referencing to the right place where the pre compiled objects are –  Dec 08 '15 at 23:33
  • So refer to the original documentation that explains how to install and use Allegro and make sure you read the linked duplicate as it'll have solutions that will help. – Captain Obvlious Dec 22 '15 at 18:44

1 Answers1

-1

Well I don't have enough info to be sure of this but I am guessing when you say that it sees the header files they show up in the project navigation. in a file that you are using those function needs to include the header along with the file that's implementing it. so add

#include "imp.h"

to the imp.ccp file and the same for all the other pairs.

You will probably have to add many of those includes to the main.cpp file as well.

  • But on imp.cpp I included main.h which includes imp.h. I tried though but didn't worked... –  Dec 08 '15 at 23:22
  • @WeltenSchann okay the undefined reference should be coming from a specific spot in a file somewhere can you tell where that is? because basically the compiler starts at the top and works down remembering stuff it has gone by and at things like .h files it will jump to those go through them and keep going and that error message basically means that at some point where you refer to that function the compiler hasn't seen the function definition. – Cody Christensen Dec 08 '15 at 23:28
  • They all come from main.cpp and main_imp.cpp and the unreferenced functions are all like al_clear_to_color, al_map_rgb, all from the allegro data structures.. the code in this same structure as I posted was compiling and running just fine on codeblocks –  Dec 08 '15 at 23:36
  • what lines were the errors on? so I can look at them online and maybe follow them backwards – Cody Christensen Dec 08 '15 at 23:42
  • main.cpp: from 56 to 85, from 318 to 333 also 119, 244. On main_imp.cpp from 10 to 29, 136, from 205 to 238 –  Dec 08 '15 at 23:46
  • This does not answer the question _at all_. This is a linker problem not compile issue. – Captain Obvlious Dec 08 '15 at 23:47
  • Found solution. I was missing the right flag options for the linker to the version I'm using of allegro. Source: https://wiki.allegro.cc/index.php?title=Compiling_Allegro_Programs –  Dec 09 '15 at 00:00
  • ya I miss understood where the error was coming from. – Cody Christensen Dec 09 '15 at 00:13