I'm trying to build a project in Windows using VS2012 (2010 also available) that includes FTGL, which depends on FreeType.
When I try to build my project, I see a large number of the following LNK2005 errors:
Error 204 error LNK2005: "private: __thiscall FTFont::FTFont(class FTFontImpl *)" (??0FTFont@@AAE@PAVFTFontImpl@@@Z) already defined in FTFont.obj buildDir\ftgl.lib(ftgl.dll)
Error 238 error LNK2005: "private: __thiscall FTGlyph::FTGlyph(class FTGlyphImpl *)" (??0FTGlyph@@AAE@PAVFTGlyphImpl@@@Z) already defined in FTGlyph.obj buildDir\ftgl.lib(ftgl.dll)
Error 249 error LNK2005: "private: __thiscall FTLayout::FTLayout(class FTLayoutImpl *)" (??0FTLayout@@AAE@PAVFTLayoutImpl@@@Z) already defined in FTLayout.obj buildDir\ftgl.lib(ftgl.dll)
Error 213 error LNK2005: "protected: __thiscall FTFont::FTFont(char const *)" (??0FTFont@@IAE@PBD@Z) already defined in FTFont.obj buildDir\ftgl.lib(ftgl.dll)
I built the FTGL lib using their provided msvc->vc8 solution (upgraded to vs2010). This created the following files for both debug and release:
ftgl_static.lib
ftgl.lib
ftgl.dll
Placed the libs into my vc lib directory and added them to the Project Settings -> Linker -> Additional Dependencies so that I have the following line:
ftgl.lib
glui32.lib
glut32.lib
glu32.lib
opengl32.lib
freetype.lib
%(AdditionalDependencies)
Don't think it matters since I don't have any unresolved dependencies, but I have the following in my project -> C/C++ -> Additional Include Dirs
$(SolutionDir)..\..\code\lib\freetype2\include\freetype2\config
$(SolutionDir)..\..\code\lib\freetype2\include\freetype2
$(SolutionDir)..\..\code\source
$(SolutionDir)
$(SolutionDir)..\..\code\lib\FTLayout
$(SolutionDir)..\..\code\lib\FTGlyph
$(SolutionDir)..\..\code\lib\FTGL
$(SolutionDir)..\..\code\lib\FTFont
$(SolutionDir)..\..\code\lib
$(SolutionDir)..\..\code\headers
%(AdditionalIncludeDirectories)
Tried playing with ignoring dependencies but didn't get anywhere with that. I have also tried a variety of solutions here and on other sites, including:
Prior to this problem I was seeing the LNK2019 errors described on this gamedev topic . That was solved by adding the lib to the additional dependencies in the project, but introduced the LNK2005 errors.
If it helps, the project builds in OS X; however, the libraries somewhat differ for Windows (dylib in OS X vs lib/dll in Win).
Can anyone help me to resolve these errors?
Make sure you lib are generated with same runtime library
option under code generation
All projects that have dependency with each other should has same option.
Also, you might have LIBCMT confliction if import static lib that is built with /MD and /MDd. Add LIBCMT into ignore libraries
for linker can avoid this problem.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.