Author Topic: Linking problem  (Read 1722 times)

Offline nelson777

  • Single posting newcomer
  • *
  • Posts: 5
Linking problem
« on: January 07, 2010, 05:56:38 pm »
Hello,

Some time ago I used wxDevCpp in a project I used to work and created also a small introductory course of C++ OO with wxWidgets in it. Now I'm a Linux only professional and as some colleagues asked me to redo the course, so the obvious choice was Code::Blocks.
But as I tried to convert my course projects to Code::Blocks, I'm getting some linking problems. I think it should be some C::B tweak I couldn't find. Can someone please point me in the right direction ? The problem goes like this:

I'm trying to teach OO together with wxWidgets, so the course starts with basic things and elaborate to the point where I create a small calculator. In the first day I have 2 classes in a folder called day1:
-Oper which has 2 variables (oper1 and oper 2) and the respectives gets and sets. These are the operands that will be used for the calculations.
-Operations which extends from Oper and has the 4 basic operations in the following folder stucture:

-day1   (has the Operations.h and Operations.cpp files)
  |---op       (sub-folder that has the Oper.h and Oper.cpp files)

Operations.h includes Oper.h like this:
#include "op/Oper.h"

in this project, all works fine. It builds, links and runs correctly. The problem is when I try to elaborate this in the next project. This time the objective is to show the multiply tables for a certain number. So I have a class called MultiplyTable with 2 methods: Show(int n) and ShowAll() which use the classes I created above.
This class is in the root project folder.  So now I got the following folder struncture:

-day1   (has the Operations.h and Operations.cpp files)
  |---op       (sub-folder that has the Oper.h and Oper.cpp files)
-day2   (has the MultiplyTable.h and MultiplyTable.cpp files)

So I have an #include "Operations.h" in the MultiplyTable.h file. In order for it to be found I included the day1 folder in the project's search directories and (after this didn't work) also tried to change the include to #include "../day1/Operations.h"

My problem is that this project compiles ok, but it won't link complaining that it has undefined references both to Oper.h anb Operations.h's methods.

I'm working in Ubuntu 8.04, using C::B version svn 6031 and GCC 4.2.4

Thnx,
Nelson Teixeira,
Fortaleza, Brasil
Any help is welcome,
Nelson Teixeira,
Fortaleza, Brasil

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6535
    • My Best Post
Re: Linking problem
« Reply #1 on: January 07, 2010, 06:20:50 pm »
I have no idea what your problem is!

Try turning on Full Compiler Logging and the state if the problem is Linking or something else.

http://wiki.codeblocks.org/index.php?title=FAQ#Q:_How_do_I_troubleshoot_an_compiler_problem.3F

Tim S.


C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: Linking problem
« Reply #2 on: January 07, 2010, 07:20:53 pm »
Are the respective cpp-files parts of the project ?
If not, you need a library that contains the classes you use and link your new project against it.