0

I'm compiling my code using g++ -L/lib64 -I /git/src ... but I get

/usr/bin/ld: cannot find -lstdc++
/usr/bin/ld: cannot find -lm
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find -lc
/usr/bin/ld: cannot find -lgcc_s

I checked my /lib64/ and found that these libs are actually present

/usr/lib64/libstdc++.so.6 -> libstdc++.so.6.0.19
/usr/lib64/libm.so -> ../../lib64/libm.so.6
/usr/lib64/libgcc_s.so.1 -> libgcc_s-4.8.5-20150702.so.1
/usr/lib64/libc.so.6 -> libc-2.17.so

When I try ld -lc --verbose this too fails. All the libs are present in /lib64 and the path is included still g++ fails to locate them. Any Idea what is going on ?

Raj
  • 401
  • 6
  • 20
  • You're missing some `.so` symlinks. Without identifying your Linux distribution, no further help can be given, but you need to install the appropriate development package for your Linux distribution, that contain the required symlinks. – Sam Varshavchik Oct 02 '18 at 00:03
  • `CentOS Linux release 7.4.1708 (Core)` I have this in `/etc/redhat-releases.` I also changed `/usr/lib64/libstdc++.so.6 -> libstdc++.so.6.0.19 ` to `/usr/lib64/libstdc++.so -> libstdc++.so.6.0.19.` the `ld -lstdc++ --verbose` worked. but g++ still reported the issue listing this pkg along with others – Raj Oct 02 '18 at 00:11
  • What development pkg should I install/check ? – Raj Oct 02 '18 at 00:15
  • Start with libstdc++-devel, glibc-devel, and gcc-c++ – Sam Varshavchik Oct 02 '18 at 00:24
  • I tried yum install pkg name and got this ` Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile Package gcc-c++-4.8.5-28.el7_5.1.x86_64 already installed and latest version Nothing to do` . I also did [https://access.redhat.com/discussions/1262603#comment-867063] groupinstall Development tools does show up now. I still have same issue – Raj Oct 02 '18 at 00:32
  • @Raj Have you tried creating symlinks to the libraries you wish to link? I ran into this problem a few months back. I was left with two options, one being to just build the libraries from source and link that way OR to create symlinks and it would work without a problem. – GKE Oct 02 '18 at 01:44
  • One more thing, assigning [LD_LIBRARY_PATH](https://stackoverflow.com/questions/4250624/ld-library-path-vs-library-path) may also resolve your issue if you haven't already done so. – GKE Oct 02 '18 at 01:47
  • @Raj What does `rpm -qVa` show? This command will attempt to verify that the required files are actually installed. – Florian Weimer Oct 02 '18 at 05:47
  • @GKE I created all the missing symlinks. Still the same issue. Florian it gave me a bunch of missing files – Raj Oct 02 '18 at 17:58
  • There was an -Bstatic option with .a file instead .so file for dynamic loading. I removed -Bstatic option as I wanted to load .so file. This fixed the issue – Raj Oct 02 '18 at 19:00

0 Answers0