🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

How do I statically link FreeType in vs2017

Started by
2 comments, last by assboot 5 years, 6 months ago

I've downloaded the latest version of freetype, added freetype.lib and the include folder to my project and linked everything in project properties. Is there something I'm missing?

I'm getting 7 unresolved externals:


Error    LNK2019    unresolved external symbol __imp_FT_Stream_OpenLZW referenced in function PCF_Face_Init    Wizzy-core    C:\Users\CM\Documents\SourceTree\Wizzy\WizzyEngine\Wizzy-core\freetype.lib(pcf.obj)    1    
Error    LNK2019    unresolved external symbol __imp_FT_Bitmap_Convert referenced in function tt_face_load_sbit_image    Wizzy-core    C:\Users\CM\Documents\SourceTree\Wizzy\WizzyEngine\Wizzy-core\freetype.lib(sfnt.obj)    1    
Error    LNK2019    unresolved external symbol __imp_FT_Bitmap_Done referenced in function tt_face_load_sbit_image    Wizzy-core    C:\Users\CM\Documents\SourceTree\Wizzy\WizzyEngine\Wizzy-core\freetype.lib(sfnt.obj)    1    
Error    LNK2019    unresolved external symbol __imp_FT_Bitmap_Init referenced in function tt_face_load_sbit_image    Wizzy-core    C:\Users\CM\Documents\SourceTree\Wizzy\WizzyEngine\Wizzy-core\freetype.lib(sfnt.obj)    1    
Error    LNK2019    unresolved external symbol __imp_FT_Get_Font_Format referenced in function FT_Load_Glyph    Wizzy-core    C:\Users\CM\Documents\SourceTree\Wizzy\WizzyEngine\Wizzy-core\freetype.lib(ftbase.obj)    1    
Error    LNK2019    unresolved external symbol __imp_FT_Gzip_Uncompress referenced in function woff_open_font    Wizzy-core    C:\Users\CM\Documents\SourceTree\Wizzy\WizzyEngine\Wizzy-core\freetype.lib(sfnt.obj)    1    
Error    LNK2019    unresolved external symbol __imp_FT_Stream_OpenGzip referenced in function PCF_Face_Init    Wizzy-core    C:\Users\CM\Documents\SourceTree\Wizzy\WizzyEngine\Wizzy-core\freetype.lib(pcf.obj)    1    

EDIT:

It actually builds fine until I call FT_Init_FreeType()

This is all the code that's related to FreeType


/******fonthandler.h******/

#pragma once
#include <ft2build.h>
#include FT_FREETYPE_H

class FontHandler {
private:
	FT_Library m_lib;
private:
	FontHandler() {}
public:
	bool Init();
};
  
/******fonthandler.cpp******/
  
#include "fonthandler.h"
#include "..\..\..\debug\debugging.h"
  
bool FontHandler::Init() {
	auto _error = FT_Init_FreeType(&m_lib);
	if (_error) {
		log("Failed to initialize FreeType...");
		log("Error: '{0}'", _error);
	}

	return !_error;
}

 

Advertisement

I would guess that the lib was build with /MT and you're using /MD. The best thing to do would be to recompile the lib with /MD and /MDd but you can check the link below for a possible quick fix as well as additional info.

https://stackoverflow.com/questions/40230731/unresolved-externals-when-compiling-with-freetype/40231002

🙂🙂🙂🙂🙂<←The tone posse, ready for action.

4 minutes ago, fleabay said:

I would guess that the lib was build with /MT and you're using /MD. The best thing to do would be to recompile the lib with /MD and /MDd but you can check the link below for a possible quick fix as well as additional info.

https://stackoverflow.com/questions/40230731/unresolved-externals-when-compiling-with-freetype/40231002

Yup building the .lib file with /MD seems to fix my issues. Thanks a lot.

For future googlers: In the freetype solution you need to go to project properties -> C/C++ -> Code Generation and change "Runtime Library" from 'Multi-threaded (/MT)' to 'Multi-threaded DLL (/MD)' and just build it again and remember to grab the new freetype.lib file and replace the one that's linked to your project.

This topic is closed to new replies.

Advertisement