SDL2_ttf issues: Entry Point not found. Visual Studio

Started by
5 comments, last by ChainedHollow 10 years, 5 months ago

I have been working on a game using SDL but recently decided to switch to SDL2. I've been going over the examples for SDL2 on LazyFoo but there isn't really any documentation, just code. I got to the ttf examples yesterday. The first basic one worked yesterday. Today, I got to another example that uses ttf and it's giving me an error. I tried the first one again and I'm getting the same error. I have no idea what is going on. I have searched on google to try to fix it but I havn't found anything helpful. The error is:

Entry Point not found
The procedure entry point InterLockedCompareExchange@12 could not be located in the dynamic link library libfreetype-6.dll
Advertisement

The procedure entry point InterLockedCompareExchange@12 could not be located in the dynamic link library libfreetype-6.dll

The error message is a linker error. The linker combines your code with the code from the operating system, from the graphics libraries, from the audio libraries, and from everywhere else, and tells each of the parts about each other. It links the different parts of code together.

In this case the linker is looking for a function called InterLockedCompareExchange, and it is searching for it in a library called libfreetype-6

The function InterLockedCompareExchange is part of the Windows kernel. Your linker should be looking in kernel32, not libfreetype-6.

This is a linker problem, and a few moments in Google shows that MinGW is frequently misconfigured to not search the system libraries. Are you using the MinGW compiler?

Edit:

The function is usually implemented as a compiler intrinsic. It is very suspicious that your program would attempt to use the function version rather than the intrinsic version.

Longer description because this is For Beginners forum: A compiler intrinsic is when you write a function call but the compiler replaces it with in-place CPU instructions. One of many examples of intrinsic functions are math functions like sin() and cos(). The compiler could call the function for that, but calling a function requires setting a bunch of boilerplate code, setting up a stack frame, and then jumping to a new location, and cleaning up when it is done. When the intrinsic version of the function is used the compiler doesn't actually call a function. Instead it calls the CPU instruction directly which saves a lot of time and complexity. Since the compiler usually doesn't call the actual function the sin() and cos() functions are not really needed except in rare situations, and if you see them being linked it means something is probably wrong with the code.

The same is true with this intrinsic; the compiler probably should not be generating a function call for InterlockedCompareExchange. It is an atomic instruction on the platform and if the compiler isn't using the intrinsic then something is probably wrong with your settings.

I saw what you were saying about MinGW on google, but Im not using it. Im using Visual Studio 2010. I do have the libfreetype.dll file in the project folder. Its the one that came with SDL2. I made a new project so that I could go through linking everything again, and its doing the same thing. I need to use text in my game, so I'm going to have to fix this eventually.

In that case it becomes a matter of looking up the setting in the maze of property pages that VS2010 uses.

Open up the project settings, open up "Configuration Properties > C/C++ > Command Line" and copy/paste the block of text. Then open up "Configuration Properties > Linker > Command Line" and copy/paste the block of text that shows up there.

Those are the exact command lines being used, and from there we can look at it to see what setting is incorrect.

C/C++:

/ZI /nologo /W3 /WX- /Od /Oy- /D "_MBCS" /Gm /EHsc /RTC1 /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fp"Debug\SDL2Tutorials.pch" /Fa"Debug\" /Fo"Debug\" /Fd"Debug\vc100.pdb" /Gd /analyze- /errorReport:queue

Linker:

/OUT:"c:\users\brandon\documents\visual studio 2010\Projects\SDL2Tutorials\Debug\SDL2Tutorials.exe" /NOLOGO "SDL2.lib" "SDL2_image.lib" "SDL2_ttf.lib" "SDL2main.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /MANIFEST /ManifestFile:"Debug\SDL2Tutorials.exe.intermediate.manifest" /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"c:\users\brandon\documents\visual studio 2010\Projects\SDL2Tutorials\Debug\SDL2Tutorials.pdb" /SUBSYSTEM:CONSOLE /PGD:"c:\users\brandon\documents\visual studio 2010\Projects\SDL2Tutorials\Debug\SDL2Tutorials.pgd" /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:QUEUE

It is suspicious that your SDL libraries are at the front instead of the back. The first should be kernel32.lib, user32.lib, etc., and the SDL libraries should be at the end. Find out where you listed the libraries in the maze of dialog boxes as there are several "additional libraries" fields that you might have put it in. Wherever you put it, make sure they appear at the end of the list on the linker command line.

If reordering those libraries doesn't help, my next suspicion is that you are using a pre-built library that was built with the MinGW bug. I recommend for all packages you should download the source and recompile it on your machine so the compiler settings will match. It is always frustrating to hunt down a bug that exists because of an incompatibility with a pre-built library. Sometimes there are subtle incompatibilities in reserved space or in reference implementations that are very time consuming to hunt down. That would be my second step if the error persisted. When in doubt about a library, rebuild it from the source.

Also I can see that libfreetype-6 is missing from your list, but your application is requiring it. That is another probable sign that your SDL library is pulling in unexpected dependencies. Building from the source can help you identify that as a problem.

Well the issue is fixed! I just came back to tell you thank you so much for all the help. I did have trouble compiling the .dll myself, so that is not what fixed it for me. I think what finally fixed it was just verifying that both libfreetype-6.dll and zlib.dll in my project folder. They both were, but I copied over them anyway and it works now.

This topic is closed to new replies.

Advertisement