LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-01-2013, 08:26 AM   #1
GATTACA
Member
 
Registered: Feb 2002
Location: USA
Distribution: Fedora, CENTOS
Posts: 209

Rep: Reputation: 32
Compiling with POCO on C++: /usr/bin/ld cannot find -lPocoFoundationd


Hi.
Newbie question here so I apologize if this is a silly question.

I'm trying to use the Runnable and Threadpool libriares in POCO in my C++ project.
I'm working on CentOS 6.3 (64-bit) using g++ version 4.4.6 20120305 (Red Hat 4.4.6-4)

I've written my code based upon the online examples (correctly I think).

My problem is when compiling.
I get the following error: /usr/bin/ld: cannot find -lPocoFoundationd

This seems strange to me since the compile command specifies the correct path to the libraries and header files.

I installed the POCO project locally (I don't have root access to our server).
Here is how installed POCO:
Code:
cd $HOME/workspace/xProject
tar xzf poco-1.4.5.tar.gz
cd poco-*
./configure --prefix=$HOME/workspace/xProject/poco.lib
make
make install
The libraries are there now in $HOME/workspace/xProject/poco.lib (which is one directory up from the project's source code folder):
Code:
ls ../poco.lib/lib/*.so

../poco.lib/lib/libPocoFoundationd.so
../poco.lib/lib/libPocoFoundation.so
../poco.lib/lib/libPocoNetd.so
../poco.lib/lib/libPocoNet.so
../poco.lib/lib/libPocoUtild.so
../poco.lib/lib/libPocoUtil.so
../poco.lib/lib/libPocoXMLd.so
../poco.lib/lib/libPocoXML.so
Here are the commands I issued to compile the program (through a Makefile):

Code:
g++ -O2 -Wall -static -I../poco.lib/include -L../poco.lib/lib -lPocoFoundationd -lPocoFoundation -c xClass.cpp
g++ -O2 -Wall -static -I../poco.lib/include -L../poco.lib/lib -lPocoFoundationd -lPocoFoundation -c main.cpp
g++ -O2 -Wall -static -I../poco.lib/include -L../poco.lib/lib -lPocoFoundationd -lPocoFoundation -c globals.cpp
g++ -O2 -Wall -static -I../poco.lib/include -L../poco.lib/lib -lPocoFoundationd -lPocoFoundation -o finalApp.exe  xClass.o main.o globals.o
And then I get this error:
Code:
g++ -O2 -Wall -static -I../poco.lib/include -L../poco.lib/lib -lPocoFoundationd -lPocoFoundation -o  finalApp.exe  xClass.o main.o globals.o
/usr/bin/ld: cannot find -lPocoFoundationd
collect2: ld returned 1 exit status
make: *** [finalApp.exe] Error 1
Any suggestions what I'm doing wrong?

Thanks in advance for any and all help.
Happy New Year.
 
Old 01-01-2013, 08:59 AM   #2
a4z
Senior Member
 
Registered: Feb 2009
Posts: 1,727

Rep: Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742
this
-lPocoFoundationd -lPocoFoundation

looks like you are linking against 2 times the same library
where one of them (with d postifx) is the debug version and the other one the release version
thats not a good idea, decide for one

you my also research the -static flag that you send to gcc
(On systems that support dynamic linking, this prevents linking with the shared libraries. On other systems, this option has no effect.)

*.so are dynamic libraries
 
Old 01-01-2013, 09:33 AM   #3
GATTACA
Member
 
Registered: Feb 2002
Location: USA
Distribution: Fedora, CENTOS
Posts: 209

Original Poster
Rep: Reputation: 32
Thanks for the quick reply!

I removed the -lPocoFoundationd library to no effect.
I still get the same error:
Code:
/usr/bin/ld: cannot find -lPocoFoundation
You were right about the -static flag though.
Removing the -static flag results in successful compilation, but not an executable program. Here is the error I get now:
Code:
$ ./finalApp.exe

./finalApp.exe: error while loading shared libraries: libPocoFoundation.so.15: cannot open shared object file: No such file or directory
I'm thinking I have to build the POCO library to produce static libraries instead of dynamic ones.

Any suggestions?
Their documentation on this point is difficult to find (at least for me).
 
Old 01-01-2013, 09:50 AM   #4
a4z
Senior Member
 
Registered: Feb 2009
Posts: 1,727

Rep: Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742
you have an executable program
when you execute your binary, the system needs to know where to find the required libraries

if you have libraries in non default locations, like your poco libs, you need to inform you environment about additional directories where to look at

export LD_LIBRARY_PATH=/path/to/poco/libs
./theapp

then the system will look also in the locations specified in the LD_LIBRARY_PATH variable for required libraries

search for LD_LIBRARY_PATH for more information about that topic
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Error: Cannot find 'ssh-keygen' in '/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin' venu.navat Linux - Software 3 03-08-2012 04:00 AM
Compiling error: /usr/bin/ld: cannot find -lexpat1 lombaardcj Linux - Newbie 1 05-11-2011 02:26 AM
troubles compiling c++ on FC6: /usr/bin/ld: cannot find -lXm michael123 Programming 5 09-19-2008 11:55 AM
Compiling error /usr/bin/ld: cannot find -ltclstub84 OlRoy *BSD 7 01-26-2007 04:24 PM
Compiling Evas (E17) - /usr/bin/ld: cannot find -lvga victorhooi Linux - Software 1 10-20-2005 04:33 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration