Solved

How to avoid resolving extern symbol?

Posted on 2008-06-11
6
262 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
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

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…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.

856 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