pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: max.fomitchev@gmail.com
To: pgsql-bugs@postgresql.org
Subject: BUG #14215: External C function link failed on Mac OSX
Date: Sun, 26 Jun 2016 09:27:21 +0000
Message-ID: <20160626092721.17236.73734@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

The following bug has been logged on the website:

Bug reference:      14215
Logged by:          Max Fomitchev
Email address:      max.fomitchev@gmail.com
PostgreSQL version: 9.5.3
Operating system:   OSX
Description:        

Example code main.cpp:

extern "C" {
    #include <postgres.h>
    #include <fmgr.h>
    #include <utils/array.h>
    #include <utils/lsyscache.h>
    #include <catalog/pg_type.h>

    #ifdef PG_MODULE_MAGIC
        PG_MODULE_MAGIC;
    #endif

    PG_FUNCTION_INFO_V1(psql_nearest);
    Datum psql_nearest(PG_FUNCTION_ARGS) {
        if(PG_ARGISNULL(0) || PG_ARGISNULL(1)) {
            elog(ERROR, "DOC2VEC: NULL INPUT DATA");
            PG_RETURN_NULL();
        }

        ArrayType *_docVector = PG_GETARG_ARRAYTYPE_P(0);
        Oid elTypeVals = ARR_ELEMTYPE(_docVector);
        if (elTypeVals != FLOAT4OID) {
            elog(ERROR, "DOC2VEC: INVALID INPUT DATA TYPE");
            PG_RETURN_NULL();
        }

        int16 typeLenVals = 0;
        bool typeByValVals = false;
        char typeAlignVals = char(0);
        get_typlenbyvalalign(elTypeVals, &typeLenVals, &typeByValVals,
&typeAlignVals);

        Datum *inputVals;
        bool *nullVals;
        int nVals;
        deconstruct_array(_docVector, elTypeVals, typeLenVals,
typeByValVals, typeAlignVals, &inputVals, &nullVals, &nVals);

        pfree(inputVals);
        pfree(nullVals);

        PG_RETURN_NULL();
    }
}

Compiling:
c++ -I/usr/local/Cellar/postgresql/9.5.3/include/server -fpic -c
./main.cpp

Linking:
c++ -shared -o ttt.dylib main.o 
Undefined symbols for architecture x86_64:
  "_deconstruct_array", referenced from:
      _psql_nearest in main.o
  "_elog_finish", referenced from:
      _psql_nearest in main.o
  "_elog_start", referenced from:
      _psql_nearest in main.o
  "_get_typlenbyvalalign", referenced from:
      _psql_nearest in main.o
  "_pfree", referenced from:
      _psql_nearest in main.o
  "_pg_detoast_datum", referenced from:
      _psql_nearest in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see
invocation)



-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs


view thread (2+ messages)  latest in thread

Message-ID: <20160626092721.17236.73734@wrigleys.postgresql.org>
Permalink:  ../20160626092721.17236.73734@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/20160626092721.17236.73734@wrigleys.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: max.fomitchev@gmail.com
  Subject: Re: BUG #14215: External C function link failed on Mac OSX
  In-Reply-To: <20160626092721.17236.73734@wrigleys.postgresql.org>
  References: <20160626092721.17236.73734@wrigleys.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox