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:
- 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
- I have tried reloading PostgreSQL, but the error still occurs.
- 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!
I also faced some errors while developing a C extension (PostgreSQL).
There are 3 main files for any extension.
1 .c file
.control file
.sql file
Make sure, your system is running proper versions that are compatible with each other while developing an extension.
I hope this answers our question.
Reference => Manual.