This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Help in Makefiles for multiple file application


Hi,
   I'm getting a weird problem. I have wrote 2 sample
c++ files with a common header that is included for
both the files. When I try to make it, I get multiple
definition errors for the data structures used. I do
have the #define directive in my header file. The
weird part is that the whole thing properly compiles
if the applications are c files. 
I'm giving below the Makefile and the c++ files that I
used. Can someone please point me in the right
direction. 
Thank you.

Giri.

*************************************************

Makefile

INSTALL_DIR=$$(INSTALL_DIR) # override on make command
line

include $(INSTALL_DIR)/include/pkgconf/ecos.mak

XCC           = $(ECOS_COMMAND_PREFIX)gcc
XCXX          = $(XCC)
XLD           = $(XCC)
CFLAGS        = -g -Wall -mcpu=arm7tdmi
-I$(INSTALL_DIR)/include
CXXFLAGS      = $(CFLAGS)
LDFLAGS       = -nostartfiles -L$(INSTALL_DIR)/lib
-Ttarget.ld
OBJ = init.o

#RULES

all: one

init.o: init.cc ll.h
        $(XCC) $(LDFLAGS) $(CFLAGS) -c init.cc

one: one.cc $(OBJ) ll.h
        $(XCC) $(LDFLAGS) $(CFLAGS) -o one one.cc
$(OBJ)


***************************************

header file

#ifndef JJ
#define JJ

// common header files
#include <pkgconf/system.h>
#include <pkgconf/kernel.h>
#include <pkgconf/libc.h>
#include <pkgconf/hal.h>
#include <cyg/infra/cyg_type.h>
#include <cyg/kernel/kapi.h>
#include <cyg/hal/hal_arch.h>
#include <cyg/hal/hal_io.h>
#include <cyg/hal/var_io.h>
#include <cyg/hal/plf_io.h>
#include <cyg/io/io_diag.h>
#include <pkgconf/io_serial.h>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>

int i;
int c;
void init();

extern "C"  {
        void cyg_user_start();
}

#endif

**************************************

one.cc

#include "ll.h"

void cyg_user_start(void)  {
        init();
        for(;;)  {
                i++;
        }
}

********************************************

init.cc

include "ll.h"

void init()  {
        for(;;)  {
                c = 100;
        }
}

********************************************




	
		
__________________________________
Do you Yahoo!?
Vote for the stars of Yahoo!'s next ad campaign!
http://advision.webevents.yahoo.com/yahoo/votelifeengine/

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]