Author Topic: Using an SDK - Dependency on multiple object files  (Read 12223 times)

Offline Vikingo

  • Single posting newcomer
  • *
  • Posts: 7
Using an SDK - Dependency on multiple object files
« on: February 24, 2014, 10:15:46 pm »
Context: using SDCC to produce an .hex file for an nRF24LE1 (8051 compatible chip)

I'm using an SDK which has multiple source files for different functions (One source file for each function) and only one header file for a group of related functions (say: gpio.h includes several function declarations but then you have one source file for each function which gets compiled into it's own .rel file)

I'm able to manually specify the dependency but I'm looking for something a little bit more flexible.

Is there a simple way to specify the dependencies in C::B for my main code such that I only get the really used functions linked? and not the unused ones?

I searched the forums but couldn't find the answer.

Thanks
Alex

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6663
    • My Best Post
Re: Using an SDK - Dependency on multiple object files
« Reply #1 on: February 24, 2014, 10:40:38 pm »
The answer depends on the Compiler and NOT on Code::Blocks.

Does SDCC support static libs for the MCU/CPU target?
If yes, I suggest trying that.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Vikingo

  • Single posting newcomer
  • *
  • Posts: 7
Re: Using an SDK - Dependency on multiple object files
« Reply #2 on: February 25, 2014, 02:52:02 pm »
ok, thanks for the refresh.

On a separate project, I was able to build the library by including all source files and compiling but not linking and then manually building the lib. Great!

I want to build/refresh the lib automatically. I thought that adding a post build step would be fine but I can't get all the compiled filenames ($linkobjects is not working)

The lib utility for SDCC can handle either all .rel files as parameters, or a text file with one line for each .rel file

So the questions are:

1 - How do I grab all object files (.rel) into a variable I can pass to my post build step?
2 - How can I build that list with a simple script into a .txt file?

Thanks
Alex

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6663
    • My Best Post
Re: Using an SDK - Dependency on multiple object files
« Reply #3 on: February 25, 2014, 03:08:56 pm »
I suggest using CB build system; instead of fighting it.
Or, I suggest using a custom makefile.

If using the CB Build system try the following.
Lookup how to do targets inside a CB Project.
Have a target build the static library.
Have a second target use the static library.

Note: I have NOT done the above using SDCC; but, it should be possible.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6663
    • My Best Post
Re: Using an SDK - Dependency on multiple object files
« Reply #4 on: February 25, 2014, 03:22:39 pm »
If the SDK is open source or free download, post a link to it?

Edit: Posting the full CB "build log" will help me help you. http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F

Tim S.
« Last Edit: February 25, 2014, 04:13:29 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Vikingo

  • Single posting newcomer
  • *
  • Posts: 7
Re: Using an SDK - Dependency on multiple object files
« Reply #5 on: February 25, 2014, 05:58:20 pm »
Got it! I was missing the essential 1st step to pick the right project type...

Selected "Static Lib" and... builds flawlessly!!!

BTW: I never wanted to fight CB, I just didn't find the answer looking around.

As a newbie I find code::blocks really powerful and well thought. However I think some basic task orienting "recipes" would be really helpful for newcomers.
I mean, tasks like prioritizing a file on the link sequence, or building a lib have the right solution but I haven't got them as easy as I expected.
A "What do you want to do today..." section with typical projects would be great (and maybe would save time for many of you :)

Thanks for the patience and support

Regards
Alex
« Last Edit: February 25, 2014, 06:00:04 pm by Vikingo »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9504
Re:
« Reply #6 on: February 25, 2014, 07:26:58 pm »
But how would you figure out a right linker sequence for literally any sdk out there? It's impossible. So it's really a task of the developer to read the docs of the sdk (s)he is using and doing it right in the first place. I'm afraid there is nothing we can do about...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline Vikingo

  • Single posting newcomer
  • *
  • Posts: 7
Re: Using an SDK - Dependency on multiple object files
« Reply #7 on: February 26, 2014, 02:08:55 am »
I totally agree on a product oriented sense (i.e: the developer's product is the developer's resposibility) however I meant a task oriented help (which is deeply related to the tool chain you are using)

In this last context it's not about "what" but about "how" do I do this or that

For example:

1) I know I have to link in this particular order, sure CB can do it. How do I do it?

2) I need to build a library, again sure CB can do it but how?

Keep in mind that for you guys experienced on CB this might be trivial, for the newcomers it's quite different. At release 13.12 you already know (newbies included) that for sure CB has the ability to do what you need, but the newbie is lost at all the daunting possible places where the solution might be. So the CB "cookbook" would be great in easying the learning curve for the newcomer. Just my 2cts.

Alex

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6663
    • My Best Post
Re: Using an SDK - Dependency on multiple object files
« Reply #8 on: February 26, 2014, 02:16:27 am »
Did you read the User Docs?
Note, I have NOT read them; So, the answer might not be in them.

http://wiki.codeblocks.org/index.php?title=User_documentation

Tim S.


C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Vikingo

  • Single posting newcomer
  • *
  • Posts: 7
Re: Using an SDK - Dependency on multiple object files
« Reply #9 on: February 26, 2014, 03:01:00 am »
Did you read the User Docs?
Note, I have NOT read them; So, the answer might not be in them.

http://wiki.codeblocks.org/index.php?title=User_documentation

Tim S.
No, the answers are not there (they are now in the forum :-), and
Yes, I have read some articles that helped me start (which coincidentaly are kind of recipes close to what I needed (http://wiki.codeblocks.org/index.php?title=Using_the_Code::Blocks_IDE_with_SDCC_on_PIC_MCUs) and many are quite helpful.

On the other hand many are for general knowledge and insight which is good in the long run but too long to read for quick starts. Unless you have plenty of time or you are building a tool instead of a product, you generally are focused on the final result and not on all the subtleties of your tool chain (you'll have time for that later). So a quick list of steps to do the chore is of invaluable help, you backup plan for a fast insight of course is to ask the tool community for help and I greatly appreciate the answers.

I find that page a good work in progress, augmenting the articles with more straight to the task chores would be great.

Alex

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9504
Re:
« Reply #10 on: February 26, 2014, 05:43:42 am »
I  believe that the user docs plus our faq provide all necessary information. Maybe we should add the faq to the user docs...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