Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

PGSQL_QUERY: Error loading sharable executable #2

Open
knutago opened this issue Mar 22, 2016 · 4 comments
Open

PGSQL_QUERY: Error loading sharable executable #2

knutago opened this issue Mar 22, 2016 · 4 comments

Comments

@knutago
Copy link

knutago commented Mar 22, 2016

I'm trying to install pg_idl, and while the installation completes (albeit with warnings about variable types), running pgsql_query() generates the error:

% PGSQL_QUERY: Error loading sharable executable.
Symbol: IDL_Load, File = /Users/olsen/idllib/pgsql/pg_idl-mast
er/pgsql_query.so
dlopen(/Users/olsen/idllib/pgsql/pg_idl-master/pgsql_query.so,
1): image not found

Seems pgsql_query.so should have been built by make, but wasn't. OBJFILES and SOFILES are defined in the Makefile, but as far as I can tell never used.

@segasai
Copy link
Owner

segasai commented Mar 23, 2016

But did it create the directory DLM? I've just tried it on linux (I am not a mac user, and don't have access to mac) with the most recent version of IDL and it did make the DLM directory with the .so and .dlm file:
$ ls DLM
pgsql_query.dlm pgsql_query.so

Also the actual compilation of the pgsql_query library is done by IDL itself (last line of the Makefile). Did it actually run ?
Here is what I am seeing when it runs

echo "make_dll,['pgsql_query','pgsql_query_util'],'pgsql_query','IDL_Load',input_directory='./',extra_cflags='"-Ipostgresql-9.5.1/src/interfaces/libpq/ -Ipostgresql-9.5.1/src/include/"',extra_lflags='"postgresql-9.5.1/src/interfaces/libpq/libpq.a"',compile_directory='./',/show_all_output,output_directory='DLM'" | idl
IDL Version 8.2.1 (linux x86_64 m64). (c) 2012, Exelis Visual Information Solutions, Inc.
Installation number: .
Licensed for use by: XXXXXXXXXX

Running the .idl_startup script...
% gcc -Ipostgresql-9.5.1/src/interfaces/libpq/ -Ipostgresql-9.5.1/src/include/ -fPIC -I"/opt/ioa/idl/idl82/external/include" -c -m64 -D_REENTRANT "/tmp/pg_idl/pgsql_query.c" -o "pgsql_query_2508_calx115.o"
% gcc -Ipostgresql-9.5.1/src/interfaces/libpq/ -Ipostgresql-9.5.1/src/include/ -fPIC -I"/opt/ioa/idl/idl82/external/include" -c -m64 -D_REENTRANT "/tmp/pg_idl/pgsql_query_util.c" -o "pgsql_query_util_2508_calx115.o"
% ld -r pgsql_query_2508_calx115.o -o partial_obj_2508_calx115.o
% mv -f partial_obj_2508_calx115.o partial_obj_tmp_2508_calx115.o
% ld -r pgsql_query_util_2508_calx115.o partial_obj_tmp_2508_calx115.o -o partial_obj_2508_calx115.o
% ld -shared -o "/tmp/pg_idl/DLM/pgsql_query_2508_calx115.so" "partial_obj_2508_calx115.o" postgresql-9.5.1/src/interfaces/libpq/libpq.a
cp -f pgsql_query.dlm DLM

I'am also wondering if the .so vs .dylib naming could be an issue. Could you check if the compilation succeed, did it maybe create teh pgsql_query.dylib file ? In that case maybe just renaming should do the trick

@knutago
Copy link
Author

knutago commented Mar 24, 2016

Thanks for the fast reply! So I see this:

echo "make_dll,['pgsql_query','pgsql_query_util'],'pgsql_query','IDL_Load',input_directory='./',extra_cflags='"-Ipostgresql-9.5.1/src/interfaces/libpq/ -Ipostgresql-9.5.1/src/include/"',extra_lflags='"postgresql-9.5.1/src/interfaces/libpq/libpq.a"',compile_directory='./',/show_all_output,output_directory='DLM',/nocleanup" | idl
IDL Version 8.4.1, Mac OS X (darwin x86_64 m64). (c) 2015, Exelis Visual Information Solutions, Inc.
Installation number: XXXXXX.
Licensed for personal use by XXXXXX only.
All other use is strictly prohibited.

% cc -Ipostgresql-9.5.1/src/interfaces/libpq/ -Ipostgresql-9.5.1/src/include/ -arch x86_64 -fPIC -no-cpp-precomp -dynamic -fPIC -fno-common -I"/idl/idl/idl/external/include" -c -D_REENTRANT "/Users/olsen/idllib/pg_idl/pg_idl-master/pgsql_query.c" -o "pgsql_query_45970_dhcp-3-166.o"
In file included from /Users/olsen/idllib/pg_idl/pg_idl-master/pgsql_query.c:66:
/idl/idl/idl/external/include/idl_export.h:2757:9: warning: 'strlcpy' macro redefined [-Wmacro-redefined]
#define strlcpy IDL_StrBase_strlcpy
        ^
/usr/include/secure/_string.h:104:9: note: previous definition is here
#define strlcpy(dest, src, len)                                 \
        ^
In file included from /Users/olsen/idllib/pg_idl/pg_idl-master/pgsql_query.c:66:
/idl/idl/idl/external/include/idl_export.h:2761:9: warning: 'strlcat' macro redefined [-Wmacro-redefined]
#define strlcat IDL_StrBase_strlcat
        ^
/usr/include/secure/_string.h:110:9: note: previous definition is here
#define strlcat(dest, src, len)                                 \
        ^
2 warnings generated.
% cc -Ipostgresql-9.5.1/src/interfaces/libpq/ -Ipostgresql-9.5.1/src/include/ -arch x86_64 -fPIC -no-cpp-precomp -dynamic -fPIC -fno-common -I"/idl/idl/idl/external/include" -c -D_REENTRANT "/Users/olsen/idllib/pg_idl/pg_idl-master/pgsql_query_util.c" -o "pgsql_query_util_45970_dhcp-3-166.o"
In file included from /Users/olsen/idllib/pg_idl/pg_idl-master/pgsql_query_util.c:28:
/idl/idl/idl/external/include/idl_export.h:2757:9: warning: 'strlcpy' macro redefined [-Wmacro-redefined]
#define strlcpy IDL_StrBase_strlcpy
        ^
/usr/include/secure/_string.h:104:9: note: previous definition is here
#define strlcpy(dest, src, len)                                 \
        ^
In file included from /Users/olsen/idllib/pg_idl/pg_idl-master/pgsql_query_util.c:28:
/idl/idl/idl/external/include/idl_export.h:2761:9: warning: 'strlcat' macro redefined [-Wmacro-redefined]
#define strlcat IDL_StrBase_strlcat
        ^
/usr/include/secure/_string.h:110:9: note: previous definition is here
#define strlcat(dest, src, len)                                 \
        ^
/Users/olsen/idllib/pg_idl/pg_idl-master/pgsql_query_util.c:194:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
/Users/olsen/idllib/pg_idl/pg_idl-master/pgsql_query_util.c:440:32: warning: format specifies type 'long' but the argument has type 'IDL_LONG64' (aka 'long long') [-Wformat]
        printf("ndim = %ld\n", ndim);fflush(stdout);
                       ~~~     ^~~~
                       %lld
/Users/olsen/idllib/pg_idl/pg_idl-master/pgsql_query_util.c:453:46: warning: format specifies type 'long' but the argument has type 'IDL_LONG64' (aka 'long long') [-Wformat]
                printf("  dim[%ld] = %ld\n", i, dims[i+1]);fflush(stdout);
                              ~~~            ^
                              %lld
/Users/olsen/idllib/pg_idl/pg_idl-master/pgsql_query_util.c:453:49: warning: format specifies type 'long' but the argument has type 'IDL_LONG64' (aka 'long long') [-Wformat]
                printf("  dim[%ld] = %ld\n", i, dims[i+1]);fflush(stdout);
                                     ~~~        ^~~~~~~~~
                                     %lld
/Users/olsen/idllib/pg_idl/pg_idl-master/pgsql_query_util.c:459:40: warning: format specifies type 'long' but the argument has type 'IDL_LONG64' (aka 'long long') [-Wformat]
        printf("Total length = %ld\n", *totlen);fflush(stdout);
                               ~~~     ^~~~~~~
                               %lld
