Alexander I. 0 Posted June 27, 2022 (edited) Here is the code: #include <REST.Json.hpp> ... TJson* formatter=new TJson(); Compilation successful, but linker says following: [ilink32 Error] Error: Unresolved external 'Rest::Json::TJson::' referenced from C:\USERS\ISKOR\DESKTOP\TJSONTEST\WIN32\DEBUG\UNIT1.OBJ How can that be? I use C++ Builder 10.1 Community Edition. Edited June 28, 2022 by Alexander I. Share this post Link to post
Remy Lebeau 1421 Posted June 27, 2022 55 minutes ago, Alexander I. said: Compilation successful, but linker says following: [ilink32 Error] Error: Unresolved external 'Rest::Json::TJson::' referenced from C:\USERS\ISKOR\DESKTOP\TJSONTEST\WIN32\DEBUG\UNIT1.OBJ How can that be? You are not linking to the BPL library that implements TJson. Try adding a reference to the RESTComponents.bpi file to your project. Share this post Link to post
Alexander I. 0 Posted June 28, 2022 9 hours ago, Remy Lebeau said: You are not linking to the BPL library that implements TJson. Try adding a reference to the RESTComponents.bpi file to your project. That worked! Thank you! But why it does not work by default, that is the question. Share this post Link to post
Remy Lebeau 1421 Posted June 28, 2022 (edited) 13 hours ago, Alexander I. said: But why it does not work by default, that is the question. Why would it? If all you did was add an #include statement to your code, the IDE is not smart enough to know which library to automatically add to the project to make the code in that header file link correctly. It doesn't even know what code is in that header file until the compiler is invoked, and by then it is too late. The IDE can do automatic linkage of libraries only for components that are dropped on a Form/Frame/DataModule in the Designer. Did you do that for the REST components? I'm guessing no. But this issue is not specific to just REST, it applies to any library. For non-designtime code, you are responsible for setting up your project with any necessary library references as needed. Edited June 28, 2022 by Remy Lebeau Share this post Link to post
Alexander I. 0 Posted June 28, 2022 (edited) Thank you for the explanation! Edited June 28, 2022 by Alexander I. Share this post Link to post