Adding header files to project, include to build

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Adding header files to project, include to build

3,690 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by simm on Thu Mar 17 00:44:14 MST 2011
Hello
I am new in LPCXpresso and I have a problem with adding new header files and c files to compile and build.
I wand to do opposite action to "Exclude from build"

Where I should add my files because I have log:


Invoking: MCU Linker
arm-none-eabi-gcc -nostdlib -Xlinker -Map=uart.map -Xlinker --gc-sections -mcpu=cortex-m0 -mthumb -T "../linker/lpc1114_flash_crp.ld" -o"uart.axf"  ./startup/cr_startup_lpc11.o  ./src/uart_main.o  ./cmsis/core_cm0.o ./cmsis/system_LPC11xx.o  
./src/uart_main.o: In function `main':
D:\PROJEKTY_KOM\M868_23_TouchPad\prog\LPC\Workspace\uart_touch\Debug/../src/uart_main.c:36: undefined reference to `UARTInit'
D:\PROJEKTY_KOM\M868_23_TouchPad\prog\LPC\Workspace\uart_touch\Debug/../src/uart_main.c:39: undefined reference to `GPIOInit'
D:\PROJEKTY_KOM\M868_23_TouchPad\prog\LPC\Workspace\uart_touch\Debug/../src/uart_main.c:42: undefined reference to `GPIOSetDir'
D:\PROJEKTY_KOM\M868_23_TouchPad\prog\LPC\Workspace\uart_touch\Debug/../src/uart_main.c:53: undefined reference to `GPIOSetValue'
D:\PROJEKTY_KOM\M868_23_TouchPad\prog\LPC\Workspace\uart_touch\Debug/../src/uart_main.c:56: undefined reference to `UARTSend'
D:\PROJEKTY_KOM\M868_23_TouchPad\prog\LPC\Workspace\uart_touch\Debug/../src/uart_main.c:63: undefined reference to `GPIOSetValue'
D:\PROJEKTY_KOM\M868_23_TouchPad\prog\LPC\Workspace\uart_touch\Debug/../src/uart_main.c:63: undefined reference to `UARTCount'
D:\PROJEKTY_KOM\M868_23_TouchPad\prog\LPC\Workspace\uart_touch\Debug/../src/uart_main.c:63: undefined reference to `UARTBuffer'
collect2: ld returned 1 exit status
make: *** [uart.axf] Error 1
0 Kudos
Reply
10 Replies

3,329 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by researchinnovation on Wed May 02 04:31:08 MST 2012
@Liza.....Hi..!!!

Have you imported these library in your project before importing the sample codes.
Have you made any change in the default setting of work-space's properties and all.


CMSISv1p30_LPC11xx or, CMSISv2p00_LPC11xx

Can you share the code or link of sample code what you are using for your application.



Thanks & Regards.....:)
0 Kudos
Reply

3,329 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Sun Apr 29 04:53:12 MST 2012
file.h is not part of C, C++ or POSIX. AFAIK, it is part of Linux/Unix system. So, what are you expecting to do with it? presumably you are expecting to manipluate files? How are you going to do that in an embedded system?
0 Kudos
Reply

3,329 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Prakash on Sun Apr 29 04:40:20 MST 2012
Hello,

I have taken project from ics.nxp.com/support/documents/microcontrollers/zip/lpcxpresso.examples.lpc1114.302.zip

The existing code working fine. I have added my xyz.c and xyz.h file in driver folder and included in ssp_main.c file and build the current workspace , then I am getting the follwowing
"../src/ssp_main.c:26:21: fatal error: file.h: No such file or directory
compilation terminated.
make: *** [src/ssp_main.o] Error 1
"

Kindly let us know the solution to resolve this.

Thanks
0 Kudos
Reply

3,329 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by liza on Tue Apr 10 03:23:09 MST 2012
Thanks for correction. Files have been added. Build works. Two things though:

-one-
I did not have to add the path to any of the source folders - only to header file folders. Somehow lpcxpresso recognizes its own source files automatically from the contents of that 'Project Explorer View' window. Which is somewhat curious : why it is not willing to do the same with the header files, hm ...

-two-
"LPCXpresso Introduction Part 2.mp4" video mentions a 'workspace relative path' there. As long as I use absolute path, for example : [COLOR=Blue]"C:\nxp\workspace_A\micros\inc" [/COLOR]then all works fine.

But when I tried to change it, using original nxp path syntax (which works of course) :[COLOR=Blue]"${workspace_loc:/CMSISv2p00_LPC17xx/inc}"[/COLOR]
          [SIZE=2][SIZE=1][  which means I changed my path from : [/SIZE][/SIZE][SIZE=1][COLOR=Blue]"C:\nxp\workspace_A\micros\inc" [/COLOR][/SIZE][SIZE=1]
                to (note the f/d slashes as in the nxp generated path style): [/SIZE][SIZE=1][COLOR=Red][COLOR=Blue]"${workspace_loc:/micros/inc}"[/COLOR][/COLOR][/SIZE][SIZE=2][SIZE=1]  ][/SIZE]
[/SIZE] then I got a compile error: [COLOR=Red]... fatal error: hardware.h: No such file or directory[/COLOR]

Note that hardware.h is located right in C:\nxp\workspace_A\micros\inc

Is there something wrong with the path's syntax which I used, brackets, slashes ... ?
0 Kudos
Reply

3,329 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Sun Apr 08 16:21:43 MST 2012

Quote: liza
thank you. I did #2, created sub catalog in my workspace, copied my C files there.



That's not #2 :eek: Create a subdirectory (like mydriver)[COLOR=Red] within [/COLOR]your project with (RightClick Project) New -> Source Folder :)

Now you should see your new folder in project folder (little 'C' in its icon shows it's a source folder).

Include it's relative path with "../mydriver" in 'Includes' settings and every source file in this folder is compiled and every header file is included :rolleyes:

A lot of samples are using this method with included 'driver' subdirectory.
0 Kudos
Reply

3,329 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by liza on Sun Apr 08 16:04:14 MST 2012
thank you. I did #2, created sub catalog in my workspace, copied my C files there. Then went back to LPCXpresso, right clicked on project, NEW, Source File, Browse button and dead end: it came up with a window that is the exact copy of the Projects window. I don't see how to add any C file from there because I can't get to my files. I will search NXP videos, may be I will find something there. (;(
0 Kudos
Reply

3,329 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Sun Apr 08 06:10:00 MST 2012
#1 Easiest way to add your own source and header files is to add them to your project->src directory.

#2 Better way to add your files is to create a subdirectory (like mydriver)[COLOR=Red] within [/COLOR]your project and add this path to your include settings in project properties (right Click Project and select Properties):

Properties -> C/C++ Build -> Settings -> Tool Settings -> MCU C Compiler -> Includes

#3 If you are more familiar with this stuff (later) you can also cerate your own library and add this to your project. But at the moment I would suggest to add files to your project with #1 or #2.

Note: A good point to start is to view:[INDENT] Learn Eclipse the LPCXpresso way - from the developers

http://ics.nxp.com/support/training/learn.eclipse.lpcxpresso/

See Literature section in: http://ics.nxp.com/lpcxpresso/[/INDENT]
0 Kudos
Reply

3,329 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by liza on Sun Apr 08 05:44:47 MST 2012
I am also new to this forum (and NXP micros in general).

Would it be too much if I ask you guys a pretty basic question ?

I have quite few 'generic' C files (and their headers from another micro that I want to transfer to NXP 1769. In order to be able to use some ready to go framework I managed to use one of the examples in Xpresso but I don't want to create all files again and paste-copy all data to them.

I tried to add C files (the C icon) but it does not allow me to get to my existing .c files. I copied them to my workplace but the popup window does not see them there. I read Xpresso manual and some web posts and it seems that it is a trivial task but not for me  (:( .

Help please the novice ....... :)
0 Kudos
Reply

3,329 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by simm on Fri Mar 18 02:43:23 MST 2011
It works. Thanks
0 Kudos
Reply

3,329 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Thu Mar 17 09:28:16 MST 2011
It appears like you are trying to modify one of the projects from NXP's latest example bundle for LPC11? (NXP_LPCXpresso1114_2011-01-27.zip or similar).

I'm not that familar with this batch of examples, but it may well be that you simply need to select the excluded files in the driver subdirectory, right click and select "Exclude from build" option.

You can then simply tick on the "Deselect All" button, then OK. Then when you rebuild, all the source code in the driver subdirectory should get built - which should solve your link step errors.

Note that if you are creating a new project based on the examples, you might want to take a look at the "template_readme.txt" file in the "template" project that is contained within this examples bundle. This provides a wizard for creating a new project containing appropriate driver code.

If you need more help with this, then hopefully someone who is more familar with these examples will be able to help you.

Regards,
CodeRedSupport
0 Kudos
Reply