Linking error : undefined reference to `avahi_alternative_service_name' - c++

in know i need to locate this symbol in library.. I am trying to compile avahi based test code to view services. But i am getting undefined reference toavahi_alternative_service_name'`.. I don't know which library contain this,I am running UBUNTU 12.04. I tried to install several packages but no success.. Any idea
Thanks..
I have following packages installed
dpkg --get-selections | grep avahi
avahi-autoipd install
avahi-daemon install
avahi-utils install
libavahi-cil-dev install
libavahi-client-dev install
libavahi-client3 install
libavahi-client3:i386 install
libavahi-common-data install
libavahi-common-data:i386 install
libavahi-common-dev install
libavahi-common3 install
libavahi-common3:i386 install
libavahi-core7 install
libavahi-glib-dev install
libavahi-glib1 install
libavahi-gobject0 install
libavahi-ui-dev install
libavahi-ui-gtk3-0 install
libavahi-ui0 install
libavahi1.0-cil install
command
gcc -fpermissive testAvahi.c -o testAvahi

Actually needed to locate libraries and then needed to pass them to linker, So follwing command did work for me
gcc -fpermissive testAvahi.c -o testAvahi -L/usr/lib/x86_64-linux-gnu/ -lavahi-client -lavahi-common

if you have a common folder where you place your c++ libraries you can check search for the function using the nm command
something like
cd /usr/lib
nm -AC * | grep avahi_alternative_service_name
The nm utility is available in binutils(sudo apt-get install binutils)

Related

library missing cannot find -lbz2 in arch

while building statically an error
/usr/bin/ld: cannot find -lbz2
I am currently using arch linux. earlier I used ubuntu there I used
sudo apt-get install libbz2-dev
I am new to arch and dont know which library to install and how to find such libraries in future.
Maybe this info be useful:
archlinux:~$ ls /usr/lib/ | grep bz2
libbz2.so
libbz2.so.1
libbz2.so.1.0
libbz2.so.1.0.6
archlinux:~$ locate libbz2
/usr/lib/libbz2.so
/usr/lib/libbz2.so.1
/usr/lib/libbz2.so.1.0
/usr/lib/libbz2.so.1.0.6
/usr/lib32/libbz2.so
/usr/lib32/libbz2.so.1
/usr/lib32/libbz2.so.1.0
/usr/lib32/libbz2.so.1.0.6
I can see that libbz2.a file is missing how to get that?

How can I add python support to vim 7.4 on a Centos 7 box?

I've tried several solutions found on google search, but nothing seems to work. Here is a shot of my vim --version and I currently have python 2.7.5 installed:
Huge version without GUI. Features included (+) or not (-):
+arabic +file_in_path +mouse_sgr +tag_binary
+autocmd +find_in_path -mouse_sysmouse +tag_old_static
-balloon_eval +float +mouse_urxvt -tag_any_white
-browse +folding +mouse_xterm -tcl
++builtin_terms -footer +multi_byte +terminfo
+byte_offset +fork() +multi_lang +termresponse
+cindent +gettext -mzscheme +textobjects
-clientserver -hangul_input +netbeans_intg +title
-clipboard +iconv +path_extra -toolbar
+cmdline_compl +insert_expand -perl +user_commands
+cmdline_hist +jumplist +persistent_undo +vertsplit
+cmdline_info +keymap +postscript +virtualedit
+comments +langmap +printer +visual
+conceal +libcall +profile +visualextra
+cryptv +linebreak -python +viminfo
+cscope +lispindent -python3 +vreplace
+cursorbind +listcmds +quickfix +wildignore
+cursorshape +localmap +reltime +wildmenu
+dialog_con -lua +rightleft +windows
+diff +menu -ruby +writebackup
+digraphs +mksession +scrollbind -X11
-dnd +modify_fname +signs -xfontset
-ebcdic +mouse +smartindent -xim
+emacs_tags -mouseshape -sniff -xsmp
+eval +mouse_dec +startuptime -xterm_clipboard
+ex_extra -mouse_gpm +statusline -xterm_save
+extra_search -mouse_jsbterm -sun_workshop
+farsi +mouse_netterm +syntax
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
fall-back for $VIM: "/usr/local/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -I/usr/local/include -g - O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -L/usr/local/lib -Wl,--as-needed -o vim -lm -ltinfo - lnsl -ldl
I followed some points on this thread and it got me up and running. I think there are steps you can probably skip, but I have found this to be a working solution:
1) Remove installed vim
yum remove (all things vimish)
2) Remove other vim footprints
find / -name vim
3) Add software collection utility
yum -y install scl-utils
4) Add python repo
rpm -Uvh https://www.softwarecollections.org/en/scls/rhscl/python33/epel-7-x86_64/download/rhscl-python33-epel-7-x86_64.noarch.rpm
4) Install python
yum -y install python33
5) Install gvim
yum install gvim
6) Install vim-enhanced
yum install vim-enhanced.x86_64
7) Install sudo
yum install sudo
In vim do a :echo has('python') and it should return 1 which means you now have python support. **Please be aware that you will be uninstalling sudo if you uninstall vim-minimal. I think you should be okay if you copy your settings from visudo and repost after reinstalling sudo.
8) If the following occurs:
bash: /usr/local/bin/vim: No such file or directory
then do the following commands:
hash vim
vim
Details for this fix at this link

Error using clang to compile c++

I have been trying to compile a simple hello world program in c++ using clang. Now in the past I have been able to do this using the command:
clang -lc++ hello.cpp -o hello
When I try this I get the error:
/usr/bin/ld: cannot find -lc++
Clang: error : linker command failed with exit code 1
If I use g++ it compiles without errors. Why is this problem occurring with clang?
You need to install libc++ library.
Try if are using ubuntu:
sudo bash -c "cat >> /etc/apt/sources.list" << LLVMAPT
# LLVM
deb http://llvm.org/apt/trusty/ llvm-toolchain-trusty main
deb-src http://llvm.org/apt/trusty/ llvm-toolchain-trusty main
# 3.5
deb http://llvm.org/apt/trusty/ llvm-toolchain-trusty-3.5 main
deb-src http://llvm.org/apt/trusty/ llvm-toolchain-trusty-3.5 main
# 3.6
deb http://llvm.org/apt/trusty/ llvm-toolchain-trusty-3.6 main
deb-src http://llvm.org/apt/trusty/ llvm-toolchain-trusty-3.6 main
LLVMAPT
wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key|sudo apt-key add -
sudo apt-get update -y
sudo apt-get install -y clang-3.6 lldb-3.6 libc++-dev libc++abi-dev
If the script above doesnt work or you do not use ubuntu then please check this websites to download that library:
http://libcxx.llvm.org/
http://libcxx.llvm.org/docs/BuildingLibcxx.html
Clang compiles C language and Clang++ compiles C++. Those are different languages, so you need a separate compiler for each of them.
Some time ago I was having trouble with this as well. I tried linking loads of libraries (-lstdc++ etc), building stdlib from source, etc, but nothing worked. This was a judge problem until I realized that I had to use clang++.
So you too, you need clang++, not clang.

Linking boost::asio using terminal

I am trying to link boost::asio using terminal (I'm also using a text editor).
What I tried
I did some researches on Internet (I didn't found nothing about my distro) - I found I must install that library by executing the following command on the terminal:
sudo pacman -S libboost-all-dev
This is the output I get:
error: the following package was not found: libboost-all-dev
Final question
How can I install and link correctly boost::asio with my .cpp file?
Notes:
I'm using Archlinux
To find a package in Arch Linux, do:
sudo pacman -Ss boost
This will list packages with the string boost. Or, you can look up on the package website: https://www.archlinux.org/packages/extra/x86_64/boost/
One thing you should understand about boost is that a majority of its modules are header-only; if the linker complains about undefined references then you would have to link the required files. To link boost-asio, you would do
g++ -lboost-system <source> <exe>
How to install boost in Arch Linux
You cannot link libraries inside your *.cpp files. You should enumerate required libraries using the -l option in the g++ command line.
g++ -lboos-asio -lboost-system myfile.cpp -o myapp

where are the opengl libraries get stored on ubuntu : i need this to mention in my make file

where are the opengl libraries get stored on ubuntu9.10 : i need this to mention in my make file and what are all the link files i need to mention
Install these to get OpenGL working:
sudo apt-get install mesa-common-dev
sudo apt-get install freeglut3
sudo apt-get install freeglut3-dev
The OpenGL files should be in:
/usr/include/GL/
The Terminal (Compiler) reads (e.g. g++) from:
/usr/bin/
Compile like this (you might need to link more libraries, but test this):
g++ filename -lglut -lGL -lGLU
/usr/lib/libGL.so
link with -lGL
You should not need to mention their location explicitly in your Makefile since they should be in the standard library search path (probably in /usr/lib).
Like sisis wrote you should just need to add -lGL to the linker flags to link against libGL.so which might actually come from different sources: mesa or some fancy graphics card driver.
They're part of mesa, as libGL*.so.* and the like, usually in /usr/lib*.