/Users/olsen/idllib/pg_idl/pg_idl-master/pgsql_query_util.c:522:21: warning: format specifies type 'long' but the argument has type 'IDL_LONG64' (aka 'long long') [-Wformat]
                    fi->field_lengths[i], 
                    ^~~~~~~~~~~~~~~~~~~~
8 warnings generated.
% ld -r pgsql_query_45970_dhcp-3-166.o -o partial_obj_45970_dhcp-3-166.o
% mv -f partial_obj_45970_dhcp-3-166.o partial_obj_tmp_45970_dhcp-3-166.o
% ld -r pgsql_query_util_45970_dhcp-3-166.o partial_obj_tmp_45970_dhcp-3-166.o -o partial_obj_45970_dhcp-3-166.o
duplicate symbol _kw in:
    pgsql_query_util_45970_dhcp-3-166.o
    partial_obj_tmp_45970_dhcp-3-166.o
ld: 1 duplicate symbol for inferred architecture x86_64
cp -f pgsql_query.dlm DLM

My output is missing the ld -shared step which creates the shared library. Perhaps the warnings are not harmless as I had assumed they were?

@knutago
Copy link
Author

knutago commented Mar 24, 2016

Update: I think your hunch about dylib goes in the right direction. ld -shared on my Mac returns an error that ld -shared is not a valid option. So I tried forcing:

dhcp-3-166:pg_idl-master olsen$ ld -dylib -o pgsql_query.so partial_obj_tmp_46080_dhcp-3-166.o postgresql-9.5.1/src/interfaces/libpq/libpq.a
But then get errors:

ld: warning: -macosx_version_min not specified, assuming 10.10
Undefined symbols for architecture x86_64:
  "_IDL_GettmpInt", referenced from:
      _pgsql_query in partial_obj_tmp_46080_dhcp-3-166.o
  "_IDL_KWFree", referenced from:
      _pgsql_query in partial_obj_tmp_46080_dhcp-3-166.o
  "_IDL_KWProcessByOffset", referenced from:
      _pgsql_query in partial_obj_tmp_46080_dhcp-3-166.o
  "_IDL_Message", referenced from:
      _pgsql_query in partial_obj_tmp_46080_dhcp-3-166.o
  "_IDL_StoreScalarZero", referenced from:
      _pgsql_query in partial_obj_tmp_46080_dhcp-3-166.o
  "_IDL_SysRtnAdd", referenced from:
      _IDL_Load in partial_obj_tmp_46080_dhcp-3-166.o
  "_IDL_VarGetString", referenced from:
      _pgsql_query in partial_obj_tmp_46080_dhcp-3-166.o
  "_pgsql_query_nparams", referenced from:
      _pgsql_query in partial_obj_tmp_46080_dhcp-3-166.o
  "_pgsql_query_send", referenced from:
      _pgsql_query in partial_obj_tmp_46080_dhcp-3-166.o
  "_pgsql_query_send_async", referenced from:
      _pgsql_query in partial_obj_tmp_46080_dhcp-3-166.o
  "_setStatus", referenced from:
      _pgsql_query in partial_obj_tmp_46080_dhcp-3-166.o
ld: symbol(s) not found for inferred architecture x86_64

@segasai
Copy link
Owner

segasai commented Mar 26, 2016

I was looking at this https://groups.google.com/forum/#!topic/comp.lang.idl-pvwave/ntdNr8ozT2c as well as this http://www.harrisgeospatial.com/docs/MAKE_DLL.html and what may help is to set LD= keyword of the MAKE_DLL
call to 'ld -dylib' as well as PLATFORM_EXTENSION= to 'dylib'
e.g. update the last like of the makefile to something like this
echo "make_dll['pgsql_query','pgsql_query_util'],'pgsql_query','IDL_Load',input_directory='./',extra_cflags='"$(PG_CFLAGS)"',extra_lflags='"$(LIBPQA)"',compile_directory='./',/show_all_output,output_directory='DLM', LD='ld -dylib', PLATFORM_EXTENSION='dylib'" | idl
unfortunately again I can't test this, so I'm just guessing...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants