Solved

How to avoid resolving extern symbol?

Posted on 2008-06-11
6
260 Views
Last Modified: 2010-04-15
Softwar Library externs a symbol something like follows:

extern const some_struct_type rtos_config;

My application links this software library.  During link time I get the following error:

"error:  external symbol not defined:  rtos_config"

I don't need to use this symbol in my application.  Is there any shortcut way to get around this link error.?  How can I define it in my application without populating all the members of the structure?

thanks.
0
Comment
Question by:naseeam
  • 3
  • 2
6 Comments
 
LVL 53

Expert Comment

by:Infinity08
ID: 21763921
It seems you didn't link your code to the library. If you don't link to it, you won't be able to use any of its features. If you link to it, all features of the library are available. There's no real middle way ...
0
 
LVL 1

Author Comment

by:naseeam
ID: 21764047
If library has a reference as follows:

extern const unsigned int some_var;

If I don't define this variable in my application, I'll get a linker error.  I don't need this variable but I'll define it anyways so the linker error goes away.  But if this variable was type some large strucuture then, I would have to set all the members of the structure.  Is there anyway to define a variable as unused or something so I don't have to populate all the members of the structure.
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 21764063
If the header file of the library contains this line :

        extern const some_struct_type rtos_config;

then it means that the library defines that variable. You don't have to define it yourself in your application - you simply have to link your code against the library.
0
ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 
LVL 1

Author Comment

by:naseeam
ID: 21764117
I believe the library is only referencing rtos_config variable.  Applications are expected to define it.  All our applications that use operating system define this variable.  My application doesn't have operating system so I don't need to define this variable but I have to in order to avoid the link error.  Can I define it unused so I don't have to populate all the members of the structure.
0
 
LVL 53

Accepted Solution

by:
Infinity08 earned 340 total points
ID: 21764127
If the library needs this variable defined, then you will have to define it one way or another. If you are sure that the library won't actually use it, then you can just define a dummy variable like :

        const some_struct_type rtos_config;

But make sure that it doesn't us it first.
0
 
LVL 11

Assisted Solution

by:cup
cup earned 160 total points
ID: 21764462
Check the library header - some have special defines which you have to use to force a declaration and possibly initialization in your own code when you #include the header.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question