Search code examples
c++buildervclunresolved-external

Unresolved External After Project Migration


I'm using C++Builder 10.4.1. I've migrated a simple project containing 3 forms. The main form contains a TDriveComboBox. When I try to compile I get these errors:

[ilink32 Error] Error: Unresolved external 'Vcl::Filectrl::TDriveComboBox::' referenced from (then it lists the path to the main form's OBJ file)
[ilink32 Error] Error: Unresolved external '__fastcall Vcl::Filectrl::TDriveComboBox::GetDrive()' referenced from (then it lists the path to the main form's OBJ file)

I've even tried to delete the TDriveComboBox and replace it, but that doesn't help. What's the problem and how can I fix it?


Solution

  • I would:

    1. delete all temp files (obj,exe,tds,...)
    2. add new temp TDriveComboBox on form with this problem
    3. compile and run.

    If that does not help then sometimes manually #include VCL header containing the component into form *.h file helps reset the compiler/linker so search the VCL inc folder for TDriveComboBox In mine system its in here:

    c:\Program Files (x86)\Borland\BDS\4.0\include\vcl\FileCtrl.hpp
    

    So add something like:

    #include <FileCtrl.hpp>
    

    or

    #include <vcl\\FileCtrl.hpp>
    

    into your form *.h file... but even this sometimes fail. In my experience the problem lies in the project file (*.bds, *.bdsproj, ... or whatever extention the newer versions got) so its a good idea to backup it while the compiler works as should... As it sometimes corrupt it self especially for big projects.

    Sometimes also helps if you move:

    #pragma hdrstop
    

    line to different locations (few lines down or up). If you're lucky it can also reset the compiler/linker after which you can move it to original location. However this helps only occasionally (like 1:20). And you also need to try few locations

    In case nothing works just create new empty project and copy the forms and stuff into it and add it to project... Each form has 3 files (*.h,*.cpp,*.dfm) and do not forget to add to your project whatever you need (DLL *.lib,...) if its not linked directly with #pragma link for all the 3th party custom stuff your app uses

    Once (also after migration from BCB5 to BDS2006) even this did not help for one of mine projects. I was forced to create also the forms (with all the components but without functionality just place them on forms) and then copy the stuff from old App... However if you got too many components it will be a pain in the ...