Sharing source file between 2 or more projects

cancel
Showing results for 
Search instead for 
Did you mean: 

Sharing source file between 2 or more projects

155 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cwpjr on Wed May 15 07:47:06 MST 2013
I have a workspace with my primary project, and an imported example project. As a means of prototyping I would like like to include source files from my project in the example projects, while maintaining the source only in my project, such that all changes on my source files are done only in my project.

What is appropriate here?
0 Kudos
12 Replies

132 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Thu May 16 11:12:22 MST 2013
Probably because you have made a mistake. Without seeing your project, I have no idea what that may be. Post your project and we can probably help.
0 Kudos

132 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cwpjr on Thu May 16 10:39:39 MST 2013
Thanks, TheFallGuy

I used to do views at Bell Labs like that for huge builds of 5eSS(TM) network cards, to get the latest code & doc into a view I could treat as a uniform filespace, that I could handily grep and awk my days away, to feed the tech writers...

I get the 3 step you outlined for creating hybrid projects thru convenient cut and past access.

I still don't get that 2 'C' functions (not object files) defined in main.c  cannot be resolve to a request by a (linked into this project) file calling them.

Cheers, Clyde
0 Kudos

132 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Thu May 16 09:36:59 MST 2013
You have a few choices. But first, you probably need to understand how LPCXpresso (Eclipse) builds projects.

For a C project, LPCXpresso will compile (to an object file) every source file that it can find within the project (unless it has been explictly excluded).

The linker will then take every object file, and any other external libraries or object files explicitly defined in the linker settings and link them together to create an executable (axf) file.

The linker will not 'find' object files unless you tell it where to find them...

So, your options are:
1. use the example project as a library and just link with the library in your project
2. Use "Linked Resources" to link directories from the example project into your project. This creates a link (NOT a copy) to the files in the example project, so that they appear to be in your project. As they now appear in your project, LPCXpresso will compile and link them
3. Copy/paste the example source files into your project

There is lots of information in the Help - (Help->Help Contents)

132 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by graynomad on Thu May 16 09:26:49 MST 2013
I'm afraid I can only just keep my head above water when it comes to toolchains/linkers etc. In the old days I'd add a reference to the resources in a makefile but that was in a previous life.

Is there a way to add a "resource" to your project, often it's a matter of knowing what the terminology is.
0 Kudos

132 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cwpjr on Thu May 16 08:53:43 MST 2013
Isn't subject to change. That machine was donated to help me get started learning a useful skill in an attempt to get work. I am very poor, less than 5k earned last year.

So this thread is about how I can declare to the linker that an imported files desire to use 2 functions from the external project are also in the host project.

I would think there would be a way to declare the functions global in the hosting main.c and that the linker would then resolve the linked resource files request for them.

Is this so un C.S. like that I need to re-evealuate my thinking? :cool:
0 Kudos

132 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by frame on Wed May 15 23:36:58 MST 2013

Quote:
Not stated is on a 768mb 12 year old xp machine every additional step is painful:o


This machine seems overdue.
I have seen PCs fail after 6 years in a row, with part of the motherboard 'exploding'.
You should have a backup PC.

And second, running Java things like Eclipse on those machines [B]IS[/B] painful.
I've been trough this with NetBeans. A make file approach would be better.

Sorry for adding my 2 cents here...
0 Kudos

132 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cwpjr on Wed May 15 09:50:23 MST 2013
And as I stated this code is in flux. Not stated is on a 768mb 12 year old xp machine every additional step is painful:o

And until the prototyping is done and debugged I'd like to keep my build download times under 3 minutes apiece!
0 Kudos

132 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by graynomad on Wed May 15 09:28:18 MST 2013
I make a library of the common code. That has to be easier than all the linking problems you are having.
0 Kudos

132 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cwpjr on Wed May 15 09:27:27 MST 2013
I linked a resource, a .s file, from project 1 to project 2.
In project 1 a function in the .s file is called from main() in main.c .
In project 1, in the main .c file I also created 2 other functions.
In project 1 the 2 other functions are called from the .s file and they return to the .s file.

In the 2nd project main.c I created the 2 other functions also.
Because the linked .s file is from project 1 the 2 functions I created in the the 2nd project main.c are not seen, resulting in the error "undefined reference to " the 2 functions.

I tried to declare the functions as extern in the linked .s file and get the error bad instruction.

I think I need to declare the functions as globals in the main.c file but in help I searched global and got .global which I don't think is correct.

These are trivial functions that I don't want to put into a library while I am prototyping and debugging., just yet.

Is there a way to clue the linker or is my approach wrong?
0 Kudos

132 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Wed May 15 08:36:50 MST 2013

Quote: cwpjr
I have a workspace with my primary project, and an imported example project. As a means of prototyping I would like like to include source files from my project in the example projects, while maintaining the source only in my project, such that all changes on my source files are done only in my project.

What is appropriate here?



The usual way to share sources is of course creating a library project and include in in both projects.
The advantage is that it is compiled already and it's a clear separated code.
With a significant name (like 'LPC17_CAN_LIB') it's very easy to understand your own resource management even after years.
0 Kudos

132 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cwpjr on Wed May 15 08:18:52 MST 2013
I was going to edit my request along the lines of how to include a source from somewhere else in the current projects make...:)
0 Kudos

132 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Wed May 15 07:49:41 MST 2013
Linked resources - search the Help (Help->Help Contents)
0 Kudos