Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiling FreeType to DLL (as opposed to static library)

I want to use FreeType in a c# project. I found this binding, but I still need a freetype.dll. I usually use a static library in my c++ projects, so I never compiled one. Opening the freetype-solution (VS2010) I noticed that there is no configuration for a dynamic library - just static ones. I tried to make my own configuration and got it to generate a freetype.dll. If I use it with the c#-binding I get an exception, that the FT_Init_FreeType-entry point was not found. Any idea how I must adjust the freetype-project in order to export those functions?

like image 296
B_old Avatar asked Jun 01 '11 20:06

B_old


People also ask

Can a static library use a DLL?

All you need to do in order to use such library (either in .exe or . dll ) is to include proper headers and link them - with Visual Studio it's pretty easy. First of all, you need to know 1) where your static libraries are placed and 2) their exact names. Go to project properties and then General .

Can a exe link to DLL and static library at the same time?

Yes, the Core and Utils code will be duplicated. Instead of building them as static libs you can build them as dlls and use anywhere.

How do I create a static library in Visual Studio?

To create a static library project in Visual StudioOn the menu bar, choose File > New > Project to open the Create a New Project dialog. At the top of the dialog, set Language to C++, set Platform to Windows, and set Project type to Library.


1 Answers

If you're ok with an old version (march 2008), you can go to FreeType for Windows page, download the latest Binaries package, open the .ZIP, and extract FreeType6.dll from the bin directory. Just rename it appropriately.

If you need a more recent version, here is how you can compile the latest:

  • download the latest source (2.4.6 as of today) from http://sourceforge.net/projects/freetype/files/freetype2/

  • open Visual Studio 2010, and load freetype.sln from the builds\win32\vc2010 directory.

  • open the project config, and in the General tab, change Configuration Type to Dynamic Library (.dll)

  • open the ftoption.h file, and add these lines (near the "DLL export compilation" remarks section for example):

    #define FT_EXPORT(x)  __declspec(dllexport) x
    #define FT_BASE(x)    __declspec(dllexport) x
    
  • change the project compilation configuration to "Release".

  • compile the project. You should now have a freetype246.dll in the objs\win32\vc2010 directory.

like image 152
Simon Mourier Avatar answered Nov 16 '22 00:11

Simon Mourier