Thread: RE: [Dev-C++] linking .h file and .cpp file
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Manish S. <msh...@qu...> - 2004-05-21 10:37:53
|
Is it a standard that all declarations shud go into .h and implementations
in .cpp (or just a convention). Though I see that most compiler doesn't
allow to compile .h and even if they do, they give a linking error for
main() (even if it is present in .h)
Manish
-----Original Message-----
From: dev...@li...
[mailto:dev...@li...] On Behalf Of Vlada
Djurovic
Sent: Friday, May 21, 2004 3:46 PM
To: casper; dev...@li...
Subject: Re: [Dev-C++] linking .h file and .cpp file
----- Original Message -----
From: "casper" <oz...@op...>
To: <dev...@li...>
Sent: Friday, May 21, 2004 11:15 AM
Subject: [Dev-C++] linking .h file and .cpp file
> Hi,
>
> I have a file with .h extension which includes my main program.
I
> have put
>
> #include "logfuncion.cpp"
>
> In the .h extension file. And inside the .cpp file I have put
the
> function definitions.
>
> Both files are in the same directory, but the .h file failed to compile
> because of the error
>
> Undefined "logfuncion.cpp"
>
> How could I solve the problem?
>
> Thanks in advance.
>
It should be the other way around. Your function declarations should go in
.h file, and their definitions in .cpp.
For example:
---myheader.h---
class Myclass{
public void f();
public int g(int x);
}
--end of myheader.h---
And in mymain.cpp you should do:
----mymain.cpp------
#include <myheader.h>
void Myclass::f(){
//define function
}
int Myclass::g(int x){
//define function
}
----end mymain.cpp----
-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
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
|
|
From: Vlada D. <dj...@im...> - 2004-05-21 12:19:16
|
----- Original Message -----
From: "Manish Shrivastava" <msh...@qu...>
To: "Vlada Djurovic" <dj...@im...>; "casper"
<oz...@op...>; <dev...@li...>
Sent: Friday, May 21, 2004 12:31 PM
Subject: RE: [Dev-C++] linking .h file and .cpp file
> Is it a standard that all declarations shud go into .h and implementations
> in .cpp (or just a convention). Though I see that most compiler doesn't
> allow to compile .h and even if they do, they give a linking error for
> main() (even if it is present in .h)
>
> Manish
Well, I don't know if it's a standard. I don't really have much experience,
but I've seen in many places that this is the recomended way to do things. I
think it represents the separation of interface( declaration) from
implementation (definitions), which is much talked about in OOP books. You
could also put both declarations and definitions in one file, but it reduces
readability, reusability, and probably some other problems.
Anyway, somebody with more experience will probably explain this better than
me. :-)
> -----Original Message-----
> From: dev...@li...
> [mailto:dev...@li...] On Behalf Of Vlada
> Djurovic
> Sent: Friday, May 21, 2004 3:46 PM
> To: casper; dev...@li...
> Subject: Re: [Dev-C++] linking .h file and .cpp file
>
>
> ----- Original Message -----
> From: "casper" <oz...@op...>
> To: <dev...@li...>
> Sent: Friday, May 21, 2004 11:15 AM
> Subject: [Dev-C++] linking .h file and .cpp file
>
>
> > Hi,
> >
> > I have a file with .h extension which includes my main
program.
> I
> > have put
> >
> > #include "logfuncion.cpp"
> >
> > In the .h extension file. And inside the .cpp file I have put
> the
> > function definitions.
> >
> > Both files are in the same directory, but the .h file failed to compile
> > because of the error
> >
> > Undefined "logfuncion.cpp"
> >
> > How could I solve the problem?
> >
> > Thanks in advance.
> >
> It should be the other way around. Your function declarations should go in
> .h file, and their definitions in .cpp.
> For example:
> ---myheader.h---
> class Myclass{
> public void f();
> public int g(int x);
> }
> --end of myheader.h---
> And in mymain.cpp you should do:
>
> ----mymain.cpp------
> #include <myheader.h>
> void Myclass::f(){
> //define function
> }
> int Myclass::g(int x){
> //define function
> }
> ----end mymain.cpp----
>
>
>
> -------------------------------------------------------
|
|
From: Vivek J. <viv...@ya...> - 2004-05-21 16:59:38
|
I am trying to compile my project and am getting the following linker error. Which libraries am I missing [Linker error] undefined reference to `_Unwind_SjLj_Register' [Linker error] undefined reference to `_Unwind_SjLj_Resume' [Linker error] undefined reference to `_Unwind_SjLj_Unregister' [Linker error] undefined reference to `__gxx_personality_sj0' Regards, Vivek Jishtu ------------------------------------------------------------------------ Make your programs with the ease of BASIC and Power of C++ usiing EzBasic http://ezbasic.sf.net/ ------------------------------------------------------------------------- --------------------------------- Do you Yahoo!? Yahoo! Domains - Claim yours for only $14.70/year |
|
From: Per W. <pw...@ia...> - 2004-05-21 17:25:21
|
Ever tried to just go to your lib directory and try grep _Unwind_SjLj_Unregister * A tip: libstdc++ /Per W On Fri, 21 May 2004, Vivek Jishtu wrote: > > I am trying to compile my project and am getting the following linker error. Which libraries am I missing > > > [Linker error] undefined reference to `_Unwind_SjLj_Register' > [Linker error] undefined reference to `_Unwind_SjLj_Resume' > [Linker error] undefined reference to `_Unwind_SjLj_Unregister' > [Linker error] undefined reference to `__gxx_personality_sj0' > > Regards, > > Vivek Jishtu > ------------------------------------------------------------------------ > Make your programs with the ease of BASIC and > Power of C++ usiing EzBasic > http://ezbasic.sf.net/ > ------------------------------------------------------------------------- > > > > --------------------------------- > Do you Yahoo!? > Yahoo! Domains - Claim yours for only $14.70/year |
|
From: Vivek J. <viv...@ya...> - 2004-05-22 06:57:04
|
I even tried out c:/dev-cpp/lib/*.a but am still getting that error. And yes these funtions are in libstdc++.a but as far as i know that file is automatically linked. Regards, Vivek Jishtu Per Westermark <pw...@ia...> wrote: Ever tried to just go to your lib directory and try grep _Unwind_SjLj_Unregister * A tip: libstdc++ /Per W On Fri, 21 May 2004, Vivek Jishtu wrote: > > I am trying to compile my project and am getting the following linker error. Which libraries am I missing > > > [Linker error] undefined reference to `_Unwind_SjLj_Register' > [Linker error] undefined reference to `_Unwind_SjLj_Resume' > [Linker error] undefined reference to `_Unwind_SjLj_Unregister' > [Linker error] undefined reference to `__gxx_personality_sj0' > > Regards, > > Vivek Jishtu > ------------------------------------------------------------------------ > Make your programs with the ease of BASIC and > Power of C++ usiing EzBasic > http://ezbasic.sf.net/ > ------------------------------------------------------------------------- > > > > --------------------------------- > Do you Yahoo!? > Yahoo! Domains - Claim yours for only $14.70/year ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click _______________________________________________ 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 --------------------------------- Do you Yahoo!? Yahoo! Domains - Claim yours for only $14.70/year |
|
From: Per W. <pw...@ia...> - 2004-05-22 10:58:53
|
Well, I would still recommend that you try and add the -lstdc++ parameter to your linker settings. /Per W On Fri, 21 May 2004, Vivek Jishtu wrote: > I even tried out c:/dev-cpp/lib/*.a but am still getting that error. And yes these funtions are in libstdc++.a but as far as i know that file is automatically linked. > > Regards, > Vivek Jishtu > > Per Westermark <pw...@ia...> wrote: > Ever tried to just go to your lib directory and try > grep _Unwind_SjLj_Unregister * > > A tip: libstdc++ > > /Per W > > On Fri, 21 May 2004, Vivek Jishtu wrote: > > > > > I am trying to compile my project and am getting the following linker error. Which libraries am I missing > > > > > > [Linker error] undefined reference to `_Unwind_SjLj_Register' > > [Linker error] undefined reference to `_Unwind_SjLj_Resume' > > [Linker error] undefined reference to `_Unwind_SjLj_Unregister' > > [Linker error] undefined reference to `__gxx_personality_sj0' > > > > Regards, > > > > Vivek Jishtu > > ------------------------------------------------------------------------ > > Make your programs with the ease of BASIC and > > Power of C++ usiing EzBasic > > http://ezbasic.sf.net/ > > ------------------------------------------------------------------------- > > > > > > > > --------------------------------- > > Do you Yahoo!? > > Yahoo! Domains - Claim yours for only $14.70/year > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: Oracle 10g > Get certified on the hottest thing ever to hit the market... Oracle 10g. > Take an Oracle 10g class now, and we'll give you the exam FREE. > http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click > _______________________________________________ > 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 > > --------------------------------- > Do you Yahoo!? > Yahoo! Domains - Claim yours for only $14.70/year |