LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-27-2016, 06:02 PM   #1
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,257

Rep: Reputation: 44
Question Flex (and "close" packages) : why gcc cannot find lib fl?


Recently I have installed Flex, Bison, m4 and libfl packages on my Ubuntu.

I used versions flex_2.5.35-10ubuntu3_i386.deb, libfl-dev_2.5.35-10ubuntu3_i386.deb, flex-doc_2.6.0-11_all.deb, m4_1.4.16-2ubuntu1_i386.deb.

I installed every dependency that flex needed, and flex-doc as an "extra" that I liked.

Now I supposedly would be able to make a
gcc myfile.l -lfl

But it gives me this error:

/usr/bin/ld: cannot find -lfl
collect2: ld returned 1 exit status

Using Synaptic I checked that the libfl package has these files installed, among others:

/usr/lib/i386-linux-gnu/libfl.a
/usr/lib/i386-linux-gnu/libfl.so
/usr/lib/i386-linux-gnu/libfl_pic.a

And they are there, of course. But gcc should already know how to look and find these files, right? What I should do (or should have done) to make it work?

Shouldn't it work without any extra steps after installing all these packages?
 
Old 07-27-2016, 07:41 PM   #2
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Linux From Scratch, Slackware64, Partedmagic
Posts: 2,964

Rep: Reputation: 798Reputation: 798Reputation: 798Reputation: 798Reputation: 798Reputation: 798Reputation: 798
/usr/lib/i386-linux-gnu/ is not a standard install folder, you will need to add this folder to /etc/ld.so.conf and then run
Code:
sudo ldconfig
This tells the system where to look for librarys
 
Old 07-27-2016, 07:44 PM   #3
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,257

Original Poster
Rep: Reputation: 44
I did not choose that path. I simply installed the package as they are, downloaded from Ubuntu official website.

Let me try what you said...
 
Old 07-27-2016, 07:54 PM   #4
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,257

Original Poster
Rep: Reputation: 44
My /etc/ld.so.conf is just one line: include /etc/ld.so.conf.d/*.conf . Should I create another file with a meaninful name? There is a few of them there. In one of them there are two paths and a comment...

Last edited by dedec0; 07-27-2016 at 08:11 PM.
 
Old 07-27-2016, 08:03 PM   #5
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,257

Original Poster
Rep: Reputation: 44
Thumbs down

The files I have inside that folder are:

GL.conf -> /etc/alternatives/gl_conf
i486-linux-gnu.conf
libasound2.conf
libc.conf

I edited the i486* file to be:
Code:
# Multiarch support
/lib/i486-linux-gnu
/usr/lib/i486-linux-gnu
# for gcc working with flex (libfl)
/usr/lib/i386-linux-gnu
But now I am into this error:

Code:
sudo -s
# ldconfig
/sbin/ldconfig.real: /usr/lib/libtotem-plparser.so.12 is not a symbolic link
What should I do? And why this configuration was not done by the packages I installed?
 
Old 07-27-2016, 08:09 PM   #6
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Linux From Scratch, Slackware64, Partedmagic
Posts: 2,964

Rep: Reputation: 798Reputation: 798Reputation: 798Reputation: 798Reputation: 798Reputation: 798Reputation: 798
some tome ld config will spit out an error and these can usually be ignored, try running your make commands and see if all is ok, you may want to check the file ldcomfig is talking ajout as it looks like a broken link.
before changing system files always back them up first.
 
Old 07-27-2016, 08:22 PM   #7
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,257

Original Poster
Rep: Reputation: 44
I copied that file, indeed. Thank you for noting it. : )

All the libtotem files I have, ls -l:

Code:
#  # Note: I edited the output to have only some details here, easier to read
#  ls -l /usr/lib/libtotem-plparser*
   0   32 2016 /usr/lib/libtotem-plparser-mini.so.17 -> libtotem-plparser-mini.so.17.0.0
 20K  18K 2010 /usr/lib/libtotem-plparser-mini.so.17.0.0
 88K  87K 2016 /usr/lib/libtotem-plparser.so.12
 88K  87K 2016 /usr/lib/libtotem-plparser.so.12.2.5
   0   27 2016 /usr/lib/libtotem-plparser.so.17 -> libtotem-plparser.so.17.0.0
104K 103K 2010 /usr/lib/libtotem-plparser.so.17.0.0
The two so.12* files have the same MD5 sum and are not links. The warning ldconfig gave may not be important, but gcc does not work yet.

Last edited by dedec0; 07-27-2016 at 08:28 PM.
 
Old 07-27-2016, 08:37 PM   #8
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,257

Original Poster
Rep: Reputation: 44
Arrow

This works:

Code:
$  gcc -Wall  -L/usr/lib/i386-linux-gnu  lex.yy.c -lfl
fb1-1.l:18: warning: return type of ‘main’ is not ‘int’
lex.yy.c:1086: warning: ‘yyunput’ defined but not used
lex.yy.c:1127: warning: ‘input’ defined but not used
This narrows the problem a bit. Now I want to make ldconfig/ld/gcc work with that path...

Last edited by dedec0; 07-27-2016 at 08:45 PM.
 
Old 07-27-2016, 08:44 PM   #9
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,257

Original Poster
Rep: Reputation: 44
Arrow

Another try that do not work:

Code:
$ echo $LD_LIBRARY_PATH 
 /media/.../.../.../lib:/media/.../.../.../lib:/usr/lib/i386-linux-gnu/
$ export LD_LIBRARY_PATH
$ gcc lex.yy.c -lfl
 fb1-1.l:18: warning: return type of ‘main’ is not ‘int’
 lex.yy.c:1086: warning: ‘yyunput’ defined but not used
 lex.yy.c:1127: warning: ‘input’ defined but not used
 /usr/bin/ld: cannot find -lfl
$
 
Old 07-28-2016, 03:53 AM   #10
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Linux From Scratch, Slackware64, Partedmagic
Posts: 2,964

Rep: Reputation: 798Reputation: 798Reputation: 798Reputation: 798Reputation: 798Reputation: 798Reputation: 798
Usually not a good idea to reset LD_LIBRARY_PATH as it can cause strange problems.
The unused variable warnings can be ignored, the return type from main should return an exit code really.

The use of -L... to tell gcc where to look for libs in a non standard directory is normal as gcc only looks in the standard places, which is why pkg-config is used to give gcc etc the various library and c flags it needs, adjusting ld.so.config will not help gcc it is used when running the application, sorry I think we was talking at cross purposes a bit, you will have to use the -L option to your gcc file.
 
1 members found this post helpful.
Old 07-28-2016, 04:10 AM   #11
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 16,981

Rep: Reputation: 5734Reputation: 5734Reputation: 5734Reputation: 5734Reputation: 5734Reputation: 5734Reputation: 5734Reputation: 5734Reputation: 5734Reputation: 5734Reputation: 5734
man ldconfig:
Code:
ldconfig  creates  the  necessary  links  and cache to the most recent shared libraries found in the directories specified on the command line, in the file /etc/ld.so.conf, and in the
       trusted directories (/lib and /usr/lib).  The cache is used by the run-time linker, ld.so or ld-linux.so.  ldconfig checks the header and filenames of the libraries it encounters when
       determining which versions should have their links updated.
but gcc -l lib is doing something like linking, but that is not a run-time linking. To find lib you need to specify -L<dir>
 
1 members found this post helpful.
Old 07-28-2016, 06:45 PM   #12
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,257

Original Poster
Rep: Reputation: 44
In my bashrc I add a few directories to LD_LIBRARY_PATH. I do not remove anything that it has before. What I posted here was different than what I had done, but maintaining the idea.

Although I posted them here, I was not minding those warnings. They are easy to solve, but do not have much importance, as said.

Is it good if I move (or copy) those libraries to /usr/lib (outside any subfolder), so gcc will compile like it does with -lm for the math library?

I was also thinking about adding this -L option to my gcc alias (which has -Wall -ggdb in its arguments). Passing it when I do not need it does not change anything, right?

Thank you all for your answers. They helped me to make better tries and thoughts. I did not imagine that this question would involve so many details, and still do not have a better solution.
 
Old 07-28-2016, 06:51 PM   #13
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,257

Original Poster
Rep: Reputation: 44
Since we separated, without noticing, our thoughts in the first posts, it may be useful to say what I am doing with Flex.

I am beginning to read a book about Flex and Bison (John Levine's), and in this book they use it as I tried to do, with apparently normal steps that make sense. I also have a couple of problems to solve with flex and bison after I learn more about them.
 
Old 08-02-2016, 10:22 AM   #14
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,257

Original Poster
Rep: Reputation: 44
Arrow Chosen solution

I decided to "solve" this problem by "installing" the library files inside the folder in /usr/lib instead. I created symbolic links with their names in this folder. Four links: libfl.a, libfl_pic.a, libfl.so, libl.a .

I did not simply move them outside i386-linux-gnu folder because this would break the normal state of installed packages that debianish systems have.

I am not marking this thread as solved because I think my solution is not the best possible that exists since I am manually changing things that should simply work after installed - as I can understand it.

Comments are welcome!
 
Old 08-03-2016, 10:24 AM   #15
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 16,981

Rep: Reputation: 5734Reputation: 5734Reputation: 5734Reputation: 5734Reputation: 5734Reputation: 5734Reputation: 5734Reputation: 5734Reputation: 5734Reputation: 5734Reputation: 5734
LD_LIBRARY_PATH is also a runtime thing, that is evaluated when you start your app, not when you make/build it.
During build you must use -L<path> -l<lib> in general, the only exception is the so called system directory where the default/system libraries stored. This is /usr/lib (in general) and that's why copying/linking libs into this directory solved your issue.
Also you can specify another system dir to g++, but I think that is out of scope here.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
"bad interpreter : no such file or directory" when configure "flex" acer_peri Linux - Software 10 11-10-2010 01:19 AM
C preprocessor "/lib/cpp" fails sanity check, cannot find stdio.h ??? zxLinux Linux - Software 7 03-10-2009 12:39 PM
"NIM thread blocked" & "Deadman Switch (DMS) close to trigger" errors sosborne Linux - Networking 1 06-28-2006 02:07 PM
Compromised? Files "/usr/lib.hwm", "/usr/lib.pwd", "/usr/lib.pwi" Klaus Pforte Linux - Security 4 09-28-2004 11:33 PM
Where can I find the "make" & "cc" packages?? sayeed_ather Mandriva 2 04-28-2004 02:02 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:22 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