Jump to content
  • Advertisement
Sign in to follow this  
greenvertex

Linkage Woes

This topic is 2119 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So the situation is that I have a library for a model format I'm working on and am having a problem importing extensions to it into another project. I export a set of three functions as follows:


namespace bof {
namespace dx {
__declspec(dllexport) D3D11_INPUT_ELEMENT_DESC* get_input_desc(
const bof::Model& model,
const std::string& name,
size_t* stride = 0);
};
};


And attempt to use them in the target project:


descriptors = bof::dx::get_input_desc(model, "Cube", &vertex_stride);


However I get the following linker errors associated with that particular call:


2>BOFCube.obj : error LNK2019: unresolved external symbol "struct D3D11_INPUT_ELEMENT_DESC * __cdecl bof::dx::get_input_desc(class bof::Model const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned int *)" (?get_input_desc@dx@bof@@YAPAUD3D11_INPUT_ELEMENT_DESC@@ABVModel@2@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PAI@Z) referenced in function "public: __thiscall BOFCube::BOFCube(struct ID3D11Device * const,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0BOFCube@@QAE@QAUID3D11Device@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
[/quote]

There are six of them so I only picked one for brevity (three referencing calls from the 'model' type's definition file and three from 'bof::dx'). This is all using Visual Studio 2012 RC and I'm wondering if there's a project setting I've missed? I have yet a third project that makes reference to this library successfully to build a little command line tool for writing these models. As far as I can tell the two projects (the one successfully building with the library and the one that's not) are set up the same way.

Anyone have any ideas? Edited by greenvertex

Share this post


Link to post
Share on other sites
Advertisement
Are you including your library in the linker settings?
Despite it being dllexport, you still need to link library, I think it tells which .dll contains function and it's address.

Share this post


Link to post
Share on other sites
That was it, simply didn't add the lib for the linker...

I guess the followup to that would be: is it better practice to #pragma comment(lib, "my.lib") or to add the lib to the linker->input->addition dependencies of the project?

Also, why would one project build without it the lib included and another complain?

Share this post


Link to post
Share on other sites
1. There's no difference. pragma and project properties work the same way.

2. Are you sure it's not linking? Check build/link log, it lists all libraries which were used, it's probably there.

Share this post


Link to post
Share on other sites
Yea I'm positive. Additional dependencies are set to the defaults on the project that originally compiled. The only dependency is to the header for the .dll. It's also a project with one source file in it so there are no pragma's seeping in. It's not a huge issue but it just seems strange no?

Share this post


Link to post
Share on other sites
If you're not actually using functions it won't need to link anything, therefore no link errors.

Also if you setup dependencies under "Common Properties" it'll link automatically.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!