I am working on merging some new trunk code into a feature branch on one of our large legacy projects. This project is written in C++ using C++Builder 5.0. We also use TwineCompile 3 to speed up our build times.
After the merge, I now sometimes get the following error when compiling:
[ilink32 Error] Unresolved external '__fastcall TPrintTickܩ ::Add(int, int, int, bool, TTicketType, int, bool, bool, bool)' referenced from C:\PROJECTS\PRODUCT\V3.12.X\SOURCE\OBJ\PROCESSOR.OBJ
This error only shows up when doing a release build with compiler optimizations turned off (which is how we typically release our code). If I re-enable compiler optimizations, or if I do a debug build, the error does not appear. Additionally, if I disable TwineCompile, the problem disappears.
Running TDump on the 'processor.obj' object file shows that it has a reference to an external function TPrintTickܩ ::Add. This function should actually be TPrintTicketQueue::Add. File processor.cpp contains the following code in one of the functions:
PrintTicketQueue.Add(/*parameters here*/);
For reference, file printTicketQueue.h (which is included by processor.cpp) has the following code:
class TPrintTicketQueue
{
public:
/* Some more code here */
void __fastcall Add(int jobID, int ticketID, int numID, bool labelPrint, TTicketType type, int count = 1, bool remote = false, bool print = true, bool printLabelOnly = false);
};
extern TPrintTicketQueue PrintTicketQueue;
To further confuse matters, if I attempt to create a local pointer to a TPrintTicketObject in any function in processor.cpp, I get the following error:
[C++ Error] processor.cpp(291, 18): E2451 Undefined symbol 'TPrintTicketQueue'
Despite knowing that printTicketQueue.h has been included in processor.cpp, and thus TPrintTicketQueue should be defined.
I'm at a loss to explain what is happening here. Has anyone encountered a similar problem with C++Builder 5.0 or TwineCompile? Is there any way to solve or work around this problem?