How to avoid resolving extern symbol?

Posted on 2008-06-11
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?

Question by:naseeam
  • 3
  • 2
LVL 53

Expert Comment

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 ...

Author Comment

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.
LVL 53

Expert Comment

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.
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!


Author Comment

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.
LVL 53

Accepted Solution

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.
LVL 11

Assisted Solution

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.

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

910 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now