开发者

visual studio project dependency on another project LINKING failure

I have a solution with 2 projects cira_lib and md5_test. One project (cira_lib) is a central library that compiles to a DLL. The other project (md5_test) is an exe with a dependency on cira_lib. When I build md5_test it builds cira_lib first, so I know the project dependencies are being followed. However when VC++ comes to linking md5_test it comes back with a linker error:

1>  win32_cira.vcxproj -> C:\Users\ale-xps\Documents\Visual Studio 2010\Projects\win32_cira\Release\cira_lib.开发者_StackOverflow社区dll
2>------ Rebuild All started: Project: md5_test, Configuration: Release Win32 ------
2>  MD5Test.cpp
2>MD5Test.obj : error LNK2001: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl getTimeChkSum(void)" (?getTimeChkSum@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
2>C:\Users\ale-xps\Documents\Visual Studio 2010\Projects\win32_cira\Release\md5_test.exe : fatal error LNK1120: 1 unresolved externals

The "unresolved external symbol" that you see is a function in one of the class files "Utils.cpp" in the cira_lib project. So it seems to me that Visual Studio needs me me to perform some additional steps in order to see the Object files from cira_lib? I thought that by making a "dependency" all that would be automatically taken care for me?

I want md5_test to dynamically link against cira_lib... but I think Microsoft requires you to at least link against a stub .LIB file at link time even if you're performing dynamic linking, is that correct?

So do I need to add cira_lib's Release directory to md5_test's "Library Directories" and add cira_lib.lib to md5_test's "Linker Input" ?

The header file that I'm exporting is the following

 __declspec( dllexport ) string getTimeChkSum( );

and the implementation file is

__declspec(dllexport)
string  getTimeChkSum( )
{...}

Even after adding these directives and rebuilding all, my exe project still can't see these symbols..


Only symbols that you specifically mark for export are available to executables linking against your DLL.

You should check the MSDN documentation

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