Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to avoid dead lock in linking lib files ?

5 views
Skip to first unread message

Esha

unread,
Dec 28, 2009, 8:10:17 AM12/28/09
to
I have added a sub project to a working kernel image on x86 platform and
using wince 6.0

This project has several dir with sources and each one of them I have
made as a lib. I could build and produce these lib files also.

I wrote an app to test these and in the app using SOURCELIBS i'm linking
all these lib files - But they seem to be interdependent and generating
lots of unresolved external... My app sources has SOURCELIBS like this :-

SOURCELIBS=\
$(_SYSGENSDKROOT)\lib\$(_CUINDPATH)\acpi_hardware.lib\
$(_SYSGENSDKROOT)\lib\$(_CUINDPATH)\acpi_utilities.lib\
$(_SYSGENSDKROOT)\lib\$(_CUINDPATH)\acpi_tables.lib\
$(_SYSGENSDKROOT)\lib\$(_CUINDPATH)\acpi_events.lib\
$(_SYSGENSDKROOT)\lib\$(_CUINDPATH)\acpi_namespace.lib

The above list is grown from bottom up as i compiled and tried to
resolve the unresolved externals. but now after adding
acpi_hardware.lib, this lib file is generating unresolved externals
which are actually present in acpi_utilities.lib .....

Is there any better way of doing things to avoid this dead lock ?

Regards
Esha

Luca Calligaris [eMVP]

unread,
Dec 28, 2009, 9:36:23 AM12/28/09
to
What if you use the TARGETLIBS directive?

--
Luca Calligaris (MVP-Windows Embedded)
l.calliga...@eurotech.it.nospam
www.eurotech.it


"Esha" <iimean...@yahoo.com> ha scritto nel messaggio
news:eNFF357h...@TK2MSFTNGP05.phx.gbl...

Vinoth [MCTS]

unread,
Dec 29, 2009, 1:14:02 AM12/29/09
to

you can use SOURCELIBS directive to create only lib files. you can use
TARGETLIBS to link your libs with the exe or dll.
--
vinoth.R
http://vinoth-vinothblog.blogspot.com
http://www.e-consystems.com


"Luca Calligaris [eMVP]" wrote:

> .
>

Esha

unread,
Dec 30, 2009, 2:05:15 AM12/30/09
to

Can a lib file be linked to an app directly without the creation of a
DLL and without export functions in a def file ?

I'm not able to link these lib files to the app. App still gives
unresolved symbols.

The over all development I have done is,

1. There are 8 directories each of with creates their .lib files -
successful
2. Added and app to test these libs hence in the sources, added
TARGETLIBS with all the 8 libs - unsuccessful.

I had thought that these libs need not have to be in a sequence when
being added in the TARGETLIBS since they are static libraries and also
because of the very fact that they are statically linked libraries,
there is no need to have a .def file with the export functions....


Should I have to create a DLL linking with all these libs and then
exporting the required functions in the .def file so that that this dll
can be used by the application ?

Its all confusing... Please suggest

Regards
Esha

Esha

unread,
Dec 30, 2009, 2:07:47 AM12/30/09
to
Some webcast by microsoft suggests that -
mms://wm.microsoft.com/ms/msnse/0906/1000484/Demo1_mod5.wmv

So is the confusion about which way to go ?

Regards
Esha

Gurusamy

unread,
Jan 5, 2010, 3:17:01 AM1/5/10
to
Yes. A LIB file can be linked against an APP without creating a DLL and
without a .def file.

According to me, you should
1. Include the required header files (Which have the declarations of the
functions you are calling in the LIB files) and mention their paths in the
sources file.

2. Include the LIB files and their paths in the sources file.

Header File paths should be mentioned under "INCLUDES=" section and LIB
files under "TARGETLIBS="section in the sources file.

Hope this helps.
-R.Gurusamy


"Esha" wrote:

> .
>

Bradley Remedios

unread,
Jan 6, 2010, 8:29:43 PM1/6/10
to
Not sure if you've solved this yet (I just noticed it now.) but I've
seen people get into this problem when they've compiled the library
one way and the header another (i.e. one in C other in C++). Often
this can be caused by missing an extern "C" around a C function
prototype or something similar when being used by C++ code.

For example, if you compile the library as a C Static Library but
include the header (or function declarations) from C++ source without
explicitly stating they are C they will be used as C++ Symbols.

e.g.

--- Start mylibfile.c, this is used in mylib.lib --

BOOL CoolFunc(int value)
{
if (value > 0)
return TRUE;
else
return FALSE;
}

-- End mylibfile.c

-- Start mylib.h, could also just be a function prototype in the
callers file --
BOOL CoolFunc(int value);

-- End mylib.h --

-- Start mycaller.cpp, this is either part of a different static
library, DLL or EXE --

#include "mylibfile.h"

BOOL OtherFunc(int value)
{
return CoolFunc(value); <- this will be unresolved.
}

-- End mycaller.cpp --

The problem is that mycaller.cpp will get compiled as C++ code, and
the function declaration BOOL CoolFunc(int value); will get pulled
into that C++ code as a C++ Function which means it will have all that
wonderful mangling and stuff. The problem is that BOOL CoolFunc(int
value) that is present in mylib.lib is actually a C Function and
doesn't have the mangling that the C++ version should.

So when the compiler looks for CoolFuncABDX$%#X in mylib.lib it cannot
find it (even though CoolFunc is present.)

If this is not the problem, I think you will need to post more
information such as the offending functions, along with the the use,
and declarations of them.

Regards,
Brad.
On Jan 5, 12:17 am, Gurusamy <Gurus...@discussions.microsoft.com>
wrote:

0 new messages