Force static linking of library linked to Xcode target?

前端 未结 5 677
别跟我提以往
别跟我提以往 2020-12-09 19:06

My Xcode target links against hdf5 library (using the Link Binary with Libraries build phase). libhdf5 is installed using MacPorts, thus /opt/local/lib contains both the dyn

5条回答
  •  遥遥无期
    2020-12-09 19:54

    Had this exact same problem and despite this being an old post, I thought I'd share what I had to do to make this work.

    Usually you do just provide the switch '-static' to the linker however, with Xcode this causes all libs including the crt to be linked statically. I got the error:

    can't locate file for: -lcrt0.o
    

    When I tried this.

    The thing which worked for me was to replace:

    -lmylib
    

    with

    /path/to/libmylib.a

    Note: the -l is dropped.

提交回复
热议问题