This piece of code:

Code:
RTC_GetTime( (unsigned int*)hour, (unsigned int*)minute, (unsigned int*)second, (unsigned int*)millisecond );

...compiles fine if it is compiled as C code, but if it is compiled as C++ code, compilation fails with the only linker error:

Code:
sh3eb-elf-g++  events.o lock.o main.o unixtime.o sha2.o toksplit.o -mb -m4a-nofpu -mhitachi -nostdlib -T/home/gabriel/CasioSDK/common/prizm.ld -Wl,-static -Wl,-gc-sections  -L/home/gabriel/CasioSDK/lib -lfxcg -lc -lgcc -o /home/gabriel/CasioSDK/projects/utilities/utilities.bin
main.o: In function `_currentUnixTime':
main.cpp:(.text+0x7e0c): undefined reference to `RTC_GetTime(unsigned int*, unsigned int*, unsigned int*, unsigned int*)'
collect2: ld returned 1 exit status
make[1]: ** [/home/gabriel/CasioSDK/projects/utilities/utilities.bin] Error 1
make: ** [build] Error 2


The same happens for RTC_GetTicks. I'm including the header file RTC_syscalls.h which contains definitions for both of these RTC syscalls (also, I have added proper "extern "C"" code to that header file, and the problem doesn't come from there).
Both syscalls are included in the libfxcg I'm using.

Any ideas? I really need to get "millisecond" precision (which is actually about 8 ms) and using that RTC_GetTime syscall would be the easiest way I believe.

EDIT: actually, I believe that if I had a way to use just RTC_GetTicks I could live without RTC_GetTime. If anyone knows of a way to return the number of ticks after midnight without RTC_GetTicks, that'd be good (but fixing the main syscalls-not-linking problem would be great).
My guess would be your cpp flags in your make file don't match your c flags. Double check you have the same flags and are linking against all the right libraries.
This is my makefile: http://www.rafb.me/results/arehjm24.html

As you can see, CXXFLAGS is exactly the same as CFLAGS, because the former consists on the reference to the latter.
I suggest you use something other than rafb.me for this sort of thing as rafb is wiped everynight at around 12PM CST. Perhaps just put it in a [ code ] block in your post.
Ah, true. It didn't occur to me rafb.me deleted the posts, it was the first thing that came for "pastebin" in history. Here's my makefile then:


Code:

#---------------------------------------------------------------------------------
# Clear the implicit built in rules
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
# Set toolchain location in an environment var for future use, this will change
# to use a system environment var in the future.
#---------------------------------------------------------------------------------
ifeq ($(strip $(FXCGSDK)),)
export FXCGSDK := $(abspath ../../)
endif

include $(FXCGSDK)/common/prizm_rules


#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
#---------------------------------------------------------------------------------
TARGET      :=   $(notdir $(CURDIR))
BUILD      :=   build
SOURCES      :=   src
DATA      :=   data 
INCLUDES   :=

#---------------------------------------------------------------------------------
# options for code and add-in generation
#---------------------------------------------------------------------------------

MKG3AFLAGS := -n basic:Utilities -i uns:../unselected.bmp -i sel:../selected.bmp

CFLAGS   = -Os -Wall $(MACHDEP) $(INCLUDE)
CXXFLAGS   =   $(CFLAGS)

LDFLAGS   = $(MACHDEP) -T$(FXCGSDK)/common/prizm.ld -Wl,-static -Wl,-gc-sections

#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS   :=    -lfxcg -lc -lgcc

#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS   :=

#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------

export OUTPUT   :=   $(CURDIR)/$(TARGET)

export VPATH   :=   $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
               $(foreach dir,$(DATA),$(CURDIR)/$(dir))

export DEPSDIR   :=   $(CURDIR)/$(BUILD)

#---------------------------------------------------------------------------------
# automatically build a list of object files for our project
#---------------------------------------------------------------------------------
CFILES      :=   $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES   :=   $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
sFILES      :=   $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
SFILES      :=   $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
BINFILES   :=   $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))

#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
   export LD   :=   $(CC)
else
   export LD   :=   $(CXX)
endif

export OFILES   :=   $(addsuffix .o,$(BINFILES)) \
               $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
               $(sFILES:.s=.o) $(SFILES:.S=.o)

#---------------------------------------------------------------------------------
# build a list of include paths
#---------------------------------------------------------------------------------
export INCLUDE   :=   $(foreach dir,$(INCLUDES), -iquote $(CURDIR)/$(dir)) \
               $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
               -I$(CURDIR)/$(BUILD) -I$(LIBFXCG_INC)

#---------------------------------------------------------------------------------
# build a list of library paths
#---------------------------------------------------------------------------------
export LIBPATHS   :=   $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
               -L$(LIBFXCG_LIB)

export OUTPUT   :=   $(CURDIR)/$(TARGET)
.PHONY: $(BUILD) clean

#---------------------------------------------------------------------------------
$(BUILD):
   @[ -d $@ ] || mkdir $@
   @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile

#---------------------------------------------------------------------------------
export CYGWIN := nodosfilewarning
clean:
   $(RM) -fr $(BUILD) $(OUTPUT).bin $(OUTPUT).g3a

#---------------------------------------------------------------------------------
else

DEPENDS   :=   $(OFILES:.o=.d)

#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).g3a: $(OUTPUT).bin
$(OUTPUT).bin: $(OFILES)


-include $(DEPENDS)

#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
Solved in my local PrizmSDK: You probably lack extern "C" { ... } in all of your headers. To fix, just surround your #include "..." statements in extern "C" { ... }
Thanks, that did it... I had done it already on RTC_syscalls.h, but I overlooked the fact that I was including rtc.h and not RTC_syscalls.h.
My includes folder is a mess.
The includes on the folder fxcg all have proper extern "C"s, but the older, messy includes files don't have them.

This is how an includes file should look in the end:

Code:

#ifdef __cplusplus
extern "C" {
#endif
int RTC_Reset( int );
void RTC_GetTime( unsigned int*hour, unsigned int*minute, unsigned int*second, unsigned int*millisecond );
int RTC_GetTicks(void);
int RTC_Elapsed_ms( int start_value, int duration_in_ms );
void RTC_SetDateTime( unsigned char*timestr );
#ifdef __cplusplus
}
#endif
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement