Difficulty in executing basic OpenCV example on Mac - c++

System Information: Mac OSX 10.7.3
I am trying to execute basic opencv example. The program is getting compiled but when I try to execute I receive this error msg:
dyld: Library not loaded: /opt/local/lib/libx264.118.dylib
Referenced from: /opt/local/lib/libavcodec.dylib
Reason: image not found
Trace/BPT trap: 5
Before it was working fine. But yesterday I just reinstalled my Xcode 4.3 version and I don't know why suddenly I get this error for this example.
Can someone please help me with that?
Thanks!

I figured out myself. So either try simply this:
sudo port -nR upgrade --force ffmpeg
because I think these lib files mentioned below may belongs to ffmpeg and maybe ffmpeg package might have broken.
libx264.118.dylib
libavcodec.dylib
Or you can do this for all outdated ports. It will most probably fix all the bugged ports
sudo port outdated
sudo port -nR upgrade --force outdated

Related

Error loading psycopg2 module: Library not loaded: libpq.5.dylib

I am trying to run a Django project with Postgres database. I use Postgres 13.4 installed via postgressapp (UNIVERSAL with all currently supported versions) and python 3.9 (in venv). I work on Mac with Apple M1 chip, macOS Big Sur.
I faced the following well-known problem:
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: dlopen(/Users/mymac/PyCharmProjects/projectname/venv/lib/python3.9/site-packages/psycopg2/_psycopg.cpython-39-darwin.so, 2): Library not loaded: /opt/homebrew/opt/postgresql/lib/libpq.5.dylib
  Referenced from: /Users/mymac/PyCharmProjects/projectname/venv/lib/python3.9/site-packages/psycopg2/_psycopg.cpython-39-darwin.so
  Reason: image not found
With searching, I found some discussions like this: https://github.com/psycopg/psycopg2/issues/1216. It seems that the most relevant solution is "RyanDurk commented on Jan 27":
$ brew install libpq --build-from-source
$ export LDFLAGS="-L/opt/homebrew/opt/libpq/lib"
$ pip install psycopg2
Unfortunately, in my case it does not help.
Then, I found some recommendations here: Library not loaded: /usr/local/lib/libpq.5.4.dylib and tried them. In particular, I tried to reach libpq.5.dylib via symlink like:
ln -s  /Library/PostgreSQL/13/lib/libpq.5.dylib /opt/homebrew/opt/postgresql/lib/libpq.5.dylib (the solution marked as accepted by topic starter), but also unsuccessfully.
I tried to install postgres from postgresql.org, then uninstall/reinstall postgres with homebrew, then
gem uninstall pg -> bundle install
with the same result.
I have run the same project successfully before, on the mac with Intel chip and PyCharm community edition. Also the same project runs normally on Linux.
If you have any idea what happens and how to fix this problem, please help me. I provide more details if necessary.
I had the same error after brew decided to upgrade my postgresql package to version 14 (your version may vary).
There was this part of the error message:
Library not loaded: '/usr/local/opt/postgresql/lib/libpq.5.dylib'
...
Reason: tried: '/usr/local/opt/postgresql/lib/libpq.5.dylib' (no such file)
I basically found the new location of the libpq and symlinked it to the location where psycopg2 was looking for it:
ln -s /usr/local/lib/postgresql#14/libpq.5.14.dylib /usr/local/opt/postgresql/lib/libpq.5.dylib
Hope that helps anyone else with a similar issue.

FFTW Error "Symbol not found: _ompi_mpi_char" when running executable

