NumberFour
NumberFour

Reputation: 3621

Netbeans C/C++ linker problem

In Netbeans 6.9 on Linux and I was trying to to compile my C++ code. It consists of two CPP files - main.cpp and later I added Tree.cpp and Tree.h to the project, but linker obviously ignores that fact and throws an "undefined reference error" in main.cpp when I use something from the Tree unit.

Do you have any clue how to add the CPP file to the project properly so it links successfully?

Thanks!

Upvotes: 0

Views: 1152

Answers (1)

Baltasarq
Baltasarq

Reputation: 12212

You need to add Tree.cpp to your project's build configuration; also you need to add the path to Tree.h in the "Search files" build section.

Right-click your project and select "properties", then go to the C++ compiler section. In "include directories" add the path to Tree.h. Now right click your project again and select "add existing items", and choose "Tree.cpp". Finally Clean and Rebuild, and your project should be built nicely.

Upvotes: 2

Related Questions