LinuxQuestions.org
Review your favorite Linux distribution.
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 03-26-2013, 08:25 PM   #1
ams_pedro
LQ Newbie
 
Registered: Mar 2013
Posts: 2

Rep: Reputation: Disabled
Issue creating dynamic libraries


Hello,

I am developing an evolutionary program which needs to test a specific program many times, under different configurations.
I decided to use dynamic linking in order to speed up the testing process and up to this point everything was ok.

I used a script to run make and generate the new library, which was then included in the main program in order to be tested.
In a previous version this seemed to work just fine.

However, I had to perform a few changes so that the main program was executed in a process, and another program would load the linked dynamic library (used sockets to perform Inter Process Communication).

The thing is, strangely, after sometime, around 1000 recompilations of the dynamic library, it fails, saying the following:

gcc -c -m64 -O -Wall -fPIC -c -I /usr/local/include -Os DFuncDarwin.c
gcc -o pizza DFuncDarwin.o Misc.o --trace --shared -Wl,--dynamic-linker=/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 -o dfuncDarwin.so.1.0 -lm
/usr/bin/ld: cannot find /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
collect2: ld returned 1 exit status

make: *** [pizza] Error 1
BEGINING GEN 3 DUDE 95

I have no Idea why does this happen... and I could not find any answer. It works for so many cases, and then it fails...

Does any body has a clue about this ???

I would really appreciate...

I can improve the description if needed...

Thanks
 
Old 03-27-2013, 04:15 AM   #2
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,541

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Perhaps you are attempting to build on a system where the file '/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2' does not exist. For example, I have that file under Kubuntu 12.04, but not under Fedora 16. A strong hint is:
Code:
/usr/bin/ld: cannot find /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
Frankly, I've never seen the option -Wl,dynamic-linker used. Can you elaborate as to why you think it is necessary to use this option to build your dynamic library?

Last edited by dwhitney67; 03-27-2013 at 04:20 AM.
 
Old 03-27-2013, 04:39 AM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,930

Rep: Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321
I do not understand why do you have two -o <something> options, and why didn't you try -ldl instead of -Wl,--dynamic-linker=/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2. Also -I /usr/local/include is usually not required.
 
Old 03-27-2013, 06:37 PM   #4
ams_pedro
LQ Newbie
 
Registered: Mar 2013
Posts: 2

Original Poster
Rep: Reputation: Disabled
The thing is, I do call the script that compiles the dynamic library around 1000 times, in runtime. But then it suddenly fails to find the file that it has used up until then. So the file must be there, but something is preventing to use it after some time ...

Well pan64, I guess you are right, I built that over some old code, and it was working ok, so I just letted it be.
I am going to remove the unnecessary -o <something>

The othe option:

-Wl,--dynamic-linker=/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2

I saw somewhere on the web that I thought it could help, but it didn't. I believe I am going to remove it.

I will clean it up...


I have tested it again, and a new error messages came out this time:

gcc -c -m64 -O -Wall -fPIC -c -I /usr/local/include -Os DFuncDarwin.c
gcc -o pizza DFuncDarwin.o --trace --shared -Wl,--dynamic-linker=/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 -o dfuncDarwin.so.1.0 -lm
BEGINING GEN 3 DUDE 101
echo> 1 3 101 0.001233FITNESS VALUE : 0.001233
TERMINATING GEN 3 DUDE 101
gcc -c -m64 -O -Wall -fPIC -c -I /usr/local/include -Os DFuncDarwin.c
gcc -o pizza DFuncDarwin.o --trace --shared -Wl,--dynamic-linker=/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 -o dfuncDarwin.so.1.0 -lm
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find /usr/lib/gcc/x86_64-linux-gnu/4.4.6/crtendS.o: Too many open files
/usr/bin/ld: cannot find /usr/lib/gcc/x86_64-linux-gnu/4.4.6/../../../x86_64-linux-gnu/crtn.o: Too many open files
collect2: ld returned 1 exit status
make: *** [pizza] Error 1
BEGINING GEN 3 DUDE 102
Server closed connection

With this new information I was able to find the cause for the error.

I was using UNIX sockets to perform Inter process comunication. In the server I was not adeuately closing the socket that was receiving the client's connection. As it ran too many times, it reached the limmit of FDs. Then, when trying to recompile the Dynamic library, it simply failed because it could not open more FDs.

So there was a leack.

Solved
 
  


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
static and dynamic libraries nesta Programming 11 09-04-2011 08:36 PM
Thread limits in dynamic libraries as opposed to static libraries pmkenny1234 Linux - Software 0 04-26-2011 02:22 PM
possibly a dynamic linking issue (xerces libraries) Omni Programming 2 09-18-2006 03:31 PM
Dynamic link libraries eshwar_ind Programming 1 05-09-2004 11:02 PM
linux dynamic libraries aizkorri Programming 4 10-09-2002 03:26 AM

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

All times are GMT -5. The time now is 06:21 PM.

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