473,662 Members | 2,588 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

link against stl (different implementation of)


hello everybody,
I have an application that uses a 3D engine library compiled as a
static library called EnRG.lib. My own code is normally compiled
against the MS Visual C implementation of the stl, and everything
works fine.
I wanted to try to link the same code against the stlport. but I get a
lot of linking errors (i report one of those at the end of the
message) and I don't understand why...
could it be because the EnRG lib is compiled with the MS's stl?? being
it a static lib, shouldn't it incorporate the code it needs and leave
me free to link my own code against the library that I prefer?
any hint??
thank you
Ricky

error example:
cameraUtils.obj : error LNK2001: unresolved external symbol
"public: bool __thiscall
EnRG::Graphics: :Win32DisplayMa nager::Register WndClass(class_ STL::basic_stri ng<char,class
_STL::char_trai ts<char>,class _STL::allocator <char> > const &,unsigned
long,unsigned long,unsigned long,unsigned long)"
(?RegisterWndCl ass@Win32Displa yManager@Graphi cs@EnRG@@QAE_NA BV?$basic_strin g@DV?$char_trai ts@D@_STL@
@V?$allocator@D @2@@_STL@@KKKK@ Z)
Jul 22 '05 #1
2 1831
Ricky Corsi wrote:
I have an application that uses a 3D engine library compiled as a
static library called EnRG.lib. My own code is normally compiled
against the MS Visual C implementation of the stl, and everything
works fine.
I wanted to try to link the same code against the stlport. but I get a lot of linking errors (i report one of those at the end of the
message) and I don't understand why...
The library implementations and declarations differ in rather many
aspects: Although they should be source compatible, it is almost
certain that they are not binary compatible.
could it be because the EnRG lib is compiled with the MS's stl??
Quite likely.
being
it a static lib, shouldn't it incorporate the code it needs and leave
me free to link my own code against the library that I prefer?


No: there can only be one standard library in a program. Actually,
you are even more restricted than you think you are: using a
compiler with a different standard library than the one shipping
with the compiler is not guaranteed to work at all! After all, the
compiler generates code dependant on standard library classes. For
example, 'std::bad_cast' is defined by standard library but the
throw statement is generated by the compiler when you do a
dynamic_cast on a reference. There are things a library implementor
can do to avoid most of the problems. One of the options is to
implement the replacement library in a different namespace than
'std' and then use macro magic to make it appear as if it is in
namespace 'std'. Of course, this means that *both* the original
and the add-on standard library need to be linked! (I think this is
the approach taken by STLPor).
--
<mailto:di***** ******@yahoo.co m> <http://www.dietmar-kuehl.de/>
<http://www.contendix.c om> - Software Development & Consulting

Jul 22 '05 #2
Dietmar Kuehl wrote:
Ricky Corsi wrote:
I have an application that uses a 3D engine library compiled as a
static library called EnRG.lib. My own code is normally compiled
against the MS Visual C implementation of the stl, and everything
works fine.
I wanted to try to link the same code against the stlport. but I get
a
lot of linking errors (i report one of those at the end of the
message) and I don't understand why...

The library implementations and declarations differ in rather many
aspects: Although they should be source compatible, it is almost
certain that they are not binary compatible.

could it be because the EnRG lib is compiled with the MS's stl??

Quite likely.

being
it a static lib, shouldn't it incorporate the code it needs and leave
me free to link my own code against the library that I prefer?

No: there can only be one standard library in a program. Actually,
you are even more restricted than you think you are: using a
compiler with a different standard library than the one shipping
with the compiler is not guaranteed to work at all! After all, the
compiler generates code dependant on standard library classes. For
example, 'std::bad_cast' is defined by standard library but the
throw statement is generated by the compiler when you do a
dynamic_cast on a reference. There are things a library implementor
can do to avoid most of the problems. One of the options is to
implement the replacement library in a different namespace than
'std' and then use macro magic to make it appear as if it is in
namespace 'std'. Of course, this means that *both* the original
and the add-on standard library need to be linked! (I think this is
the approach taken by STLPor).


Thanks Dietmar.
So this means that when you build a static lib, it takes internal
reference to the symbols deriving from the STL right?
And this means also that when you get for instance an open source
library from the web,
- either you recompile it with the STL you want to use
- either (in case you use the precompiled version) you must adapt and
use the same stl implementation the precomp. library uses.
Am I right? this is pretty annoying...

One last question: can you give me some more details or suggest a
reading for the "macro magic" trick? I never heard about it before...

thank you
ricky

--
<mailto:di***** ******@yahoo.co m> <http://www.dietmar-kuehl.de/>
<http://www.contendix.c om> - Software Development & Consulting

Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
23003
by: lawrence | last post by:
In my style sheet I've set the links like this: a:link{ text-decoration:none; } I did that for the pseudo classes and I also did that for the image tag. Yet there are still link lines around the images. Why? It's on this page:
34
3672
by: Dennis | last post by:
I would like to dynamically allocate in a sub a 2 dimensional Array float *myarray = new float ; of course I get an error. How do you allocate a 2D array using the New operator? I currently use static float gxy;
87
5192
by: ziliath | last post by:
I recently tried out the Google "top coder" contest, as a C++ coder. I noticed immediately that they expected me to know STL. To which I say, what the fuck?! I may be missing something, but at what point when learning C++ was I supposed to have picked up STL? I ask because at every job I've had, and every job interview for that matter, whenever STL comes up it's not I, but a manager who says effectively yuck, we don't use that crap.
5
2112
by: sriram | last post by:
I have the following: class BSA { ... ... ... ... public: enum VRGAttrId {
4
1563
by: firegun9 | last post by:
I am not a newbie C++, but I haven't coded multiple files project under g++. Here is my quesiont: b.h //////////////////// #ifndef b_h #define b_h class b{
8
2264
by: Andrew Phillipo | last post by:
I have a layout which works perfectly. It is three column, the central column is width:auto; with margins and the columns are absolutely positioned at top:0px; left:0px; and top:0px;right:0px; In the right column I have a javascript link which hides the column. This is very necessary due to the width of content shown on the site at times. Clicking the link makes the scrollbars appear for no aparent reason - both horizontal by about...
13
2689
by: Derek | last post by:
As I understand it there is a good amount of link compatibility among C compilers. For example, I can compile main.c with GCC and func.c with Sun One and link the objects using either linker (GNU or Sun). What I'm curious about is why this compatibility exists in the absence of a standard C ABI? What encourages C compiler vendors to agree on implementation issues such as alignment, packing, etc., such that their object
1
2079
by: sri2097 | last post by:
Hi all, I have written a Link list implementation in Python (Although it's not needed with Lists and Dictionaries present. I tried it just for the kicks !). Anyway here is the code - # Creating a class comprising of node in Link List. class linklist: def __init__(self, data=None,link=None): self.data = data self.link = link
18
4725
by: happyvalley | last post by:
a silly question. when linking a program, the path to include files and library files are given already (-I, -L), why still need to give the names of some library by -l , say -lm for math library. otherwise, will get no reference error thanks
0
8344
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8857
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8764
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8546
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8633
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5654
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4347
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.