Causes of ILINK32 Error: Unresolved external '__fastcall System :: TObject :: NewInstance (System :: TMetaClass *)', referencing XXX.obj?

I get the following error from C ++ Builder 2009 linker

Unresolved external '__fastcall System::TObject::NewInstance(System::TMetaClass *)' referenced from XXX.obj? 

We have a set of files Delphi ( .pas ) and a set of C ++ Builder files ( .hpp and .obj ), which has been generated from these files .pas .

The set of files is copied to another computer. Both machines have the same version of C ++ Builder 2009 with the same updates (latest: 3 + 4).

When I create a blank VCL application in C ++ Builder on another computer, and includes a single file obj from this collection to the active project, I get the above error at link time.

Strange things about this error:

  • This error may not be reproduced on every machine or installation of C ++ Builder (I checked at least 5 of them).
  • If you delete the obj file and instead add the corresponding pas file to the project, the error will disappear.
  • But if you delete the pas file and include the obj file again, there will be no error.
  • None of the pas obj files are modified in the process. That is, if you delete this set of files from the computer and bring them again from the first machine (where they were created), you still will not have an error.
  • After you execute this sequence on one specific computer (include / exclude the pas file from the project) - you can no longer get this error on this machine, no matter how hard you try (move files between folders, play with settings , etc.). In fact, I no longer have machines where I can reproduce this error right now :(

I do not see how the situation "after" is different from the situation "before" (after / before turning pas file), so the error is only visible before and after.

The only mention of this error (or a very similar error) on the Internet is this . But there is no solution. There are no spaces or "spaces" ("") in the path.

Am I missing something? Right now it looks like a C ++ Builder bug for me.

PS We cannot use the solution "just include the pas file", since we need to deploy only the .hpp and .obj tags (no .pas ) on certain machines.

+4
source share
3 answers

Ok, I found the answer: the reason was in some wrong IDEs or project settings (I don’t know for sure).

I have several versions of C ++ Builders and Delphis. And for some reason, the C ++ Builder 2009 linker took the wrong obj files - those that should be used for another version (possibly 2007).

The reason for the error was that NewInstance was changed between versions 2007 and 2009 - see here: https://forums.codegear.com/thread.jspa?messageID=161105

0
source

I also got this error, but that was because I defined it:

 virtual void getMaxSafeSpace(); 

Instead

 virtual void getMaxSafeSpace()=0; 

in my abstract class.

+1
source

It looks like if you create a project from pas files, then somewhere is defined somewhere, and not in obj files, the function of the __fastcall System :: TObject :: NewInstance (System :: TMetaClass *) function and related binary code. Once a function is defined, the file XXX.obj finds it. Therefore, if you delete the current obj files and bring the obj files from another computer, the error is not displayed. This is just my thought. I do not know Delphi and have no idea about pas or C ++ Builder files.

Is your dll project or some external libraries created where the function System :: TObject :: NewInstance () is defined and connected with the binary?

0
source

All Articles