Skip to content

OSX: Undefined symbols for architecture x86_64 __d_osx_image_init2 #101

@thelastmammoth

Description

@thelastmammoth

I followed the instructions given on https://github.com/ldc-developers/ldc/wiki/Installation with a few modifications to make the build successful on OSX (see below for required modifications):

when compiling + linking a hello world program main.d I get the following link error:

ldc2 main.d
Undefined symbols for architecture x86_64:
"__d_osx_image_init2", referenced from:
_main in libphobos-ldc.a(dmain2.o)
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
Error: linking failed:
status: 1

************************************ installation *************************
sudo port install libconfig-hr (install libconfig)
then in ccmake, change llvm path to /opt/local/bin/llvm-config-mp-3.0 (to make it work with the macports version)

ccmake complains (" libconfig++ not found") ("consider manually setting the LIBCONFIG_CXXFLAGS and LIBCONFIG_LDFLAGS"). Unfortunately the instructions given here (http://www.dsource.org/projects/ldc/wiki/OSXBuildInstructions : you also need to set LIBCONFIG_LDFLAGS="-L/usr/local/lib -lconfig++" in advanced options of ccmake (while configuring, press 't', scroll down) didn't work as LIBCONFIG_LDFLAGS doesn't appear in advanced options.

but the following manual way works:
cmake .. -DLIBCONFIG_LDFLAGS="-L/opt/local/lib/ -lconfig++" -DLIBCONFIG_CXXFLAGS=-I/opt/local/include/
followed by make && make install

that compiles fine, ldc2 is created

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions