Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create a lib

Status
Not open for further replies.

KingOfJava

Programmer
Feb 21, 2003
7
US
//Example.cpp

// MAIN FILE : It make use of Test.h and Test.cpp

#include "Test.h"

int main(){
Test *t = new Test("KingOfJava");
cout << t->getMessage() << endl;
}

//++++++++++++++++++++++++++++++++++++++++

//Test.h

#include <iostream>
#include <string>
using namespace std;

class Test{

string msg;

public:

Test(string s);

string getMessage();


};

//++++++++++++++++++++++++++++++++++++++++

// Test.CPP

#include &quot;Test.h&quot;

Test::Test(string s){
msg = s;
}
string Test::getMessage(){
return msg;
}
//+++++++++++++++++++++++++++++++++++++++++++++++++

I am new to CPP and I wanted to creat an example of Lib file.

I have created a header file I wanted to put it in Include directory of Borland comp

Test.cpp I wanted to creat an object file out of it. And wanted to put it in Lib directory.

And I wanted to write an example program which make use of them.

Please help how to do them.

Thanx in advance,

Regards,
 
You ought to put this in the Borland forum. I don't think many Unix people know very much about the Borland IDE etc.
 
My Question is like this:

I wanted to create an Intermediat files and place them in (header file in include directory) and Object file in lib or object files directory so that a user using it has not to worry about $LD_LIBRARY_PATH or $PATH to be set.

Test.h goes to include directory.
Test.cpp goes to other directory prob lib.

A user writing an Example.cpp just have to include Test.h in his file just as #include <iostream.h>

Thanx in advance,

Samule.
 
Hi,
I am not sure about borland IDE. But, if you are using forte compiler (Sun workshop on Solaris) or g++ on Linux, then ..
1. You can generate .so (shared object ..similar to dll on windows) using -so flag and put it in some folder (designed for libraries).
2. Either include this folder in LD_LIBRARY_PATH or
use -L&quot;Lib folder location&quot; while compilation of Example .cpp, and -l&quot;Library name with full path&quot; while compilation of Example.cpp

Or, generate .a files (static lib files) and link them at the time of compilation

All these options are there in man pages for g++ (linux) and CC (Solaris)

Hope this helps :)

regards,
Mahesh
 
hello
I look for the equivalent for the function fnsplit() (builder c++ on windows) on linux in my program. please if someone knew something about this, write to me thanks in advance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top