RE: RE: [Dev-C++] doubts about creating static libs and using them
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: dein_metzger <dei...@ya...> - 2003-07-16 18:36:44
|
Thanks very much. It worked as perfect as it could be :)
-----Original Message-----
From: dev...@li...
[mailto:dev...@li...] On Behalf Of Carlos
Garc=EDa del Monte
Sent: quarta-feira, 16 de julho de 2003 13:55
To: dev-cpp-users
Subject: Re: [Dev-C++] doubts about creating static libs and using them
You don't have to type class when declaring an object.
You must include the header file in the program you're building.
See below and at the end.
Dark Kernel (InacioW-) wrote:
> Hi.
> I=B4ve created the lib called libTest, wich contains
>the following:
>
>#include <iostream.h>
>
>class Test
>{
>public:
> Test();
>};
>
>Test::Test()
>{
> cout << " this is a test";
>}
>
>the file was well-compiled and generated a file called
>libTest.a, wich I can add to the linker and use in
>other program, but I have no Idea about how make a
>reference of the methods.
>
>I tried
>
>
>#include <iostream>
>#include <stdlib.h>
>
>using namespace std;
>
>
>
>class Test; <----- This line has not to be there. And you shall=20
#include the header where that class is defined
>class Teste * test1; <-----First you say Teste, when you haven''t any=20
class named Teste, you have the class named Test.
>extern Teste::Teste();
>
>int main(int argc, char *argv[])
>{
> teste1 =3D new Teste(); // <- the compiler points me
>an error here ... :(
>
> system("PAUSE");=09
> return 0;
>}
>
>so, what=B4s goind wrong?
>someone can help me?
>
>thanks anyway,
>
>__________________________________________________________________
>
>Gesendet von Yahoo! Mail - http://mail.yahoo.de
>Logos und Klingelt=F6ne f=FCrs Handy bei http://sms.yahoo.de
>
>
>-------------------------------------------------------
>This SF.net email is sponsored by: VM Ware
>With VMware you can run multiple operating systems on a single
machine.
>WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at
the
>same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
>_______________________________________________
>Dev-cpp-users mailing list
>Dev...@li...
>TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
>
>
You should do:
File 1: header of test library, test.h
#ifndef TEST_H
#define TEST_H
class Test{
Test();
};
#endif
File 2: source file of test: library, test.cpp
#include <iostream>
#include <test.h>
Test::Test(){
std::cout << "This is a test" << endl;
}
Then you select both files into a static library project and compile it.
You build the library libtest.a.
After that you write your test program, test_program.cpp:
#include <test.h>
#include <stdlib.h>
int main(){
Test *test_object =3D new Test();
system("PAUSE");
return 0;
}
Then you compile it with the option -ltest for linker.
-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.501 / Virus Database: 299 - Release Date: 14/7/2003
=20
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.501 / Virus Database: 299 - Release Date: 14/7/2003
=20
|