LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-28-2011, 09:03 AM   #1
EmbeddedSteve
LQ Newbie
 
Registered: Sep 2006
Posts: 17

Rep: Reputation: 0
Linux: App Link Error with Shared Library - Varadic Macro Issue


Greetings all!
I seem have run into a rather sticky issue here, and I'm not finding the answers I'm looking for. I'm hoping someone here has the answer to my woes.
I'm building an embedded linux shared library. I've done this many times before. Difference this time is that we are trying to standardize on some debug macro's in the code. In a header file, I have:
#define LIB_ERR(fmtStr,args...) { printf("ERROR: "); (void) printf(fmtStr , ##args );}
I compile this just fine as a shared library, no errors. When I then go to link my application to this, I get:
/home/Proj/Install/usr/local/lib/brd/libBoard.so: undefined reference to `LIB_ERR'
I include <stdio.h> and <stdarg.h> in the header file to find the printf and varadic info.
Compiler is PPC7xx, version 3.3.1 from Montavista, so it "should" be able to support this setup.
We have a different project, using ARM (4.2.x) in a similar setup and there's no issues.
I've read the GNU specs on varadic macro's, tried different spacing in the definition. Removed the first printf (there is a different macro with the 2 printf's that I don't seem to have a problem with, it's only invoked once though.
Using Eclipse, when I roll-over the Macro, it will expand correctly.
Any insight would be greatly appreciated!
Thanks in Advance for your comments!
Steve
 
Old 02-28-2011, 09:38 AM   #2
z1p
Member
 
Registered: Jan 2011
Location: the right coast of the US
Distribution: Ubuntu 10.04
Posts: 80

Rep: Reputation: 23
That the linker is reporting an undefined symbol for what you have defined as a macro, indicates that in at least one of your files you are not including the needed header file or 'ifdefs' are causing the definition of the macro to be skipped.
 
Old 02-28-2011, 09:39 AM   #3
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,786

Rep: Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083
Quote:
/home/Proj/Install/usr/local/lib/brd/libBoard.so: undefined reference to `LIB_ERR'
That sounds like LIB_ERR is getting interpreted as a function call instead of a macro. Maybe you forgot to #include the definition in one of libBoard's sources? If you compile with -Wall and -Wextra you should get a warning about it, something like "implicit declaration of function LIB_ERR".

EDIT: whoops, ninja'd by z1p

Last edited by ntubski; 02-28-2011 at 09:41 AM.
 
1 members found this post helpful.
Old 02-28-2011, 10:00 AM   #4
EmbeddedSteve
LQ Newbie
 
Registered: Sep 2006
Posts: 17

Original Poster
Rep: Reputation: 0
Many thanks!

z1p, you nailed it! One (of ~ 12) files was missing the necessary include. I could have sworn it was there. . . (too many files, so little time. . . )
ntubski, the warning's were not enabled for the library build, that's why it was not picked up. I will tweak the build system (not mine, someone else's) to get these turned on!
MANY THANKS! I now have the test application linked and ready for testing.
Regards,
Steve
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
will my app work if the shared library version changed? KillerCode Programming 11 02-17-2011 06:54 AM
[SOLVED] Link shared library against other shared library Lobinho Linux - Newbie 2 05-28-2010 08:16 AM
unable to link against a 'c' shared library vessper Linux - Software 4 11-09-2009 10:49 AM
gcc link shared library against another shared library qcp Linux - Newbie 1 07-25-2008 11:15 AM
Link shared library in Kdevelop neikinfology Linux - Software 0 07-12-2007 03:35 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration