Using Boost Library on an example code causing Undefined symbols error? - c++

I wish to run an example code g++ reference_counted.cpp, but the program produced an error
Undefined symbols for architecture x86_64:
"boost::system::system_category()", referenced from:
__static_initialization_and_destruction_0(int, int) in ccD1hl7z.o
boost::system::error_code::error_code() in ccD1hl7z.o
boost::asio::error::get_system_category() in ccD1hl7z.o
"boost::system::generic_category()", referenced from:
__static_initialization_and_destruction_0(int, int) in ccD1hl7z.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
Running brew doctor produces the following warnings, but it's unclear what is causing the failure. How can this be fixed?
Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.
Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:
/opt/local/bin/curl-config
/opt/local/bin/freetype-config
/opt/local/bin/icu-config
/opt/local/bin/libpng-config
/opt/local/bin/libpng15-config
/opt/local/bin/nc-config
/opt/local/bin/ncurses5-config
/opt/local/bin/ncursesw5-config
/opt/local/bin/pcre-config
/opt/local/bin/ppl-config
/opt/local/bin/python-config
/opt/local/bin/python2.7-config
/opt/local/bin/xml2-config
Warning: /Library/Frameworks/Mono.framework detected
This can be picked up by CMake's build system and likely cause the build to
fail. You may need to move this file out of the way to compile CMake.
Warning: You have MacPorts or Fink installed:
/opt/local/bin/port
This can cause trouble. You don't have to uninstall them, but you may want to
temporarily move them out of the way, e.g.
sudo mv /opt/local ~/macports
Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected dylibs:
/usr/local/lib/libasan.0.dylib
/usr/local/lib/libatomic.1.dylib
/usr/local/lib/libgcc_ext.10.4.dylib
/usr/local/lib/libgcc_ext.10.5.dylib
/usr/local/lib/libgcc_s.1.dylib
/usr/local/lib/libgfortran.3.dylib
/usr/local/lib/libgomp.1.dylib
/usr/local/lib/libitm.1.dylib
/usr/local/lib/libmca_common_sm.3.dylib
/usr/local/lib/libmpi.1.dylib
/usr/local/lib/libmpi_cxx.1.dylib
/usr/local/lib/libmpi_f77.1.dylib
/usr/local/lib/libompitrace.0.dylib
/usr/local/lib/libopen-pal.4.dylib
/usr/local/lib/libopen-rte.4.dylib
/usr/local/lib/libopen-trace-format.1.dylib
/usr/local/lib/libotfaux.0.dylib
/usr/local/lib/libquadmath.0.dylib
/usr/local/lib/libssp.0.dylib
/usr/local/lib/libstdc++.6.dylib
/usr/local/lib/libvt-hyb.0.dylib
/usr/local/lib/libvt-mpi-unify.0.dylib
/usr/local/lib/libvt-mpi.0.dylib
/usr/local/lib/libvt-mt.0.dylib
/usr/local/lib/libvt.0.dylib
Warning: Unbrewed .la files were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected .la files:
/usr/local/lib/libasan.la
/usr/local/lib/libatomic.la
/usr/local/lib/libgfortran.la
/usr/local/lib/libgmp.la
/usr/local/lib/libgomp.la
/usr/local/lib/libitm.la
/usr/local/lib/libmca_common_sm.la
/usr/local/lib/libmpc.la
/usr/local/lib/libmpfr.la
/usr/local/lib/libmpi.la
/usr/local/lib/libmpi_cxx.la
/usr/local/lib/libmpi_f77.la
/usr/local/lib/libmpi_f90.la
/usr/local/lib/libompitrace.la
/usr/local/lib/libopen-pal.la
/usr/local/lib/libopen-rte.la
/usr/local/lib/libopen-trace-format.la
/usr/local/lib/libotfaux.la
/usr/local/lib/libquadmath.la
/usr/local/lib/libssp.la
/usr/local/lib/libssp_nonshared.la
/usr/local/lib/libstdc++.la
/usr/local/lib/libsupc++.la
/usr/local/lib/libvt-hyb.la
/usr/local/lib/libvt-mpi-unify.la
/usr/local/lib/libvt-mpi.la
/usr/local/lib/libvt-mt.la
/usr/local/lib/libvt-pomp.la
/usr/local/lib/libvt.la
Warning: Unbrewed .pc files were found in /usr/local/lib/pkgconfig.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected .pc files:
/usr/local/lib/pkgconfig/ompi-c.pc
/usr/local/lib/pkgconfig/ompi-cxx.pc
/usr/local/lib/pkgconfig/ompi-f77.pc
/usr/local/lib/pkgconfig/ompi-f90.pc
/usr/local/lib/pkgconfig/ompi.pc
/usr/local/lib/pkgconfig/orte.pc
Warning: Unbrewed static libraries were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected static libraries:
/usr/local/lib/libatomic.a
/usr/local/lib/libgfortran.a
/usr/local/lib/libgmp.a
/usr/local/lib/libgomp.a
/usr/local/lib/libitm.a
/usr/local/lib/libmpc.a
/usr/local/lib/libmpfr.a
/usr/local/lib/libmpi_f90.a
/usr/local/lib/libopen-trace-format.a
/usr/local/lib/libotfaux.a
/usr/local/lib/libquadmath.a
/usr/local/lib/libssp.a
/usr/local/lib/libssp_nonshared.a
/usr/local/lib/libstdc++.a
/usr/local/lib/libsupc++.a
/usr/local/lib/libvt-hyb.a
/usr/local/lib/libvt-mpi-unify.a
/usr/local/lib/libvt-mpi.a
/usr/local/lib/libvt-mt.a
/usr/local/lib/libvt-pomp.a
/usr/local/lib/libvt.a
Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
python
Warning: You have uncommitted modifications to Homebrew
If this a surprise to you, then you should stash these modifications.
Stashing returns Homebrew to a pristine state but can be undone
should you later need to do so for some reason.
cd /usr/local/Library && git stash && git clean -d -f
Warning: Some directories in your path end in a slash.
Directories in your path should not end in a slash. This can break other
doctor checks. The following directories should be edited:
/usr/local/facebook/arcanist/bin/
Warning: Homebrew's sbin was not found in your PATH but you have installed
formulae that put executables in /usr/local/sbin.
Consider setting the PATH for example like so
echo export PATH="/usr/local/sbin:$PATH" >> ~/.bash_profile
Warning: Your Xcode (4.6.2) is outdated
Please install Xcode 5.0.
467502-mitll:Boost ch24515$ echo export PATH="/usr/local/bin:$PATH" >> ~/.bash_profile
467502-mitll:Boost ch24515$ g++ reference_counted.cpp
Undefined symbols for architecture x86_64:
"boost::system::system_category()", referenced from:
__static_initialization_and_destruction_0(int, int) in ccmaaqd0.o
boost::system::error_code::error_code() in ccmaaqd0.o
boost::asio::error::get_system_category() in ccmaaqd0.o
"boost::system::generic_category()", referenced from:
__static_initialization_and_destruction_0(int, int) in ccmaaqd0.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
467502-mitll:Boost ch24515$ brew doctor
Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.
Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:
/opt/local/bin/curl-config
/opt/local/bin/freetype-config
/opt/local/bin/icu-config
/opt/local/bin/libpng-config
/opt/local/bin/libpng15-config
/opt/local/bin/nc-config
/opt/local/bin/ncurses5-config
/opt/local/bin/ncursesw5-config
/opt/local/bin/pcre-config
/opt/local/bin/ppl-config
/opt/local/bin/python-config
/opt/local/bin/python2.7-config
/opt/local/bin/xml2-config
Warning: /Library/Frameworks/Mono.framework detected
This can be picked up by CMake's build system and likely cause the build to
fail. You may need to move this file out of the way to compile CMake.
Warning: You have MacPorts or Fink installed:
/opt/local/bin/port
This can cause trouble. You don't have to uninstall them, but you may want to
temporarily move them out of the way, e.g.
sudo mv /opt/local ~/macports
Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected dylibs:
/usr/local/lib/libasan.0.dylib
/usr/local/lib/libatomic.1.dylib
/usr/local/lib/libgcc_ext.10.4.dylib
/usr/local/lib/libgcc_ext.10.5.dylib
/usr/local/lib/libgcc_s.1.dylib
/usr/local/lib/libgfortran.3.dylib
/usr/local/lib/libgomp.1.dylib
/usr/local/lib/libitm.1.dylib
/usr/local/lib/libmca_common_sm.3.dylib
/usr/local/lib/libmpi.1.dylib
/usr/local/lib/libmpi_cxx.1.dylib
/usr/local/lib/libmpi_f77.1.dylib
/usr/local/lib/libompitrace.0.dylib
/usr/local/lib/libopen-pal.4.dylib
/usr/local/lib/libopen-rte.4.dylib
/usr/local/lib/libopen-trace-format.1.dylib
/usr/local/lib/libotfaux.0.dylib
/usr/local/lib/libquadmath.0.dylib
/usr/local/lib/libssp.0.dylib
/usr/local/lib/libstdc++.6.dylib
/usr/local/lib/libvt-hyb.0.dylib
/usr/local/lib/libvt-mpi-unify.0.dylib
/usr/local/lib/libvt-mpi.0.dylib
/usr/local/lib/libvt-mt.0.dylib
/usr/local/lib/libvt.0.dylib
Warning: Unbrewed .la files were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected .la files:
/usr/local/lib/libasan.la
/usr/local/lib/libatomic.la
/usr/local/lib/libgfortran.la
/usr/local/lib/libgmp.la
/usr/local/lib/libgomp.la
/usr/local/lib/libitm.la
/usr/local/lib/libmca_common_sm.la
/usr/local/lib/libmpc.la
/usr/local/lib/libmpfr.la
/usr/local/lib/libmpi.la
/usr/local/lib/libmpi_cxx.la
/usr/local/lib/libmpi_f77.la
/usr/local/lib/libmpi_f90.la
/usr/local/lib/libompitrace.la
/usr/local/lib/libopen-pal.la
/usr/local/lib/libopen-rte.la
/usr/local/lib/libopen-trace-format.la
/usr/local/lib/libotfaux.la
/usr/local/lib/libquadmath.la
/usr/local/lib/libssp.la
/usr/local/lib/libssp_nonshared.la
/usr/local/lib/libstdc++.la
/usr/local/lib/libsupc++.la
/usr/local/lib/libvt-hyb.la
/usr/local/lib/libvt-mpi-unify.la
/usr/local/lib/libvt-mpi.la
/usr/local/lib/libvt-mt.la
/usr/local/lib/libvt-pomp.la
/usr/local/lib/libvt.la
Warning: Unbrewed .pc files were found in /usr/local/lib/pkgconfig.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected .pc files:
/usr/local/lib/pkgconfig/ompi-c.pc
/usr/local/lib/pkgconfig/ompi-cxx.pc
/usr/local/lib/pkgconfig/ompi-f77.pc
/usr/local/lib/pkgconfig/ompi-f90.pc
/usr/local/lib/pkgconfig/ompi.pc
/usr/local/lib/pkgconfig/orte.pc
Warning: Unbrewed static libraries were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected static libraries:
/usr/local/lib/libatomic.a
/usr/local/lib/libgfortran.a
/usr/local/lib/libgmp.a
/usr/local/lib/libgomp.a
/usr/local/lib/libitm.a
/usr/local/lib/libmpc.a
/usr/local/lib/libmpfr.a
/usr/local/lib/libmpi_f90.a
/usr/local/lib/libopen-trace-format.a
/usr/local/lib/libotfaux.a
/usr/local/lib/libquadmath.a
/usr/local/lib/libssp.a
/usr/local/lib/libssp_nonshared.a
/usr/local/lib/libstdc++.a
/usr/local/lib/libsupc++.a
/usr/local/lib/libvt-hyb.a
/usr/local/lib/libvt-mpi-unify.a
/usr/local/lib/libvt-mpi.a
/usr/local/lib/libvt-mt.a
/usr/local/lib/libvt-pomp.a
/usr/local/lib/libvt.a
Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
python
Warning: You have uncommitted modifications to Homebrew
If this a surprise to you, then you should stash these modifications.
Stashing returns Homebrew to a pristine state but can be undone
should you later need to do so for some reason.
cd /usr/local/Library && git stash && git clean -d -f
Warning: Some directories in your path end in a slash.
Directories in your path should not end in a slash. This can break other
doctor checks. The following directories should be edited:
/usr/local/facebook/arcanist/bin/
Warning: Homebrew's sbin was not found in your PATH but you have installed
formulae that put executables in /usr/local/sbin.
Consider setting the PATH for example like so
echo export PATH="/usr/local/sbin:$PATH" >> ~/.bash_profile
Warning: Your Xcode (4.6.2) is outdated
Please install Xcode 5.0.

Add -lboost_system to your linker flags:
g++ reference_counted.cpp -lboost_system

You need to link your application to boost_system library. I think for asio you also need boost_thread, so in summary it's:
g++ -lboost_system -lboost_thread reference_counted.cpp

Related

Makefile cannot install code due to previous installation of earlier version

I have previously installed some code using a makefile. Now, I'm installing an updated version of the code (with some added features). The problem is that when I run make clean; make class the following error comes up:
ld: 13 duplicate symbols for architecture x86_64
collect2: error: ld returned 1 exit status
make: *** [class] Error 1
I believe this is because it is trying to install the same files in the same directories as the previous installation. I've tried make uninstall on the other installation, but that just returns make: *** No rule to make target `uninstall'. Stop.
Is this the reason for the error? If so, do I have to manually uninstall the previously installed files? And how do I do that?
Thanks a lot for any help!
We need your Makefile for this.
Clean and other commands are defined inside it, make sure that the rules are correctly cleaning the files.

Apps cannot detect C++ poco even though I have installed it

I want to be able to make and run this particular library on my computer. Currently going through the INSTALL file. I am currently at the point:
After extracting the Poco (Complete Edition) source archive, the configure
script should be called with the following parameters:
./configure --omit=Crypto,Net,NetSSL_OpenSSL,Data/ODBC,Data/MySQL \
--no-tests --no-samples
This line avoids building the parts of Poco which are dependent on third-party
libraries, and are not required for openBliSSART.
You can also specify a prefix where Poco should be installed, but in most cases
you should leave the default /usr/local.
I can't seem to run the options, so I simply ran ./configure, this seemed to have worked till the point where I encountered:
checking for fftw_plan_dft_r2c_1d in -lfftw3... yes
checking for Poco (Enterprise)... no
configure: error: Need Poco Enterprise v1.3.6+!
But the fact is, that I have installed Poco already on the system through a brew install poco and downloaded the library from their source website and compiled it ground up. looking back at INSTALL:
Depending on where you have installed Poco, you may have to set the
LD_LIBRARY_PATH environment variable to contain the Poco "lib" directory,
or run the ldconfig tool. The following lines work with Ubuntu and openSUSE
($ indicates the shell prompt):
$ sudo sh -c 'echo <prefix>/lib > /etc/ld.so.conf.d/poco.conf'
$ sudo ldconfig
where <prefix> is the Poco install prefix (by default /usr/local).
Now when I do a simple sudo find / -name poco, I get:
/usr/local/var/homebrew/linked/poco
/usr/local/opt/poco
/usr/local/Cellar/poco
find: /private/var/db/ConfigurationProfiles/Store: Operation not permitted
find: /private/var/folders/pq/xchc5hxj02d754txf8nml5f00000gn/0/SafariFamily: Operation not permitted
find: /private/var/folders/pq/xchc5hxj02d754txf8nml5f00000gn/0/com.apple.LaunchServices.dv: Operation not permitted
find: /private/var/folders/pq/xchc5hxj02d754txf8nml5f00000gn/0/com.apple.nsurlsessiond: Operation not permitted
find: /private/var/folders/pq/xchc5hxj02d754txf8nml5f00000gn/0/com.apple.routined: Operation not permitted
find: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000y800007k/0/com.apple.nsurlsessiond: Operation not permitted
find: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000s4000069/0/com.apple.nsurlsessiond: Operation not permitted
find: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000s4000069/0/com.apple.routined: Operation not permitted
/Users/sharanduggirala/Library/Logs/Homebrew/poco
/Users/sharanduggirala/Documents/of_v0.9.8_osx_release/libs/poco
/Users/sharanduggirala/Documents/of_v0.9.8_osx_release/scripts/apothecary/formulas/poco
find: /dev/fd/3: Not a directory
find: /dev/fd/4: Not a directory
Also, it looks like while building poco, I did a ./configure --static. Would this have affected my compilation? How do I link this library?
I have already used the command ./configure --with-poco-prefix=/usr/local/opt/poco which doesn't really change anything.
Notes relating to S.M.'s Answer
I tried this, but got the error:
brew install poco --with-static ⏎
==> Downloading https://pocoproject.org/releases/poco-1.9.0/poco-1.9.0-all.tar.gz
######################################################################## 100.0%
Error: SHA256 mismatch
Expected: 028de410fc78d5f9b1ff400e93ec3d59b9e55a0cbbf0d8fec04636882b72ea45
Actual: 0387bf0f9d313e2311742e1ad0b64e07f2f3e76039eed20e3b9aa9951b88e187
Archive: /Users/sharanduggirala/Library/Caches/Homebrew/poco-1.9.0.tar.gz
To retry an incomplete download, remove the file above.
I also tried:
./configure --static ⏎
configure: error: unrecognized option: `--static'
Try `./configure --help' for more information
Do not install poco from sources. Use brew install poco. If you want the same like ./configure --static use brew install poco --with-static.

Link errors after pod install followed by attempted uninstall

I installed 'CoreStore' using cocoapods. one of the installed source (GCD) had over 30 compilation errors. I attempted to uninstall the module by running pod install on a Podfile without the module. However this is resulting in a link error ld: framework not found Pods_QwikFile
clang: error: linker command failed with exit code 1 (use -v to see invocation) .
How do I attempt to edit the link commands in Build Settings
Is it easier for me to edit the Link file directly. If so where do I find the link file
In the Build Phases part of the Target, I found clear reference to pod. I deleted the 2 entries and that eliminated the link errors.

dyn.load error linking a package with Rcpp

I've made an R package with Rcpp, to use the methods of a library I programmed in c++.
I've R running on the last version:
R version 3.2.5 (2016-04-14)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04 LTS
I'm executing the following instruction to install my package:
> install.packages("mypackage", repos = NULL)
The package compiles well, I have the .o files of my source code, but in the linking phase I got the error:
* installing *source* package ‘rbdd’ ...
** libs
make: No se hace nada para 'all'.
installing to /home/sergio/R/x86_64-pc-linux-gnu-library/3.2/mypackage/libs
** R
** preparing package for lazy loading
** help
Warning: /home/sergio/R/mypackage/man/mypackage-package.Rd:27: All text must be in a section
Warning: /home/sergio/R/mypackage/man/mypackage-package.Rd:28: All text must be in a section
*** installing help indices
** building package indices
** testing if installed package can be loaded
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/home/sergio/R/x86_64-pc-linux-gnu-library/3.2/mypackage/libs/mypackage.so':
/home/sergio/R/x86_64-pc-linux-gnu-library/3.2/mypackage/libs/mypackage.so: undefined symbol: _ZN4cudd12defaultErrorENSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE
Error: loading failed
Ejecución interrumpida
ERROR: loading failed
mypackge.so is created in the src folder of my package.
I've got a Makevars file (in src, too) with the following content:
PKG_CPPFLAGS=-I./buddy-2.5/src -I./cudd-3.0.0/cudd -I./cudd-3.0.0/mtr -I./cudd-3.0.0/cplusplus -I./cudd-3.0.0/dddmp -I./cudd-3.0.0/util -I./cudd-3.0.0 -isystem /usr/include/c++/v1 -std=c++11
PKG_LIBS=-lc++ -L/lib
and my NAMESPACE file has the lines:
useDynLib(mypackage)
exportPattern("^[[:alpha:]]+")
importFrom(Rcpp, evalCpp)
Someone knows how to solve this problem?
I am a little concerned about
PKG_LIBS=-lc++ -L/lib
Did you really mean /lib? If it is your library, a more common place would be /usr/local/lib which is also search by default.
But, and that is a BIG but, you also need to understand what you need to do for ldconfig for the proper setup of libfoo.so, libfoo.so.$MAJOR and so on. I taught myself that many moons ago from a Linux HOWTO.
If and when that is setup right, you can link it to R via Rcpp. Otherwise maybe stick with system libraries, or package-local static libraries. That approach will also make your package more portable.
The problem was I am consumming external libs, and I must compile it and execute ldconfig before compile my R library.

Linking error with `libopencv_highgui.so` under Ubuntu 14.04, strange result with `libtiff.so.5`

Problem
I'm compiling the deep learning library Caffe in Ubuntu 14.04(64 bit).
OpenCV(Version: 2.4.8+dfsg1-2ubuntu1) is installed from ubuntu packages server with :
sudo apt-get install libopencv-dev
Compile Caffe with CMake 2.8.
Linking error:
Linking CXX executable caffe-
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so.2.4.8: undefined reference to `TIFFOpen#LIBTIFF_4.0'
Infomation
It seems some symbols of TIFF library were not found. I made some effort to find the reason(without luck). Here's some infomation about the libraries.
TIFF library linked by libopencv_highgui.so.2.4.8
$ ldd libopencv_highgui.so.2.4.8 | grep tiff
libtiff.so.5 => /usr/lib/x86_64-linux-gnu/libtiff.so.5 (0x00007f978313b000)
Import symbols of libopencv_highgui.so.2.4.8
$ readelf -s libopencv_highgui.so.2.4.8 |grep TIFFOpen
62: 0000000000000000 0 FUNC GLOBAL DEFAULT UND TIFFOpen#LIBTIFF_4.0 (9)
Note: There is one single # in the symbol names.
$ nm -D libopencv_highgui.so.2.4.8| grep TIFFOpen
U TIFFOpen
Export symbols of libtiff.so.5:
$ nm -D /usr/lib/x86_64-linux-gnu/libtiff.so.5
0000000000000000 A LIBTIFF_4.0
...
00000000000429f0 T TIFFOpen
...
$ readelf -s /usr/lib/x86_64-linux-gnu/libtiff.so.5|grep TIFFOpen
99: 00000000000429f0 239 FUNC GLOBAL DEFAULT 12 TIFFOpen##LIBTIFF_4.0
Note: There are two #(##) in the symbol names.
My confusion
Is it because libtiff.so.5 has ## in the symbol names instead of # that made the linking error
libopencv_highgui.so.2.4.8: undefined reference to 'TIFFIsTiled#LIBTIFF_4.0'
What's the difference between # and ## in symbol names?
What's the meaning of the suffix LIBTIFF_4.0 of symbols names in libtiff.so.5?
Many people said it's because OpenCV need libtiff4-dev which is not provided by Ubuntu 14.04. Then why the Ubuntu guys put a broken package on the package server.
How to solve the linking problem?
I'm not a profession on compiling and linking. Sorry for such a long post. Just what to provide enough infomation for you guys to help me.
Appreciate for any suggestions.
P.S. If you need more infomation of those libs, feel free to say in the comment.
I had similiar problems and it was due to Anaconda messing up
I simply had to execute the following command:
conda remove libtiff
I installed opecv via:
sudo apt-get install opencv-dev
and libtiff via:
sudo apt-get install libtiff4-dev
Old question but still without an answer so here it goes (I came across the same error today):
That is not why the linker fails. If it was able to find libtiff.so.5 it would have linked just fine.
# vs ## is just a way to track difference versions of the function. More details here https://sourceware.org/binutils/docs/ld/VERSION.html
LIBTIFF_4.0 means it is that specific version of TIFFOpen that is required when dynamically loading the symbol.
That is probably a good way to fix the issue. It's likely that without the libtiff-dev package the libtiff.so symbolic linked file doesn't exit in /usr/lib/x86_64-linux-gnu/ so the linker will not be able to find the library (it knows nothing about libtiff.so.5 unless you tell it explicitly).
a. You may be able to test 4. by invoking the linker command line yourself from the command line. If you compiled caffe with cmake you'll find the linker command under tools/CMakeFiles/caffe.bin.dir/link.txt. Just add /usr/lib/x86_64-linux-gnu/libtiff.so.5 to the command line and it should work.
b. Alternatively manually create the symbolic link /usr/lib/x86_64-linux-gnu/libtiff.so
c. install the dev package, which should do that for you. Also make sure that cmake knows about /usr/lib/x86_64-linux-gnu/ by specify extra library path
d. check that there are no other libtiff.so library lurking in your system if previous steps don't work (e.g. anconda type thing)
Hope it helps.
Install libtiff4-dev:
sudo apt-get install libtiff4-dev
This is what worked for me:
Go to Tiff website, and follow the instructions to download Tiff and build it, and install it. Then in your make file add this:
-L/[path to libtiff.so] -ltiff
If you want to know the path to the libtiff.so
try this:
sudo find /usr/ -name libtiff.so
As you can see in
62: 0000000000000000 0 FUNC GLOBAL DEFAULT UND TIFFOpen#LIBTIFF_4.0 (9)
there's an UND which I think means undefined. I guess when ubuntu is producing libopencv_highgui, it fails to find TIFFOpen#LIBTIFF 4.0. So I think I should have libtiff at hand and compile libopencv_xxx again.
I like to include things in conda. So I install opencv again with conda, and point my LIBRARY_PATH to the conda lib directory and things go well.