Jump to content
Sign in to follow this  
vfbb

[C++Builder] Static link SDK objects on iOS

Recommended Posts

We started porting the Skia4Delphi library to C++Builder and we came across a problem in the static linking of objects, specifically linking the file “/usr/lib/clang/lib/darwin/libclang_rt.ios.a” which is in the SDK path (ex: “C:\Users\<username>\Documents\Embarcadero\Studio\SDKs\iPhoneOS15.2.sdk\usr\lib\clang\lib\darwin\libclang_rt.ios.a”)

 

In Delphi, this linking is very simple to do. We can simply declare a fake method and add the external '/<sdk_sub_path>/<filename>.a', which is exactly what we do in our Delphi implementation:

procedure libcompiler_rt; external '/usr/lib/clang/lib/darwin/libclang_rt.ios.a';

 

In C++Builder however, we didn't find anything similar. So far we've only been able to force this link in two different (but very rudimentary) ways:

 

Method 1 - Configuring project linking:

  1. Adding to the project library path “$(BDSPLATFORMSDKSDIR)\<DefaultPlatformSDK>\usr\lib\clang\lib\darwin\”
    Note: This is necessary because although some SDK paths are automatically passed to the linker, this is not.
  2. Adding the command -lclang_rt.ios to the project link

The problem with this method is that apparently there is no environment variable for the <DefaultPlatformSDK>, and adding only relative paths, in this case “\usr\lib\clang\lib\darwin\”, doesn't work. We also tried “$(SDKROOT)\usr\lib\clang\lib\darwin\” but to no avail.

 

Method 2 – Adding objects to the project

  1. Directly add the file “libclang_rt.ios.a” to the project.

It also works, but this is also a bad option.

 

Questions

  1. Is there any other way to force link an SDK object in C++Builder?
    It would be nice to have a simple solution that requires no configuration:
    #pragma link "/usr/lib/clang/lib/darwin/libclang_rt.ios.a" // But this don't work
  2. Would there be any variables we could use to represent the path of the SDK being used? (Ex: “$(SDKROOT)\usr\lib\clang\lib\darwin\”)

 

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×