Jump to content
Sign in to follow this  
ZotDitzMyo

CCS Static Library for Launchpad

Recommended Posts

I'm having the hardest time trying to do something that seems easy enough, building a static library in CCS.

I can build the library fine, but cannot successfully link an application against it. Here is my test code:

 

/// testlib header file
#ifndef TEST_H_
#define TEST_H_

int testfunc(int x);

int testfunc2(int x)
{
return x*2;
}
#endif /*TEST_H_*/

 

/// testlib source file
#include "test.h"

int testfunc(int x)
{
return x*2;
}

 

/// application source file
#include "../testlib/test.h"

void main(void) 
{
int y = testfunc2(33);
int z = testfunc(33);
}

 

Seems easy enough! I always end-up with this:

undefined first referenced

symbol in file

--------- ----------------

testfunc ./test.obj

 

error: unresolved symbols remain

error: errors encountered during linking; "testexe.out" not built

 

I added the static lib as a reference in the application, I also added a -l option to the linker command line and can never get it to compile. I have seen some launchpad "libraries" out there completely implemented in header files. Is this a coincidence? Is linking with user defined libs allowed in the code limited version of CCS?

 

Thanks!

Share this post


Link to post
Share on other sites

I finally had some free time and managed to get it to work. I guess changing compiler, IDE, microcontroller got me distracted...

 

I found an nm utility in ccsv4/tools/compiler/msp430/nm430.exe. used it on the lib and saw that it generated testfunc__Fi as an export symbol. After looking around at the compiler options, I realized that the library source file was .cpp and not .c!! D'oh!

 

Everything fine now, move along people!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...