How do I do weak linking in Swift?

Seems like I’ve figured out what you can do I used NSClassFromString() to check if class is available on device, i.e. if NSClassFromString(“UIBlurEffect”) { let blur = UIBlurEffect(…) //… } else { //… } It’s needed to make UIKit.framework (or another corresponding framework) optional. If you create Swift-based application in XCode6-BetaX, all the frameworks wouldn’t … Read more

Linking GLEW with CMake

Typical CMake scripts like FindGLEW will define variables that specify the paths and files that your project needs. If the script can’t automatically identify the correct paths (usually because of nonstandard install location, which is fine), then it leaves these variables up to you to fill in. With command line CMake, you use the -D … Read more

dlopen from memory?

I needed a solution to this because I have a scriptable system that has no filesystem (using blobs from a database) and needs to load binary plugins to support some scripts. This is the solution I came up with which works on FreeBSD but may not be portable. void *dlblob(const void *blob, size_t len) { … Read more

MySQL Improperly Configured Reason: unsafe use of relative path

In OS X El Capitan (10.11), Apple added System Integrity Protection. This prevents programs in protected locations like /usr from calling a shared library that uses a relative reference to another shared library. In the case of _mysql.so, it contains a relative reference to the shared library libmysqlclient.18.dylib. In the future, the shared library _mysql.so … Read more

Why does the PLT exist in addition to the GOT, instead of just using the GOT?

The problem is that replacing call printf@PLT with call [printf@GOTPLT] requires that the compiler knows that the function printf exists in a shared library and not a static library (or even in just a plain object file). The linker can change call printf into call printf@PLT, jmp printf into jmp printf@PLT or even mov eax, … Read more