skip to Main Content

I am facing an issue while trying to create a C-based PostgreSQL extension. I have the extension code available in my GitHub repository, and I am trying to load it using the CREATE EXTENSION command in PostgreSQL. However, I am encountering the following error:

ERROR: could not load library "/Users/spartacus/Desktop/GSoC/CODE/pg_cext": dlopen(/Users/spartacus/Desktop/GSoC/CODE/pg_cext, 0x000A): tried: '/Users/spartacus/Desktop/GSoC/CODE/pg_cext' (not a file), '/System/Volumes/Preboot/Cryptexes/OS/Users/spartacus/Desktop/GSoC/CODE/pg_cext' (no such file), '/Users/spartacus/Desktop/GSoC/CODE/pg_cext' (not a file)

I have verified that the extension files are present at the given location, and the necessary permissions are also set. Despite this, the extension is not loading, and the error persists.

Steps Taken to Resolve the Issue:

  1. I have checked the file permissions for the extension files, and they seem to be correct.
ls -l /Users/spartacus/Desktop/GSoC/CODE/pg_cext


total 80
-rw-r--r--@ 1 spartacus  staff    139 Jul 15 12:24 Makefile
-rw-r--r--@ 1 spartacus  staff    100 Jul 15 12:27 pg_cext--1.0.0.sql
-rw-r--r--@ 1 spartacus  staff    227 Jul 15 12:27 pg_cext.c
-rw-r--r--@ 1 spartacus  staff    157 Jul 15 11:56 pg_cext.control
-rw-r--r--  1 spartacus  staff    984 Jul 17 09:14 pg_cext.o
-rwxr-xr-x  1 spartacus  staff  16951 Jul 17 09:14 pg_cext.so
  1. I have tried reloading PostgreSQL, but the error still occurs.
  2. I have confirmed that the extension files exist at the specified location, but the error message suggests otherwise.

My Environment:

  • PostgreSQL version: postgres (PostgreSQL) 15.0
  • Operating System: MacOS [M1 chip]
  • Extension Code

Can anyone help me troubleshoot and fix this issue? Thank you in advance for your assistance!

2

Answers


  1. Please do the following:
    1.Check file permissions :

    pg_cext.so: ls -l /Users/spartacus/Desktop/GSoC/CODE/pg_cext
    
    1. Verify file path is correct & then Set the DYLD_LIBRARY_PATH:
    export DYLD_LIBRARY_PATH=/Users/spartacus/Desktop/GSoC/CODE
    
    1. Use an absolute path in CREATE EXTENSION command.
    2. Restart PostgreSQL by using the command
     sudo systemctl restart postgresql
    
    1. Check PostgreSQL logs for additional details & Ensure extension is compiled for PostgreSQL 15.0 and M1 architecture.

    I hope it will work..

    #Apache-Age #postgresql

    Login or Signup to reply.
  2. Try to follow from this Manual, it will help you making your first extension and you can correct your mistakes aswell.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search