ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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:
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:
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.
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.
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>
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.