Solved

How to avoid resolving extern symbol?

Posted on 2008-06-11
6
251 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
Comment Utility
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
 

Author Comment

by:naseeam
Comment Utility
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
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:naseeam
Comment Utility
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
Comment Utility
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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops 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.

744 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

13 Experts available now in Live!

Get 1:1 Help Now