I'm on macOS Catalina (10.15.7) and I have FFTW installed using brew install fftw. Up until today, I was able to run an executable which required FFTW. I have no idea why it just stopped working today and gave me the following error.
dyld: Symbol not found: _ompi_mpi_char
Referenced from: /usr/local/opt/fftw/lib/libfftw3_mpi.3.dylib
Expected in: flat namespace
in /usr/local/opt/fftw/lib/libfftw3_mpi.3.dylib
zsh: abort ./cartogram -h
I've tried everything from uninstalling and reinstalling all my brew packages and git cloning a fresh repo from GitHub but it doesn't work despite it working for my friend when he freshly clones the repo from GitHub. My suspicion is that it has something to do with my "macOS Catalina 10.15.7 Update" 2 days ago, which is 1 day after I last successfully ran my executable.
Any help is appreciated, thank you.
I think it might be due to the formula's flag --enable-openmp. I have tried to compile FFTW 3.3.10 myself using the following command to configure:
./configure --enable-threads --enable-shared --disable-debug --disable-dependency-tracking --enable-avx2
and then
make && make install

VirtualBox extension pack error

I purchased a network card to give a separate network to my virtual machine. My host OS is Ubuntu 14.04 . Also i need to mount the USB to my virtual machine and not my host OS, so i downloaded extension pack version 5.0.2 for Vbox-5.0 . While installing virtual box extension pack, there were two VM's running and i got this popup.
Failed to install the Extension Pack /home/aniket/Downloads/Oracle_VM_VirtualBox_Extension_Pack-5.0.20-106931.vbox-extpack.
Failed to load the main module ('/usr/lib/virtualbox/ExtensionPacks/Oracle_VM_VirtualBox_Extension_Pack/linux.amd64/VBoxPuelMain.so'): VERR_FILE_NOT_FOUND - /usr/lib/virtualbox/ExtensionPacks/Oracle_VM_VirtualBox_Extension_Pack/linux.amd64/VBoxPuelMain.so: undefined symbol: RTLogRelGetDefaultInstanceEx.
Result Code: NS_ERROR_FAILURE (0x80004005)
Component: ExtPackManager
Interface: IExtPackManager {3295e6ce-b051-47b2-9514-2c588bfe7554}
Even after power off of VM's and restarting the host OS, I get this similar error code.
Sorry if you think the question is not formatted properly or any other issue with my question. This is my second post, please tell me if there are any things i need to correct in my question.
Thanks in Advance.
After lot of test and trial, the solution I found that the extension pack was not compatible and hence I had to download the compatible version of the virtualbox I am running on.
What happened was this, I was running virtualbox-5.0 and the version I was trying to install was 5.0.20 .
You can check your version by clicking on Help and then About Virtualbox and download the exact compatible extension pack, else it will through the same hex error code 0x80004005 which means file not found.
Run vboxmanage command with sudo, i.e.:
sudo vboxmanage extpack install Oracle_VM_VirtualBox_Extension_Pack-5.1.22-115126.vbox-extpack --replace
From:
https://www.virtualbox.org/ticket/17034
I uninstalled virtualbox,then reinstall it. After this the extension pack got installed successfully. My version is `5.1.12 r112440 (Qt5.6.2)
I encounter this problem again, but this time I disable my antivirus software(mcafee), that is ok. refer by https://www.virtualbox.org/ticket/7972

How to install gtk on OSX for use with g++/gcc compiler

I already asked this question at apple.stackexchange.com, but I was told it was the wrong place for this question - so I will ask it here, as I was suggested to do.
At my university we got the task to implement a c-program which has a GTK-GUI. The GTK-GUI is already implemented, we just have to implement a algorithm which hands it some data.
I already got gcc/g++ working. But when i try to compile the project the compiler returns the error, that it does not find the gtk:
fatal error: 'gtk/gtk.h' file not found
#include <gtk/gtk.h>
^
So my question is:
How do I install gtk on OSX Mavericks for using it with gcc/g++ compiler?
My setup: MacBook Pro Retina Mid 2012 with OSX Mavericks. Homebrew is installed and working if it could be useful for the installation.
(Of course the Apple Command Line Developer Tools are installed)
I finally solved the Problem. tojanfoe suggested in a comment the link http://www.hardcoded.net/devlogs/20120426 which turned out to not be helpful.
This is how i solved it:
1.a) Installation of GTK+ 2.x:
brew install gtk+
1.b) Installation of GTK+ 3.x:
You can install gtk+ 3.x via home brew too if you need that, but the 2.x version is enough for my purposes. The command would be:
brew install gtk+3
2.)
But after the installation I had the problem, that cairo could not be found. So i solved it this way:
export PKG_CONFIG_PATH=/usr/local/Cellar/cairo/1.12.16/lib/pkgconfig/
3.)
Then the compiler said it could not find the package 'xcb-shm', required by 'cairo'. This can be solved this way:
export PKG_CONFIG_PATH=/usr/X11/lib/pkgconfig
After this command the compiler worked as expected.
You can download precompiled Gtk2 Framework from: http://r.research.att.com
http://r.research.att.com/libs/GTK_2.24.17-X11.pkg,
or
http://r.research.att.com/libs/GTK_2.18.5-X11.pkg
And Gtk3 Framework from: http://www.tarnyko.net/dl/gtk.htm

installing c++ boost on mac osx leopard -- port fails

I'm not much of a c++ programmer, just an end-user trying to install an existing project from source.
One of the project dependencies is the boost library.
When I tried to install boost on my osx 10.5.7 using "sudo port install boost", I got the following error message:
---> Building boost with target all
Error: Target org.macports.build returned: shell command " cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_boost/work/boost_1_35_0" && gmake all " returned error 2
Command output: Makefile:2: *** missing separator. Stop.
Error: Status 1 encountered during processing.
help?
EDIT: I suspect something is wrong with my system, though I am not sure what -- it's just a plain osx installation + the xcode CD that came with it, nothing fancy. [things are just so much easier on this front on linux!)
I did "sudo port selfupdate" and "sudo port upgrade outdated" as suggested in an answer,
and the second one ran about all night, then failed with many errors, the last few are:
Error: The following dependencies failed to build: db46
Error: Unable to upgrade port: 1
---> Extracting tiff
On Mac OS X 10.5, tiff 3.8.2 requires Xcode 3.1 or later but you have Xcode 3.0.
Error: Target org.macports.extract returned: incompatible Xcode version
Error: Unable to upgrade port: 1
---> Activating xorg-renderproto #0.9.3_0
Error: Target org.macports.activate returned: Image error: /opt/local/include/X11/extensions/render.h is being used by the active render port. Please deactivate this port first, or use 'port -f activate xorg-renderproto' to force the activation.
Error: The following dependencies failed to build: xorg-renderproto
Error: Unable to upgrade port: 1
In my experience you can easily do things with other installers that can break the port command from working correctly. Not to mention that MacPorts just breaks at the most random of times for me. Once I removed perl using the port command. It broke the whole port installation, don't even try this.
If you can I would just build Boost from source using gcc.It is actually not that difficult.
I have written an article on how to do this with some detail here.
It has a specific focus on how to do this on Mac OS X but says how to do this on Windows as well.
The two commands you will need are:
Build debug libs using GCC:
bjam toolset= darwin variant=debug threading=multi link=static
Build release libs using GCC:
bjam toolset=darwin variant=release threading=multi link=static
More detailed info on doing this here.
On Mac OS X 10.5, tiff 3.8.2 requires Xcode 3.1 or later but you have Xcode 3.0.
Isn't that the cause of port upgrade outdated failure?
Try running 'sudo port selfupdate'. You are using an outdated version of MacPorts. Once this is done run 'port upgrade outdated' to update the ports you have and then try to install boost again.
Update:
Update XCode as Paul mentioned in a post below. You can get it on the Apple Developer Site. You will probably have to signup to get a download link. As for the bug about the active render port you can safely disable this port as it has been replaced by xorg-renderproto. Deactivate it by running 'sudo port deactivate render'. Once that is done you can update again using 'port upgrade outdated' and it shouldn't take as long this time.
My experiences with MacPorts are a mixed blessing at best. Sometimes ports are out of date, or only half-done, it's very nice when it works, but unfortunatly doesn't always, so I kind of gave up on port to be honest...
That said, the default configure, bjam, ... combo from the boost distribution works flawlessly on os x, any reason you specifically want to get it working via port ?