Hi,
I have a general linking / compiling problem.
In the main() function there was a very easy c-function implemented, it's namend test().
The test() function was located in test.c, this additional file is also added in the FileView of HiTOP5.
The prototype declaration is in function.h, this file is located in the source directory and added in FileView.
Preprocessor directives should complete everything, look at the code snippets:
main.c
--------------------
#include "functions.h"
int main (void)
{
test();
while (1)
{
}
}
--------------------
test.c
--------------------
#include "functions.h"
void Test( void )
{
// function contents
}
--------------------
functions.h
--------------------
#ifndef _FUNCTIONS_H
#define _FUNCTIONS_H
// Prototype
void Test( void );
#endif
--------------------
After compiling the project, HiTOP5 appears with following message:
arm-hitex-elf-ld.exe -T.\netx_intram.ld.tmp -static -lc -lm -lgcc -Map=file.map -o .\Output\startup.elf
./Output/main.o: In function `main':
.\Sources/main.c:52: undefined reference to `test'
Why???
I think, I have tested everything.
It's impossible to create a reasonable project! :(
I'm using HiTOP5 V5.20.0424 with NXHX-500RE.
Please help!
Thanks
micha1975er
Only in this forum I have typed 'Test' and 'test'... Sorry for confusing.
But all test() function names were written with small letters in my project, I have checked this.
Additionaly the file test.c wasn't located in the ModuleView tree, is this the reason?
micha1975er
Hilscher Gesellschaft fuer Systemautomation mbH
As long as the file is not complied and linked it will not be available in the module view.
Try in the first step to add the function prototype at the beginning of your c file. When this is working, try to add it into the header.
Ok, I understand. Now, I have tested following:
This works fine:
-------------------------
//#include "functions.h"
void test( void )
{
}
int main (void)
{
test();
while (1)
{
}
}
-------------------------
This does not work!
-------------------------
//#include "functions.h"
// Prototype, the function is located in 'test.c'
void test( void );
int main (void)
{
test();
while (1)
{
}
}
-------------------------
After compiling, same error.
Hilscher Gesellschaft fuer Systemautomation mbH
Please check if the search path for the includes is set.
This is located in the HiTOP under:
Project->Settings...->Your Application the the Tree Structure->Button "Tool Settings..." on the right->General.
Are here all needed include path set?
Hilscher Gesellschaft für Systemautomation mbH
For some reasons test.o is not linked into your project.
Check that Hitop compiles your file (test.c) and also make sure it passes the object file (test.o) to the linker.
Regards
MT
To AJ:
Yes, I think all neccessary include paths are set:
.\Includes\
.\Lib\
.\Sources\
The 'test.c' and 'functions.h' are both located in ..\Sources directory.
To MT:
HiTOP5 has compiled the test.c.
After that, test.o was created. Following the message after rebuilding all:
arm-hitex-elf-as.exe -mcpu=arm926ej-s -gdwarf2 -mthumb-interwork -EL -I.\Includes\ -I.\Lib\ -I.\Sources\ -o .\Output\InitGnu.o .\Sources\InitGnu.s
arm-hitex-elf-gcc.exe -c -mlong-calls -mcpu=arm926ej-s -fshort-enums -gdwarf-2 -Wall -O0 -mapcs -mthumb-interwork -fsigned-char -xc -mlittle-endian -marm -mno-apcs-frame -nostdlib -D_NETX_HITOP_ -D__RCX__ -I.\Includes\ -I.\Lib\ -I.\Sources\ -o .\Output\main.o .\Sources\main.c
arm-hitex-elf-gcc.exe -mlong-calls -mcpu=arm926ej-s -fshort-enums -gdwarf-2 -Wall -O0 -mapcs -mthumb-interwork -fsigned-char -xc -mlittle-endian -marm -mno-apcs-frame -c -D_NETX_HITOP_ -D__RCX__ -I.\Includes\ -I.\Lib\ -I.\Sources\ -o .\Output\test.o .\Sources\test.c
arm-hitex-elf-ld.exe -T.\netx_intram.ld.tmp -static -lc -lm -lgcc -Map=file.map -o .\Output\startup.elf
./Output/main.o: In function `main':
.\Sources/main.c:52: undefined reference to `test'
Hilscher Gesellschaft für Systemautomation mbH
Take a look at "netx_intram.ld.tmp" if test.o is included as INPUT(test.o) or something like that.
Regards
MT
There are several linker script files available in the project directory:
netx_intram.ld
netx_intram.ld.tmp
netx_sdram.ld
Within this files there are following parts:
INCLUDE netx.lnk
MEMORY{...}
SECTIONS{...}
But nothing with INPUT etc.
Hilscher Gesellschaft fuer Systemautomation mbH
In this case you are using an old example.
But anyway. Please check the "netx.lnk" for the settings like MT wrote before.
Hi,
the problem was solved.
In the file 'netx.lnk' I have manually added following:
INPUT ( ./Output/test.o )
After that, HiTOP was compiling succesfully my project.
Thanks to all!
Regards
micha1975er
Andreas Jacob
Hilscher Gesellschaft fuer Systemautomation mbH
Hi micha1975er,
the compiler is case sensitive.
In your main.c you write:
But in functions.h you write: