how to uninstall openCV on mac 10.6.8? - opencv

I have multiple versions of openCV (2.0,2.1) on my mac. Is there a way to erase these multiple versions and all its files so that i can make a fresh install of openCV 2.3.0

The most obvious command
sudo port uninstall opencv
may not work, at least in my case it complained that it needs a particular version. I run then
sudo port uninstall opencv 4.2
All opencv libraries in /opt/local/lib were gone after that command. After that I re-installed openCV with
sudo port install opencv
(If there is a problem with ffmpeg just uninstlal it with sudo port uninstall ffmpeg)
Reinstalling opencv, by the way, fixed my problems with compilation and linking that I had after switching from Mountain Lion to Maverick (10.9.2). In particular, I had a linker problem in Eclipse:
Invoking: GCC C++ Linker
g++ -L/opt/local/lib -o "deltetit" ./src/deltetit.o -lopencv_core -lopencv_highgui -lopencv_imgproc
Undefined symbols for architecture x86_64:
"cv::imshow(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, cv::_InputArray const&)", referenced from:
_main in deltetit.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [deltetit] Error 1

Just delete the install folder.
And make sure to point to the correct install path when compiling your proj

Related

Undefined symbols for architecture arm64 building nokogiri-xmlsec-instructure Ruby gem

Recently I was trying to get a Ruby on Rails project running on macOS Ventura (Apple M1 Silicon) and was running into a problem with building the nokogiri-xmlsec-instructure gem.
The build error:
make "DESTDIR="
compiling init.c
compiling nokogiri_decrypt_with_key.c
compiling nokogiri_encrypt_with_key.c
compiling nokogiri_helpers_set_attribute_id.c
compiling nokogiri_init.c
compiling nokogiri_sign.c
compiling nokogiri_verify_with.c
compiling options.c
compiling shutdown.c
compiling util.c
linking shared-object nokogiri_ext_xmlsec.bundle
Undefined symbols for architecture arm64:
"_noko_xml_document_pin_node", referenced from:
_decrypt_with_key in nokogiri_decrypt_with_key.o
"_noko_xml_node_wrap", referenced from:
_get_id in nokogiri_helpers_set_attribute_id.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [nokogiri_ext_xmlsec.bundle] Error 1
make failed, exit code 2
The solution for this problem is:
Make sure you have installed brew install libxmlsec1 pkg-config
Run bundle config build.nokogiri-xmlsec-instructure --with-ldflags="-Wl,-undefined,dynamic_lookup" (Source: https://github.com/instructure/nokogiri-xmlsec-instructure/issues/15)
You should now be able to bundle install and build nokogiri-xmlsec-instructure

-lomp not found for openmp apple m1

I am currently trying to compile a cpp program with openmp. From what I have read online this is the command that I need to use for indeed using openmp on apple silicon:
g++ -Xpreprocessor -fopenmp -I/opt/homebrew/Cellar/libomp/14.0.6/include -L/usr/local/lib -lomp heat2D.cpp
I have installed everything required for openmp (libomp,llvm,etc...) but it gives me this error:
ld: library not found for -lomp
clang: error: linker command failed with exit code 1 (use -v to see invocation)
In addition if try to remove the lomp flag:
g++ -Xpreprocessor -fopenmp -I/opt/homebrew/Cellar/libomp/14.0.6/include heat2D.cpp
this is the error i get:
Undefined symbols for architecture arm64:
"_omp_set_num_threads", referenced from:
_main in heat2D-0b5aaa.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Since you mention that you installed GCC (and LLVM) via Homebrew, the problem is probably (as Jim Cownie suggested) that when you type "g++", you are running the default link to Apple's LLVM installation (which, alas, does not support OpenMP).
The problem is that Homebrew installs its versions of the compiler binary commands using versioned names -- e.g., "g++-12" if you installed the latest version of GCC. So you have to use those names if you want to run the Homebrew versions. (They are probably installed in /opt/homebrew/bin/ in your case, since you have an Apple Silicon Mac.)
(I haven't installed Homebrew's version of LLVM, but it's probably a similar situation for that as well, since you wouldn't want it to overwrite Apple's LLVM commands.)

Problems linking FFTW with gfortran (symbol(s) not found for architecture x86_64)

I am on macOS Catalina (10.15.5) and I have installed FFTW using brew install fftw. I also have GCC (version 10.2.0) installed which is symlinked to the commands I am using below.
I am able to compile and run a simple C++ program like so:
g++-10 test.cpp -L/usr/local/lib -I/usr/local/include -lfftw3 -lm
But, I had to modify the environment variable CPATH to make this work.
I am unable to get a simple Fortran FFTW example to work (I am using this one). The command I am using to compile is:
gfortran-10 test.f90 -L/usr/local/lib -I/usr/local/include -lfftw3 -lm
The error I get is as follows:
Undefined symbols for architecture x86_64:
"__gfortran_os_error_at", referenced from:
_MAIN__ in ccRvJaEQ.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
If I understand correctly, the linking step fails. Any inputs on how I might find the relevant paths that I may have to pass to the compiler would be very helpful. I searched for solutions and I wasn't able to find one. But, in case I missed something obvious, I apologise.
Thanks to msi_gerva's helpful hints through comments, I was able to solve the issue by downloading FFTW and compiling it to a custom directory following the installation directions.
Now, the linking doesn't fail if I pass the new locations of the libraries to gfortran like so:
gfortran-10 test.f90 -L/new/path/to/lib -I/new/path/to/include -lfftw3 -lm
Since /usr/local/ is the default installation path, it's possible that there is a mixing up of the FFTW library files from previous installations.

Linking OpenCV 2.3 program in Mac OS X Lion: symbol(s) not found for architecture x86_64

I'm having a problem when trying to compile the program in this tutorial from the OpenCV 2.3 official documentation. I have created the CMakeList.txt like it's said in the link. Well, it didn't work.
After a good time searching Google and trying to fix it, I have added the correct lib and include folders to the OpenCVConfig.make (at /opt/local/share/opencv here). Well, this is the output when I try to make it:
$ cmake .
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/carlosagarie/dropbox/code/c++/opencv
$ make
Linking CXX executable teste
Undefined symbols for architecture x86_64:
"cv::_InputArray::_InputArray(cv::Mat const&)", referenced from:
_main in teste.cc.o
"cv::imshow(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)", referenced from:
_main in teste.cc.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make[2]: *** [teste] Error 1
make[1]: *** [CMakeFiles/teste.dir/all] Error 2
make: *** [all] Error 2
Trying to find out why it said ld: symbol(s) not found for architecture x86_64, I looked at my libraries folder (/opt/local/lib) and used the file command:
libopencv_calib3d.2.2.0.dylib: Mach-O 64-bit dynamically linked shared library x86_64
The same for all the other libs. So, I assume that it's not a problem with them. But, why isn't ld working them? I really don't know what to do.
The code is the same as in the tutorial presented earlier. My CMakeLists.txt file:
cmake_minimum_required(VERSION 2.8)
project( teste )
find_package( OpenCV REQUIRED )
add_executable( teste teste )
target_link_libraries( teste ${OpenCV_LIBS} )
Thanks in advance!
I noticed you are following the 2.3.x guide, but the link error is referring to 2.2.0. Which version are you using?
Have you tried compiling it manually?
With something like this:
Assuming OPENCV_ROOT is set to your install location (e.g., /opt/local)
g++ -I$OPENCV_ROOT/include -L$OPENCV_ROOT/lib -lopencv_core2.2.0 -lopencv_calib3d2.2.0 -c test.cpp
If that doesn't work, have you tried running ldconfig as root? Is the install location for the opencv libraries setup in /etc/ld.so.conf (If not, you need to do this first before ldconfig will do anything useful)?
Edit you answer with updates to these questions. And, I'll try to help you with the rest.
EDIT :
You might also try adding this to your ~/.profile and see it fixes it:
export DYLD_FALLBACK_LIBRARY_PATH=/opt/local/lib
Have you tried following this guide starting from Section 2 with XCode?

/usr/local/lib/libz.1.dylib, file was built for i386 which is not the architecture being linked (x86_64)

having this problem on installing several things on my mac,
i think this problem is coming from upgrading my leopard to snow leopard. Also this problem also is linked with macports i think.
/usr/local/lib/libz.1.dylib, file was built for i386 which is not the architecture being linked (x86_64)
Any ideas?
Update
To be more specific this happens on installing nokogiri gem
and the log looks like:
xslt_stylesheet.c:127: warning: passing argument 1 of ‘Nokogiri_wrap_xml_document’ with different width due to prototype
cc -dynamic -bundle -undefined suppress -flat_namespace -o nokogiri.bundle
html_document.o html_element_description.o html_entity_lookup.o html_sax_parser_context.o nokogiri.o xml_attr.o xml_attribute_decl.o xml_cdata.o xml_comment.o xml_document.o xml_document_fragment.o xml_dtd.o xml_element_content.o xml_element_decl.o xml_encoding_handler.o xml_entity_decl.o xml_entity_reference.o xml_io.o xml_libxml2_hacks.o xml_namespace.o xml_node.o xml_node_set.o xml_processing_instruction.o xml_reader.o xml_relax_ng.o xml_sax_parser.o xml_sax_parser_context.o xml_sax_push_parser.o xml_schema.o xml_syntax_error.o xml_text.o xml_xpath_context.o xslt_stylesheet.o -L. -L/usr/local/lib -L/opt/local/lib -L/usr/local/lib -L/usr/lib -L. -lruby -lexslt -lxslt -lxml2 -lpthread -ldl -lobjc
ld: in /usr/local/lib/libz.1.dylib, file was built for i386 which is not the architecture being linked (x86_64)
collect2: ld returned 1 exit status
make: *** [nokogiri.bundle] Error 1
This is not about MacPorts:
zlib is installed as i386, so you have to build it for x86-64. Here's how to do it:
Update: As Nick says in his comment, you first have to remove old zlib files: sudo rm /opt/local/lib/libz*
Download zlib source code from its webpage
Extract the source, and open a terminal in source location
./configure, make and sudo make install
If it still doesn't work, remove ruby and install it again (you can do it with RVM)
Hope it helped you.
You might have x86_64 compiled zlib installed in
/usr/local/opt/zlib/ or alternatively do a brew install zlib
this will install zlib in /usr/local/Cellar/.
Temporary remove libz.* from /usr/local/lib/ into a backup folder.
Do gem install nokogiri -v '<version>' --with-zlib-dir=<zlib directory path from step 1>
Nokogiri must be installed by now. Restore the backup libz again.
It is a macport migration to snow leopard issue, sadly you have to reinstall macports and all the ports to have the right architecture. Read the wiki here: https://trac.macports.org/wiki/Migration

Resources