473,395 Members | 1,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Library in library...

A question about linking with a static library that uses code from another
static library.

Suppose we have files A.h and A.cpp defining class A:

//////////////////////
// A.h
class A {
public:
A();
int get_value();
};
//////////////////////

//////////////////////
// A.cpp
#include "A.h"
A::A() {}
int A::get_value() {
return 1;
}
//////////////////////

We compile A.cpp and create a library A.lib.

Now suppose we have another set of files B.h and B.cpp defining class B:

//////////////////////
// B.h
#include "A.h"
class B {
public:
B();
int get_value();
private:
A a();
};
//////////////////////

//////////////////////
// B.cpp
#include "B.h"
B::B() {}
int B::get_value() {
return (2*a.get_value());
}
//////////////////////

Now suppose that we have a file test.cpp using class B:

//////////////////////
// test.cpp
#include <iostream.h>
#include "B.h"
B b();
cout << b.get_value();
//////////////////////

In order for this file to be built the following must be true (correct me if
I am wrong):
1. the compiler must be aware of the paths to both A.h and B.h
2. both A.lib and B.lib must be given to the linker

So, in order for one to use B.lib, one should also have, or be willing to
provide paths and other arguments about, A.lib!

So the question is:

Is there a way to create B.lib and an accompanying header file (say B2.h) in
such a way so that I only need to include this B2.h and link to B.lib in
order to compile a module that uses class B and create an executable? In
other words, is it possible to build B2.h and B.lib in such a way that it
B.lib is redistributable without needing to be accompanied by A.h and A.lib?

Thanx to all in advance

Sweep

P.S. Forgive me for any wrong terminology/expressions, English is not my
native language.

Jul 22 '05 #1
1 1161
On Mon, 8 Dec 2003 21:03:17 +0200, "Sweep" <no*****@ntua.gr> wrote in
comp.lang.c++:
A question about linking with a static library that uses code from another
static library.


The C++ language does not define static libraries or how linking is
performed at all. You need to ask this in a support group for your
particular compiler/linker combination. It is a compiler-specific
issue, not a language one.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
Jul 22 '05 #2

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

Similar topics

2
by: pieter.breed | last post by:
Hi All, The company I work for has traditionally used COM/ActiveX for the solutions that it provides. We are in the process of moving to .NET and a few applications have been written in VB.NET...
3
by: K.S.Liang | last post by:
Hi all, 1> If there are more than one dynamic linking libraries in the file system, how do I know which one is loaded into system? Any C library or system call can tell me which *.so or *.sl is...
1
by: Jim | last post by:
Have fully operational software package developed on VB.NET that worked until Jan 1 2003, with early stage deployments on Oct 10, Oct 23, Nov 11, Dec 12 and Dec 30. When attempted final...
10
by: mwt | last post by:
So in a further attempt to learn some Python, I've taken the little Library program (http://groups.google.com/group/comp.lang.python/browse_thread/thread/f6a9ccf1bc136f84) I wrote and added...
10
by: Julian | last post by:
I get the following error when i try to link a fortran library to a c++ code in .NET 2005. LINK : fatal error LNK1104: cannot open file 'libc.lib' the code was working fine when built using...
20
by: Frank-O | last post by:
Hi , Recently I have been commited to the task of "translating" some complex statistical algorithms from Matlab to C++. The goal is to be three times as fast as matlab ( the latest) . I've...
6
by: =?Utf-8?B?WW9naSBXYXRjaGVy?= | last post by:
Hello, I am using Visual Studio-2003. I created a project to build my library. Since I am using third party libraries as well, I have specified those additional library dependencies in project...
0
by: JosAH | last post by:
Greetings, the last two article parts described the design and implementation of the text Processor which spoonfeeds paragraphs of text to the LibraryBuilder. The latter object organizes, cleans...
0
by: JosAH | last post by:
Greetings, welcome back; above we discussed the peripherals of the Library class: loading and saving such an instantiation of it, the BookMark interface and then some. This part of the article...
16
by: Xiaoxiao | last post by:
Hi, I got a C library, is there a way to view the public function names in this library so that I can use in my C program? Thanks.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
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...

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.