|
I use brickos-0.2.6.10.6 with a gcc 3.4.2 crosscompiler and binutils 2.15.
When I try to make an executable I get the linker error:
"cannot handle R_MEM_INDIRECT reloc when using symbolsrec output"
I use a patched Makefile.user for making:
##
## legOS - the independent LEGO Mindstorms OS
## Makefile.common - make rules for user executables
## (c) 1998, 1999 by Markus L. Noga <markus@noga.de>
##
# User application libraries. Comment out if linking
# them statically to kernel in Makefile.kernel.
BRICKOS_ROOT=/usr/local/src/brickos-0.2.6.10.6
LIBS=-lc -lmint -lfloat -lc++
# linker command files dynamic executables.
DYNAMIC_LDS =$(KERNEL).lds
DLDFLAGS =-T $(DYNAMIC_LDS) -relax -L$(BRICKOS_ROOT)/lib
# base addresses to determine relocation info.
BASE1=0xb000
BASE2=0xb210
# Add config.h to include path.
CINC +=-I$(dir $(KERNEL))
############ new dynamic executables stuff
# how to build executables dynamically linked to the kernel
# set DYNAMIC_TEXT, DOBJECTS, DYNAMIC_LDS appropriately.
%.dcoff: %.o $(DOBJECTS) # $(DYNAMIC_LDS)
$(LD) $(DLDFLAGS) $^ $(LIBS) -o $@ -Ttext $(BASE1) --oformat coff-h8300
# how to make barebones dymanic executable map files
%.dmap: %.dcoff
$(NM) $< | sort > $@
# how to disassemble coff kernel
%.dis: %.dcoff
$(OBJDUMP) $(ODFLAGS) $*.dcoff > $*.dis
# how to merge map files with symbols
%.dis2: %.dmap %.dis
$(MERGEMAP) $*.dmap $< > $@
# how to make srec files of dynamic executables
%.ds1: %.o $(DOBJECTS) # $(DYNAMIC_LDS)
$(LD) $(DLDFLAGS) $^ $(LIBS) -o $@ -Ttext $(BASE1)
# how to make srec files of dynamic executables
%.ds2: %.o $(DOBJECTS) # $(DYNAMIC_LDS)
$(LD) $(DLDFLAGS) $^ $(LIBS) -o $@ -Ttext $(BASE2)
%.lx: %.ds1 %.ds2
$(MAKELX) $^ $@
-------------------------------------------------------end of Makefile
I found the patch in an old thread from 2002.
When I use the normal Makefile.user I get several linker errors while with the
patched Makefile linking is succesful in most cases (when not getting the error
above).
One error for example is:
"undefined reference to Lichtmesser::Lichtmesser()"
Here is the sourcecode of the files, I try to compile:
lichtmesser.h
------------------
#ifndef LICHTMESSER_H
#define LICHTMESSER_H
#include <Thread.h>
#include <Semaphore.h>
#include <c++/LightSensor.H>
/**
@author Annedore Rößling
*/
class Lichtmesser : public Thread
{
public:
Lichtmesser();
~Lichtmesser();
virtual void Run();
int getLightValue();
int getPriority();
void setPriority(int priority);
int light_value;
int prio;
enum LIGHT_VAL{
LIGHT_VAL_BRIGHT,
LIGHT_VAL_DARK,
LIGHT_VAL_NORMAL
};
enum PRIORITY{
PRIORITY_NORMAL,
PRIORITY_OTHER
};
/*static const unsigned int LIGHT_VAL_BRIGHT = 0;
static const unsigned int LIGHT_VAL_DARK = 1;
static const unsigned int LIGHT_VAL_NORMAL = 2;
static const unsigned int PRIORITY_NORMAL = 3;
static const unsigned int PRIORITY_OTHER = 4;
*/
Semaphore* sem;
LightSensor* light_sensor;
};
#endif
-------------------------end of lichtmesser.h
lichtmesser.cpp
-----------------
#include "lichtmesser.h"
Lichtmesser::Lichtmesser()
{
sem = new Semaphore();
light_sensor = new LightSensor(Sensor::S2);
light_value = 50;
prio = PRIORITY_NORMAL;
}
Lichtmesser::~Lichtmesser()
{
delete sem;
delete light_sensor;
}
void Lichtmesser::Run()
{
for(;;)
{
int value = light_sensor->get();
sem->wait();
if(value<=LIGHT_VAL_DARK)
{
light_value = LIGHT_VAL_DARK;
}
else
{
if(value>=LIGHT_VAL_BRIGHT)
{
light_value = LIGHT_VAL_BRIGHT;
}
else
light_value = LIGHT_VAL_NORMAL;
}
//lichtmessen
}
}
int Lichtmesser::getLightValue()
{
return light_value;
sem->post();
}
int Lichtmesser::getPriority()
{
return prio;
}
void Lichtmesser::setPriority(int priority)
{
prio = priority;
}
------------------------------------end of lichtmesser.cpp
test.cpp
------------------
#include "lichtmesser.h"
#include <conio.h>
int main(int argc, char** argv){
bool run = true;
Lichtmesser* lm = new Lichtmesser();
lm->Start();
while(run)
{
int val = lm->getLightValue();
if(val==lm->LIGHT_VAL_BRIGHT)
cputs("hell");
if(val==lm->LIGHT_VAL_DARK)
cputs("dark");
if(val==lm->LIGHT_VAL_NORMAL)
cputs("normal");
delay(100);
//!warten auf Tastendruck beim RCX
wait_event( dkey_pressed, 0);
//!wenn Taste Run gedrueckt
if(getchar() == KEY_RUN)
{
run = false;
}
/*else
yield();
*/
}
lm->Stop();
return 0;
}
---------------------------------------end of test.cpp
Can someone help with this linker problems?
|
|
1 Message in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|