Reputation: 3637
I walked through this tutorial and tried to recreate the example I get this error:
Error 1 error LNK2019: unresolved external symbol __imp__GetXyz@0 referenced in function _main app.obj app
If I download the source from the website and run the project in visual studio it works, but If I even copy the code from the original project in my own visual studio solution it still doesn't work. I guess it must be some project settings, I don't know. What do do?
Upvotes: 0
Views: 403
Reputation: 14581
You need to add the XyzLibrary.lib to your Linker settings within project settings.
You can also do it directly in code by using #pragma comment(lib,"xyzlibrary.lib")
if you are using VisualStudio.
The reason why it works in the given sample without these 2 approaches is that in the solution file, the dependencies are set from XyzExe to XyzLib, and XyzProject has 'Link Library Dependencies' in Linker settings set to true. However, I am not too keen on this approach, as I don't like to store data important for building inside solution files (for larger projects, developer's solution files can differ from build system solution files)
Upvotes: 2
Reputation: 1670
Seems like you are missing some external library that needs to be linked in. Whatever provides the GetXyz function is missing.
Open the Solution that works, right click the project, Properties, Linker, Input, and check what their Additional Dependencies list up. You need to add the same to your own project.
Upvotes: 2