Link to home
Start Free TrialLog in
Avatar of naseeam
naseeamFlag for United States of America

asked on

How to avoid resolving extern symbol?

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.
Avatar of Infinity08
Infinity08
Flag of Belgium image

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 ...
Avatar of naseeam

ASKER

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.
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.
Avatar of naseeam

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of Infinity08
Infinity08
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial