How to fix 'postgres.h' file not found problem? - c

I am trying to write a base type for PostgreSQL in C (using xcode), and I already installed PostgreSQL 11, but it seems that postgres.h cannot be simply included in the file ("'postgres.h' file not found").
Could someone tell me how to fix that problem? And can I write code under an arbitary directory, or do I have to write under the PostgreSQL directory?
Or perhaps the question should be: how to install header files like postgres.h?

Install postgresql-server-dev package with this command:
sudo apt install postgresql-server-dev-XX
Replace [XX] with your already installed version of postgresql:9.5, 10, 11, 12

You have several approaches here:
Search for the file yourself, using some command like
find / -name "postgres.h" -print
this will tell you (on my Mac does) the file is in:
/usr/local/Cellar/postgresql/11.2_1/include/server/postgres.h
and add the -I /usr/local/Cellar/postgresql/11.2_1/include/server option to the compiler. Check your postgresql version for the possibility of having a different one.
Probably there's another package for database development. Search for a package named postgresql-dev or similar, and install it. After searching packages with:
brew search postgres
and
brew search psql
on my system doesn't appear anything that matches.
EDIT
I've checked a FreeBSD system for that file and it appears on
/usr/local/include/postgresql/server/postgres.h
So probably you have to #include <server/postgres.h> instead, and use the appropiate -I flag (as mentioned above)

I was facing the same issue while compiling postgis 3.1.7 for postgresql#13 on my Mac.
The problem was that in pg_config the link to server file was
/opt/homebrew/opt/postgresql#13/include/server
While the actual server folder was in
/opt/homebrew/opt/postgresql#13/include/postgresql/server
So I moved the entire "server" folder up a directory inside "/include". And viola, postgis compiled and installed perfectly.

Related

VS Code Remote - Can't run 'code' command in WSL Ubuntu 18 or WSL 2 Ubuntu 20 - wrong path

I'm having an issue when I try to run the code command from Visual Studio Code in WSL Ubuntu. I get the following error:
$ code .
/mnt/c/Users/Name/.vscode/extensions/ms-vscode-remote.remote-wsl-0.64.2/scripts/wslCode.sh: 63: /mnt/c/Users/Name/.vscode/extensions/ms-vscode-remote.remote-wsl-0.64.2/scripts/wslCode.sh: /home/barry/.vscode/bin/899d46d82c4c95423fb7e10e68eba52050e30ba3/bin/remote-cli/code: not found
When I run the following, it installs the VS Code Server and the command works as expected:
$ /mnt/c/Users/Name/AppData/Local/Programs/Microsoft\ VS\ Code/bin/code .
When I run which -a code, I can see I have two paths related to this command and I believe the correct one is /mnt/c/Users/Name/AppData/Local/Programs/Microsoft VS Code/bin/code, but I don't know how to remove the first one or how it even related two paths to this command in the first place?
barry#RandomName:~$ which -a code
/mnt/c/Program Files/Microsoft VS Code/bin/code
/mnt/c/Users/Name/AppData/Local/Programs/Microsoft VS Code/bin/code
Can anyone help please?
Ran into the same problem 5 min ago and this post from thesteve0 worked for me:
https://github.com/microsoft/vscode-remote-release/issues/6294#issuecomment-1031974516
Quoting from the original post:
Open VS Code on Windows
Open Extensions and then search on WSL
It should say the extension needs to be reloaded - go ahead and reload it
Open WSL and type code
This should force another upgrade of code and this time it should launch.
I've managed to 'solve' it by creating a new Symlink to the correct directory so this one gets run first. I couldn't find a way to remove the incorrect directory so would appreciate it if someone knows a cleaner solution?
To add the Symlink, I ran ln -s /mnt/c/Users/Name/AppData/Local/Programs/Microsoft\ VS\ Code/bin/code /usr/local/bin/code
So now I have these 3 paths for the code command:
$ which -a code
/usr/local/bin/code
/mnt/c/Program Files/Microsoft VS Code/bin/code
/mnt/c/Users/Name/AppData/Local/Programs/Microsoft VS Code/bin/code
Whenever I tried to remove rm or unlink /mnt/c/Program Files/Microsoft VS Code/bin/code (with sudo), I get permission denied.
Just run Vscode normally on windows. This will load wsl extension and solve the issue.
A simple sudo apt update -y and then rerunning code . fixed this for me.
I fixed my issue by opening wsl and removing the .vscode-server
rm -rf .vscode-server
i followed this link link to fix
Keep it simple S*upid method:
Download & install vscode again. link for windows
(Ubuntu example) apt update && yes | apt upgrade
Try to launch code from wsl
You should see something like:
Updating VS Code Server to version 5554b12acf27056905806867f251c859323ff7e9
Removing previous installation...
Installing VS Code Server for x64 (5554b12acf27056905806867f251c859323ff7e9)
In my case the extension in VS Code was not in a state needing reload like in the most upvoted answer. What helped after multiple attempts:
Terminate the WSL2 distribution (from the Windows CLI): wsl -t Ubuntu (replace Ubuntu with your distribution name)
Check that it is stopped: wsl -l -v
Start your WSL distribution again.
In my case the command code started to be accessible through a Windows directory: /mnt/c/Users/username/AppData/Local/Programs/Microsoft VS Code/bin/code
In C:\Users<user>.vscode rename path ms-vscode-remote.remote-wsl- to ms-remote-wsl-old
In WSL run: code .
I got two versions of Visual Studio Code installed, one said "(user)". I uninstalled both and installed the newest version via winget.
That fixed it for me.
I have got two different versions of visual studio code installed on my PC.
I have uninstalled the older version keeping the latest one.
This resolved issue for me.

How to install PostGIS into Postgres-XL correctly?

I have Postgres-XL 10 installed with geos-3.9.1 and postgis-3.1.1 on my Amazon Linux 2 machine. My cluster is running and working flawlessly but I am having troubles with getting postgis installed into the database. I've built and installed everything from source.
The error I'm getting when I run CREATE EXTENSION postgis; is:
ERROR: could not load library "/usr/local/pgsql/lib/postgis-3.so": libgeos_c.so.1: cannot open shared object file: No such file or directory
Using solutions from other posts online, I have tried:
Running sudo ldconfig
Using the --enable-shared option when installing geos and postgis
Ensured /usr/local/lib is in the LD_LIBRARY_PATH environment variable and I also added /usr/local/pgsql/lib to LD_LIBRARY_PATH
None of these solutions worked. I can't install PostGIS or Geos using yum because it will install postgresql 12 which conflicts with my version of postgresql which is a custom one for Postgres-XL.
Is there anything else I can try to solve this error? Any help is appreciated.
Thanks.
It looks like you might need to downgrade. Postgres-XL is only supporting 2.0.x versions of postgis right now. At least according to their docs.
https://www.postgres-xl.org/faq/
Q. Is PostGIS supported?
Yes, PostGIS can be added to Postgres-XL. It has been tested with PostGIS 2.0.

In Debian Jessie apache2-dev package is missing aspx2

I have verified that I have installed the latest apache2, apache2-bin, apache2-dev, apache2-mpm-prefork, apache2-utils, apache2.2-bin, and apache2.2-common. The apache2-dev package is supposed to include aspx2 located in /usr/bin, but it's not there.
I removed and reinstalled apache2-dev, but aspx2 is still not being installed on my system. If you know how to resolve this issue, I would appreciate the help.
Probably you mean apxs (APache eXtenSion tool) ?
If so, the filename is /usr/bin/apxs and it exists in apache2-dev
https://packages.debian.org/jessie/amd64/apache2-dev/filelist
If not please list files of this package with
dpkg -L apache2-dev

Not able build apache mod_tile in openSuse error: Could not find apxs on the path

I want to run a tiles server with OSM data
i want to install mod_tile so i followed the mod_tile setup
But when i do the
./configure
It says
checking for getloadavg... yes
checking for apxs... no
checking for apxs2... no
checking for /opt/local/apache2/bin/apxs... no
configure: error: Could not find apxs on the path.
any idea what went wrong?
According to the Internets you need to install apache2-dev (previously known as apache2-devel). The apx binary should then be located under /usr/bin/apxs2 or /usr/sbin/apxs2.
Note: For building a tile server you should follow the guide on switch2osm.
For Ubuntu
sudo apt-get install apache2-devel
For RedHat & CentOs
yum install httpd-devel
SUSE has removed the SDK ISO from the area where you download the server ISO.
Check out this page.
I consider their page as very complicated and not logical so play a bit around but you find it in the end.
When you are looking for a current version then it helps you check Last 6 months

Problems with "cabal install cabal-install" in Windows

After Haskell Plaftform 2013.2.0.0 installation, the cabal.exe is in "C:\Program Files (x86)\HaskellPlatform\2013.2.0.0\lib\extralibs\"
After execution of "cabal install cabal-install" the updated cabal.exe file is in "C:\Users\Alberto\AppData\Roaming\cabal\bin"
But the old cabal.exe is still in "..\extralibs", so it is always the old version to be performed.
User variables for Alberto: PATH = C:\Users\Alberto\AppData\Roaming\cabal\bin
System variables: Path = C:\Program Files (x86)\Haskell\bin;C:\Program Files (x86)\Haskell Platform\2013.2.0.0\lib\extralibs\bin;C:\Program Files (x86)\Haskell Platform\2013.2.0.0\bin;C:\Program Files (x86)\PC Connectivity Solution\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files (x86)\Haskell Platform\2013.2.0.0\mingw\bin
I hastily solved this problem by deleting the cabal.exe file in "..\extralibs", but I do not think that this is the best solution.
I have found this problem even on other computers with Windows operating systems (Vista, Windows 7, Windows 8)
You can specify where to install cabal with the "--bindir=" option. So if you do the following, it should find it (You may have to run it from an administrative command prompt):
cabal install --bindir="C:\Program Files (x86)\Haskell\bin" cabal-install
The Haskell\bin directory didn't exist on my install (Haskell Platform 2014.2.0.0 on Windows 8 64-bit), but the install still put it first in the path. So I assumed that is where it expected cabal to install. Doing so will make sure it is found first. You can check with where cabal. It will list all cabal's on the path, with the first one used by default.

Resources