Jump to content

Migrating a project to Codeblocks produces linking errors (missing definition fo


Pablop
 Share

Recommended Posts

Hello people!

I'm starting my way programming in c, and made my first steps using Notepad++. Everything was ok, but then I saw that with Acsim i could test my apps without flashing the pic. So, following the instructions in the wiki I started to setup Codeblocks and all the needed other things for ACsim to work.

It's been complicated, but everything seems to be right. Everything but:

I have a project based on mclock, where there's main.c and mtc.c, with their respective headers.

When I try to bulid the project, either as debug or release I get the error:

error: missing definition for symbol "_MTC_DoRew", required by "_output\main.o"

error: missing definition for symbol "_MTC_DoStop", required by "_output\main.o"

error: missing definition for symbol "_MTC_DoPlay", required by "_output\main.o"

error: missing definition for symbol "_mtc_state", required by "_output\main.o"

error: missing definition for symbol "_MTC_Timer", required by "_output\main.o"

error: missing definition for symbol "_MTC_Tick", required by "_output\main.o"

error: missing definition for symbol "_MTC_Init", required by "_output\main.o"

error: missing definition for symbol "_MTC_DoFwd", required by "_output\main.o"

error: missing definition for symbol "_MTC_FPSSet", required by "_output\main.o"

error: missing definition for symbol "_MTC_DoPause", required by "_output\main.o"

error: missing definition for symbol "_mtc_long_timeMSW", required by "_output\main.o"

error: missing definition for symbol "_mtc_long_timeLSW", required by "_output\main.o"

ERROR!

Process terminated with status 1 (0 minutes, 1 seconds)

0 errors, 1 warnings

It seems it cannot find the definitions in mtc.h

Although they are just as they were when using Notepad++ and there was no trouble at all.

I copy the start of main.c, and some parts of mtc.h

////////////////////////////////////////////////////////////////////////////

// Include files

/////////////////////////////////////////////////////////////////////////////

#include "main.h"

#include "mtc.h"

//#include <cmios.h>

//#include <pic18fregs.h>

#ifndef _DEBUG_C

#include "cmios.h"

#include "pic18f452.h"

#endif

-------------------------------------------------------------------

mtc.h:

#ifndef _MTC_H

#define _MTC_H

/////////////////////////////////////////////////////////////////////////////

// Global definitions

/////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////

// Global Types

/////////////////////////////////////////////////////////////////////////////

// status of MTC

typedef union {

  struct {

    unsigned ALL:8;

  };

  struct {

    unsigned RUN:1;

    unsigned PAUSE:1;

    unsigned START_REQ:1;

    unsigned STOP_REQ:1;

    unsigned CONT_REQ:1;

  };

} mtc_state_t;

/////////////////////////////////////////////////////////////////////////////

// Prototypes

/////////////////////////////////////////////////////////////////////////////

void MTC_Init(void);

void MTC_Tick(void);

void MTC_Timer(void);

void MTC_FPSSet(unsigned char rate);

unsigned char MTC_FPSGet(void);

void MTC_ResetMeter(void);

void MTC_SendMeter(void);

void MTC_DoStop(void);

void MTC_DoPause(void);

void MTC_DoPlay(void);

void MTC_DoRew(void);

void MTC_DoFwd(void);

unsigned int MTC_GetTimerValue(unsigned char rate);

____________________________

As you can see, mtc.h is included in main.c, an the functions not found by the linker are declared in mtc.h. So, it's puzzling me beyond my efforts. I know it must be some stupid thing I'm overlooking, but, well, I spent many hours and couldn't find a solution.

Thanx for your wise advice

Pablo

Link to comment
Share on other sites

Hi Pablo,

I never used CodeBlocks, so I'm not sure if I can be of any help, but if it worked in Notepad++ but not in Codeblocks, I guess there might be something wrong with the make-process. With the old toolchain, one had to add additional classes to the Makefile (OBJS = mtc.o)... again, not sure if this is done automatically by adding files to a target in CodeBlocks...

Best,

Michael

Link to comment
Share on other sites

Hi!

If I understood you well, I took makefile and where it said

OBJS=$(OUTDIR)/pic18f452.o $(OUTDIR)/main.o

I added mtc.o so it now reads

OBJS=$(OUTDIR)/pic18f452.o $(OUTDIR)/main.o $(OUTDIR)/mtc.o

Sadly, I got the same error, and what's more, once the project is built, makefile returns to it's original state.

thank you, anyway!

Link to comment
Share on other sites

Heya pablop :)

So, following the instructions in the wiki

You mean this one ?

Did you maybe use the template in the zip file from this section ? It's verrrry olllld and won't work...

You should be able to follow the instructions for creating a new template found here though, but you will need to change at least one step:

Where it says to type 'make.bat' you just type 'make'.

There may be other changes required.... That documentation is quite old...

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...