[ODE] operator new undefined link cygwin gcc

Martin Magnusson mama7121 at student.uu.se
Wed Nov 27 04:28:01 2002


OK, thanks for your help everybody. After creating lib/ manually both 
configurator and ode-lib compile properly (although with a couple of 
warnings about multi line strings and one or two unused variables), but 
when it comes to ode-test and drawstuff-test I get undefined references 
to new[] (when I compile with gcc in Cygwin/Windows).

lib/libdrawstuff.a(drawstuff.o)(.text+0x393):drawstuff.cpp: undefined 
reference to `operator new[](unsigned)'

Anselm Hook wrote:
> For the default compiler in makefile.cygwin to be g++ you have to wrap
> extern "C" { } around your includes in the configurator source.  Also just
> remove exit() - it isn't important.  The configurator could be generalized
> to support this overall but I guess it's pretty obvious.

I wrapped the entire configurator.c in

#ifdef __cplusplus
extern "C" {
#endif
       ...
#ifdef __cplusplus
}
#endif
#endif

and commented out the exit() line, but that didn't help (g++ complained 
about the system() calls in configurator.c and lots of other stuff as 
well). I installed Cygwin a couple of days ago, so it should be recent 
enough. My ./include/ode/config.h looks like this - if that matters:

== config.h: =========================================================
/* per-machine configuration. this file is automatically generated. */

#ifndef _ODE_CONFIG_H_
#define _ODE_CONFIG_H_

/* shared lib definitions */
#ifndef SHAREDLIBIMPORT
#define SHAREDLIBIMPORT
#endif
#ifndef SHAREDLIBEXPORT
#define SHAREDLIBEXPORT
#endif

/* standard system headers */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdarg.h>
#include <malloc.h>
#include <alloca.h>

#ifdef __cplusplus
extern "C" {
#endif

/* is this a pentium on a gcc-based platform? */
#define PENTIUM 1

/* integer types (we assume int >= 32 bits) */
typedef char int8;
typedef unsigned char uint8;
typedef int int32;
typedef unsigned int uint32;

/* an integer type that we can safely cast a pointer to and
  * from without loss of bits.
  */
typedef unsigned int intP;

/* select the base floating point type */
#define dDOUBLE 1

/* the floating point infinity */
#define DINFINITY_DECL SHAREDLIBEXPORT union dInfBytes dInfinityValue = 
{{0,0,0,0,0,0,0xf0,0x7f}};
#if defined SHARED_CONFIG_H_INCLUDED_FROM_DEFINING_FILE
   #define GLOBAL_SHAREDLIB_SPEC SHAREDLIBEXPORT
#else
   #define GLOBAL_SHAREDLIB_SPEC SHAREDLIBIMPORT
#endif
union dInfBytes { unsigned char c[8]; double d; };
extern GLOBAL_SHAREDLIB_SPEC union dInfBytes dInfinityValue;
#define dInfinity (dInfinityValue.d)
#undef GLOBAL_SHAREDLIB_SPEC

/* ODE feature configuration */

#ifdef __cplusplus
}
#endif
#endif

======================================================================

/ Martin Magnusson