Can a compiled C++11 library (lib,dll,etc.) be linked in older C++ compilers?

Could older C++ compilers (e.g. VS2008 and gcc3.4) link with external libraries written in C++11?

My thought is that the C++11 .lib files are just byte code at this stage, and it shouldn’t bother the older compilers how it was generated, as long as it is somehow resolvable and callable.

I’m developing a small library whose API should still support C++03 users. So, looking forward, I’m wondering whether it’s ok to implement my library using helpful features like std::unique_ptr and such, or do I have to just stick with boost::?

0

Provided your library only uses C++11 in its implementation and doesn’t expose C++11 facilities or types publically, and especially if you use static linkage, then yes, this is possible and even standard.

Consider the common case where a library exposes a C-level interface (to be usable by the widest variety of clients) but which is internally implemented in C++. Clients linking against such a library need only worry about the public binary API (exported functions), which you’ll have constrained to be legacy C/C++ for maximum compatibility. A Java program can link to C-level APIs which are internally implemented in C++. This does not mean that Java needs to “support C++”. Similarly, an old-style C/C++ client can link to a C-level or C++-level API which internally uses some more avant-garde version of the C++ libs or any other libs. Two separate things: what’s required to link to the library’s interface, and what the library itself internally links to (or pulls in statically).

You simply don’t expose clients of your library to the dependencies of your implementation.

If you can statically link your dependencies (C++11 or whatever else) into your library, this is clean and self-contained. The library is a true black box: nothing but bytecode. But even if your library links to your dependencies via “implicit dynamic” linkage (not to be confused with the explicity LoadLibrary/GetProcAddress kind and the similar methods on *nix and OS X), older clients should still be able to link to that library’s public interface, even if they couldn’t link to the libraries the library depends on.

1

Sounds like you want to write a new library for others to use, and that you would like to use C+11 as your implementation language. There are a number of issues to consider:

  • by introducing a new version of C++ you will introduce the need to deploy the new C++ runtime libraries with your library, is that OK?
  • you should not use new C+11 types in your public interface, otherwise they will not be able to call it.
  • In general, you should avoid complex types, such as unique_ptr, even vector, etc. Unless you are distributing your library as source code, the layout of the objects in your library may differ from the layout in the client code. Stick with simple types that have no risk of object layout variations.

0

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật