1

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?

asked Jan 5, 2014 at 23:32
1
  • I may have resolved SOME of these thanks to this thread. I added the #define MYCLASS_API __declspec(dllexport) to ftgl.h. Now I have a bunch of LIBCD.lib LNK2005 errors. If I compile it as /MD then I get conflicts with MSVCRT.lib. If I change /MD then LIBCD.lib conflicts with LIBCMTD.lib. ARGH! Commented Jan 6, 2014 at 1:10

1 Answer 1

1

Make sure you lib are generated with same runtime library option under code generation

  • /MD and /MDd is for multi-threaded (debug)
  • /MT and /MTd is for multi-threaded DLL (debug)

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.

answered Jan 6, 2014 at 6:45
Sign up to request clarification or add additional context in comments.

1 Comment

Bingo, that did it. I'm pretty sure the glui lib was doing that. I recompiled it from source paying close attention to that and now it's all building. Thanks!

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.