G++ Compile error

G++ Compile error

Post by Derek Gerstman » Wed, 18 Aug 1999 04:00:00



  GCC/G++ is not correctly compiling or linking external includes
for a bunch of my C++ code.  I'm currently running on an SGI 8
proccessor 0rigin server using Irix 6.4 and GCC 2.8.1.  The code is
fine, but the compiler is not correctly finding objects and methods
in  external code modules.  For instance, I have an external module
"rerez.c" that contains the function "filterzoom", but I get the
following linking error when I include "rerez.c" (#include "rerez.c")
in my code:

ld: ERROR 33: Unresolved text symbol "filterzoom" -- 1st referenced by
/var/tmp/cca000p81.o.

I get a similar error for all external files that I include when I try
and access their associated methods or objects.  The preprocessor
correctly finds the files, but the linker seems to be failing.  I don't
have a problem with standard libraries (#include <stdio>), but all
of my files seem to generate an error similar to the one above.
Are there any particular options that I should set when invoking
gcc from the command line? Any help would be most appreciated.

 
 
 

G++ Compile error

Post by Bob Moshe » Fri, 20 Aug 1999 04:00:00


The last time I got this error message it was because I forgot to put a
"-l"
in my makefile to point to the library containing the function being
complained
about.

>   GCC/G++ is not correctly compiling or linking external includes
> for a bunch of my C++ code.  I'm currently running on an SGI 8
> proccessor 0rigin server using Irix 6.4 and GCC 2.8.1.  The code is
> fine, but the compiler is not correctly finding objects and methods
> in  external code modules.  For instance, I have an external module
> "rerez.c" that contains the function "filterzoom", but I get the
> following linking error when I include "rerez.c" (#include "rerez.c")
> in my code:

> ld: ERROR 33: Unresolved text symbol "filterzoom" -- 1st referenced by
> /var/tmp/cca000p81.o.

> I get a similar error for all external files that I include when I try
> and access their associated methods or objects.  The preprocessor
> correctly finds the files, but the linker seems to be failing.  I don't
> have a problem with standard libraries (#include <stdio>), but all
> of my files seem to generate an error similar to the one above.
> Are there any particular options that I should set when invoking
> gcc from the command line? Any help would be most appreciated.


 
 
 

1. GCC error using offsetof to do compile time error checking (help)

I'm trying to fix a problem right now that is easily solved by using
offsetof on class member variables.  G++, of course, chokes on it
because I am trying to use offsetof on a non-POD type (VC6 doesn't
complain since it is more lax).

The problem: At compile time, verify that a subset of the member
variables of a class that are linearly laid out in memory is a certain
size (really, verify that no one unwittingly added any data members to
the fixed size header).  Contrived example:

#define STATIC_CHECK(expr, msg) typedef char ERROR_##msg[1][(expr)]
#define STATIC_CHECK_FUNC(expr, msg) void ERROR_##msg() {
STATIC_CHECK(expr,msg); }
#define HEADERSIZECHECK(type,size) void HeaderSizeCheck() {
STATIC_CHECK(OffsetOf(type,type##_FIRST_TAGGED) == size,HeaderCheck);

class foo {
public:
        foo();
        ~foo();         // non-virtual class
protected:
        int     m_nMyInt;
        char*   m_pszMyCharString;

#define foo_FIRST_TAGGED        long m_nMyLong;
        long    m_nMyLong;

HEADERSIZECHECK(foo,8); // yes this may vary by compiler, but it is a
simple example

Under MSVC6, this gives us a compile time error if someone inserted a
new variable before m_nMyLong.  Under g++ (GCC 3.2.2) it gives an
error that offsetof is used on a non-POD type and we should use
pointers to members instead.

I am unclear exactly how I can use pointers to members to achieve
compile time size checking.  I could, of course, wrap all such headers
up in structs, verify their sizeof independently, and embed them as
the first member (or derive from them), but there is a fair amount of
legacy code that I do not want to port if I can avoid it.  If you have
an idea or another solution I would be most appreciative.

thanks,
michael


      [ about comp.lang.c++.moderated. First time posters: do this! ]

2. HELP !!!! CDRW-1622 IS BURNING ME!!!!

3. Compile errors when I include qedit.h

4. Exelan Export 2000 Terminal Server - INFO WANTED

5. error compiling the projects

6. forgotten bios password

7. GDI+ compile error in debug only

8. Diskette repair programs?

9. Compile errors at Windows 2000?

10. Compile error with _i.c file ????

11. Compile errors using VC++ 5.0 in CDO

12. Compile errors when using CDO in VC++ 5.0

13. compile-time errors when includeing winsock2 instead of winsock??