Click here to Skip to main content
15,851,387 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi
Just starting out with VS2008 C++

I'm trying to compile code from an old C++ project into a Windows Forms project. When I compile I'm getting LNK2028 errors for several of the objects of a Class. The Class is declared in a CLASSES.h file but does not seem to be recognized in the SIGNAL.cpp file. Here is the error which is typical of several:

Error	1	error LNK2028: unresolved token (0A000009) "void * __clrcall memrealloc(void *,unsigned int)" (?memrealloc@@$$FYMPAXPAXI@Z) referenced in function "public: int __clrcall Signal::undo_difference(class Signal *)" (?undo_difference@Signal@@$$FQAMHPAV1@@Z)	SIGNAL.obj


Here is the "token" (I think!) declaration in the header file FUNCDEFS.h:
extern void *memrealloc ( void *ptr , unsigned int size ) ;


Code within EXTERN.h is thus:
extern TDecoratedMDIFrame *frame ;
extern npredictMDIClient  *mdiClient ;


Here is the Class declaration in the header file CLASSES.h:

class Signal {

public:
   Signal ( char *signame , int length , double *signal ) ;
   ~Signal () ;

   enum SignalType type ;  // Optimizes display
   int n ;             // Length of signal
   char *name ;        // Its name
   double *sig ;       // It is here
   int centered ;      // Has it been centered?
   double cent ;       // Its center if so
   int detrended ;     // Has it been detrended?
   double slope ;      // Slope if so
   double pivot ;      // And pivot point
   int offsetted ;     // Has it been offset?
   double offst ;      // Offset if so
   int scaled ;        // Has it been scaled?
   double scal ;       // Its scale if so
   int standardized ;  // Has it been standardized?
   double mean ;       // Its mean if so
   double std ;        // And its standard deviation
   int differenced ;   // Has it been differenced?  (Degree if so)
   double leads[3] ;   // First points before differencing
   int seasonal ;      // Has it been seasonally differenced? (Period if so)
   double *sleads ;    // First period points if so
   int source_n ;      // If CORRELATION or SPECTRUM, length of defining signal
   int known_n ;       // Normally n, else set by NET_PRED.CPP, ARMAPRED.CPP
   int npred ;         // Number of future prediction confidence intervals
   double *intervals ; // This is them (2 * npred long), alloced in NP_CONF.CPP
   int mult_conf ;     // Normally 0, 1 if 'intervals' are multiplicative

   void replace ( int n , int n_protect , double *x ) ;
   void center () ;
   int median_center () ;
   void undo_center ( Signal *per ) ;
   void detrend () ;
   void undo_detrend ( Signal *per ) ;
   void offset ( double val ) ;
   void undo_offset ( Signal *per ) ;
   void scale ( double val ) ;
   void undo_scale ( Signal *per ) ;
   void standardize () ;
   void undo_standardize ( Signal *per ) ;
   void difference ( int degree ) ;
   int undo_difference ( Signal *per ) ;
   int seasonal_diff ( int period ) ;
   int undo_seasonal_diff ( Signal *per ) ;
   void integrate ( int period ) ;
   void siglog () ;
   void sigexp () ;
}


Here is the definition in the SIGNAL.cpp file:

int Signal::undo_difference ( Signal *sigptr )
{
   int i, pass, passes ;
   double temp, sum, *dptr ;
   remove_display ( this ) ; // Windows must remove MDI child if displayed
   if (sigptr != NULL) {
      if (sigptr->differenced)
         passes = sigptr->differenced ;
      else
         return 0 ;
      }
   else
      passes = differenced ;
   MEMTEXT ( "SIGNAL: undo_difference" ) ;
   dptr = (double *) REALLOC ( sig , (n+passes) * sizeof(double) ) ;
   if (dptr == NULL)
      return 1 ;
   sig = dptr ;
   
   for (pass=0 ; pass<passes ; pass++) {
      if (sigptr != NULL)
         sum = sigptr->leads[passes-pass-1] ;
      else
         sum = leads[passes-pass-1] ;
      for (i=0 ; i<n ; i++) {
         temp = sig[i] ;
         sig[i] = sum ;
         sum += temp ;
         }
      sig[n++] = sum ;
      }
   type = DataSignal ;
   known_n += passes ;
   return 0 ;
};


Have had a good look around on Google etc but stuck here. suspect that there might be a declaration issue with C as a .C file supplied as well but inclusion makes no difference.

I'd appreciate some direction.

Thanks
Posted
Comments
RedDk 21-Nov-13 13:22pm    
Whenever I get a linker error I find the "mangled" name (usually in the trailing message) and using THAT as my search string, go to windows search paste it in and limit the filetype to ".lib". The scope of the search should be limited to the drive(s) where any SDK or VS install files or subsidiary MS stuff are located.

Also of help might be the enabling of /VERBOSE mode in the Additional parameters of the command line under Properties.


[edit]

Of real note is the very bad behavior of some Winndows OS search "engine" and the pseudoability it has in making the ".lib" species invisible to such a fundamental sleuth. Just be forewarned. I have found using the SQL Server Managment Studio "Find-In-Files" facility infintely more stalwart in matching the symbol to known link libraries (here, one can target anywhere and also make sure the extention ".lib" isn't hidden in any covert manner).

[end edit]

1 solution

Is, by chance, your project 'managed C++'? This Stack Overflow question might help: "Managed C++ unresolved token"[^].
 
Share this answer
 
v2
Comments
RedDk 21-Nov-13 15:18pm    
I saw that coming ... (the mangled stuff isn't really mangled but "memrealloc")
PaulS_UK 22-Nov-13 8:39am    
Thanks RedDK
I'm beginning to think this is a CLR/Native code issue.
I appreciate your input
RedDk 22-Nov-13 12:52pm    
See my [edit]. And 4 stars for CP. My money's on mc++ ...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900