TuononenP / llvm4eclipsecdt

LLVM toolchain support for Eclipse CDT. Now deprecated since it is build-in to Eclipse CDT via installation option. LLVM is a modular toolchain architecture that is used more and more in all kinds of computing platforms for it's certain benefits.
8 stars 0 forks source link

Linker can't find stdc++ library #15

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a C++ project.
2. Build the project.

Error message that appears on console when building a project using LLVM with 
Clang on Windows:
clang++ -O0 -emit-llvm -g3 -Wall -c -fmessage-length=0 -o src\test5.bc 
..\src\test5.cpp
llvm-ld -lstdc++ -native -o= test5 src\test5.bc
llvm-ld: error: Cannot find library 'stdc++'
Build error occurred, build is stopped

This is a known problem. Because the developer can't be sure where the C++ 
standard library headers are located on Linux or Windows (could be defined with 
linker flags), the task to specify the stdc++ library header file location is 
left to end-user. The place where the library path should be added is to 
navigate to Window -> Preferences -> LLVM and add the correct library path 
which is then passed to the llvm linker tool.

Original issue reported on code.google.com by petri.tuononen@gmail.com on 12 Jan 2011 at 12:02

GoogleCodeExporter commented 9 years ago
Because this is a so called known issue I will change the status as 'Done'.

Original comment by petri.tuononen@gmail.com on 4 Feb 2011 at 3:33

GoogleCodeExporter commented 9 years ago
Reopened. There must be a way to overcome this.

In my Ubuntu installation the stdc++ library is found from:
/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5/

Original comment by petri.tuononen@gmail.com on 2 May 2011 at 7:54

GoogleCodeExporter commented 9 years ago
Now the library libstdc++ and it's path are automatically added in Linux.

Original comment by petri.tuononen@gmail.com on 17 May 2011 at 11:57

GoogleCodeExporter commented 9 years ago
When I select libstdc++.dylib (in 
/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin10/4.2.1/ on OS X) and click open, 
nothing happens.
The path does not get added to the box...

Original comment by gaeremyn...@gmail.com on 29 May 2011 at 3:58

GoogleCodeExporter commented 9 years ago
Thanks for the comment.

Unfortunately I don't have access to Mac computers so I cannot test with the 
right platform. Considering that I was able to successfully add libstdc++.dylib 
named file in Linux and Windows it seems quite strange it doesn't work for Mac.

I am afraid there's nothing else to be done than wait that someone with a Mac 
would run debug. There might have been an error log on console when you 
encountered that bug which might give some clues. If you can post the error log 
on console here I might be able to try and fix it. 

Original comment by petri.tuononen@gmail.com on 30 May 2011 at 6:32

GoogleCodeExporter commented 9 years ago
I have provided an alternative solution for now.Not sure if it works though.

The new 1.1.6 version should find the lib path and stdc++ lib automatically in 
Mac and add them to Preferences and to every LLVM projects' build configuration 
(linker). Only flaw is that it adds them to C projects as well.

Original comment by petri.tuononen@gmail.com on 30 May 2011 at 6:57

GoogleCodeExporter commented 9 years ago
I can see the stdc++ lib being added automatically to the LLVM settings on a 
Mac.

However still getting:
llvm-ld: error: Cannot find library 'stdc++'
Build error occurred, build is stopped

Original comment by Tristan....@gmail.com on 8 Jun 2011 at 4:48

GoogleCodeExporter commented 9 years ago
[Mac]

Not quite sure what I'm doing but...

I've managed to add /usr/lib/libstdc++-static.a as a library, and it seems ok, 
however because eclipse continues to automagically add stdc++, I always get the 
failure:

llvm-ld -v -lstdc++ -native -o Tutorial3 src/MegaLottery.bc src/Main.bc 
src/LotteryFactory.bc src/Lottery.bc -l/usr/lib/libstdc++-static.a -lstdc++
llvm-ld: error: Cannot find library 'stdc++'
Build error occurred, build is stopped

because `-lstdc++` keeps getting included

So I removed it from Miscalenous in C/C++ Build -> Settings -> LLVM C++ Linker 
-> Linker Flags , but it still just appears as a Library and seems to ruin the 
day.

See console output below. I think my code appears to link, is it just the 
stdc++ that keeps getting in the way?:

**** Internal Builder is used for build               ****
clang++ -O0 -emit-llvm -g3 -Wall -c -fmessage-length=0 -o src/Lottery.bc 
../src/Lottery.cpp
clang++ -O0 -emit-llvm -g3 -Wall -c -fmessage-length=0 -o src/Main.bc 
../src/Main.cpp
clang++ -O0 -emit-llvm -g3 -Wall -c -fmessage-length=0 -o src/MegaLottery.bc 
../src/MegaLottery.cpp
clang++ -O0 -emit-llvm -g3 -Wall -c -fmessage-length=0 -o src/LotteryFactory.bc 
../src/LotteryFactory.cpp
llvm-ld -v -native -o Tutorial3 src/MegaLottery.bc src/Main.bc 
src/LotteryFactory.bc src/Lottery.bc -l/usr/lib/libstdc++-static.a -lstdc++
  Linking bitcode file 'src/MegaLottery.bc'
  Linked in file 'src/MegaLottery.bc'
  Linking bitcode file 'src/Main.bc'
  Linked in file 'src/Main.bc'
  Linking bitcode file 'src/LotteryFactory.bc'
  Linked in file 'src/LotteryFactory.bc'
  Linking bitcode file 'src/Lottery.bc'
  Linked in file 'src/Lottery.bc'
llvm-ld: error: Cannot find library 'stdc++'
Build error occurred, build is stopped
Time consumed: 1359  ms.  

Original comment by Tristan....@gmail.com on 8 Jun 2011 at 5:03

GoogleCodeExporter commented 9 years ago
I also tried to make a symlink named stdc++ in my project directory ponting to 
/usr/lib/libstdc++-static.a, it didn't like that either, same "cannot find 
library" error.

Original comment by Tristan....@gmail.com on 8 Jun 2011 at 5:08

GoogleCodeExporter commented 9 years ago
Because I don't have a Mac and therefore cannot test I am sorry you early 
adopters get these problems.

That said I really appreciate testers feedback because that really speeds up 
Mac support.

I removed the call to add std++ lib automatically for Mac OS X so try to update 
and add lib path and lib manually and try if that works.

It helps to comment here which lib and path combinations work so I can figure 
out the automatic stdc++ lib finding algorithm.

Original comment by petri.tuononen@gmail.com on 8 Jun 2011 at 5:24

GoogleCodeExporter commented 9 years ago
After update, it was necessary to still remove the stdc++ library from the 
following:

remove stdc++ from  Eclipse->Preferences->LLVM
remove stdc++ from Project->Preferences->C/C++ Build->Settings->Tool 
Settings->LLVM C++ linker -> Libraries
remove -lstdc++ from Project->Preferences->C/C++ Build->Settings->Tool 
Settings->LLVM C++ linker -> Miscaellaneous -> LInker flags

library that did seem to work is :   /usr/lib/libstdc++-static.a

after that was complete, I think it works, at least I moved on to another error 
and now getting Unknown pseudo-op errors instead...

Generating Native Executable With:
'/usr/bin/gcc' '-fno-strict-aliasing' '-O3' '-o' 'Tutorial3' 'Tutorial3.s' 
'-l/usr/lib/libstdc++-static.a' 
Tutorial3.s:44:Unknown pseudo-op: .cfi_startproc
Tutorial3.s:50:Unknown pseudo-op: .cfi_def_cfa_offset
Tutorial3.s:50:Rest of line ignored. 1st junk character valued 49 (1).
Tutorial3.s:59:Unknown pseudo-op: .cfi_endproc
Tutorial3.s:65:Unknown pseudo-op: .cfi_startproc
Tutorial3.s:77:Unknown pseudo-op: .cfi_endproc
Tutorial3.s:83:Unknown pseudo-op: .cfi_startproc
Tutorial3.s:84:Unknown pseudo-op: .cfi_personality
Tutorial3.s:84:Rest of line ignored. 1st junk character valued 49 (1).
Tutorial3.s:86:Unknown pseudo-op: .cfi_lsda
Tutorial3.s:86:Rest of line ignored. 1st junk character valued 49 (1).
Tutorial3.s:92:Unknown pseudo-op: .cfi_def_cfa_offset
Tutorial3.s:92:Rest of line ignored. 1st junk character valued 49 (1).
Tutorial3.s:95:Unknown pseudo-op: .cfi_def_cfa_offset
Tutorial3.s:95:Rest of line ignored. 1st junk character valued 50 (2).
Tutorial3.s:98:Unknown pseudo-op: .cfi_def_cfa_offset
Tutorial3.s:98:Rest of line ignored. 1st junk character valued 51 (3).
Tutorial3.s:100:Unknown pseudo-op: .cfi_offset
Tutorial3.s:100:Rest of line ignored. 1st junk character valued 37 (%).
Tutorial3.s:102:Unknown pseudo-op: .cfi_offset
Tutorial3.s:102:Rest of line ignored. 1st junk character valued 37 (%).
Tutorial3.s:191:Unknown pseudo-op: .cfi_endproc
Tutorial3.s:263:Unknown pseudo-op: .cfi_startproc
Tutorial3.s:264:Unknown pseudo-op: .cfi_personality
Tutorial3.s:264:Rest of line ignored. 1st junk character valued 49 (1).
Tutorial3.s:266:Unknown pseudo-op: .cfi_lsda
Tutorial3.s:266:Rest of line ignored. 1st junk character valued 49 (1).
Tutorial3.s:273:Unknown pseudo-op: .cfi_def_cfa_offset
Tutorial3.s:273:Rest of line ignored. 1st junk character valued 49 (1).
Tutorial3.s:276:Unknown pseudo-op: .cfi_def_cfa_offset
Tutorial3.s:276:Rest of line ignored. 1st junk character valued 50 (2).
Tutorial3.s:279:Unknown pseudo-op: .cfi_def_cfa_offset
Tutorial3.s:279:Rest of line ignored. 1st junk character valued 51 (3).
Tutorial3.s:282:Unknown pseudo-op: .cfi_def_cfa_offset
Tutorial3.s:282:Rest of line ignored. 1st junk character valued 54 (6).
Tutorial3.s:284:Unknown pseudo-op: .cfi_offset
Tutorial3.s:284:Rest of line ignored. 1st junk character valued 37 (%).
Tutorial3.s:286:Unknown pseudo-op: .cfi_offset
Tutorial3.s:286:Rest of line ignored. 1st junk character valued 37 (%).
Tutorial3.s:288:Unknown pseudo-op: .cfi_offset
Tutorial3.s:288:Rest of line ignored. 1st junk character valued 37 (%).
Tutorial3.s:432:Unknown pseudo-op: .cfi_endproc
Tutorial3.s:502:Unknown pseudo-op: .cfi_startproc
Tutorial3.s:506:Unknown pseudo-op: .cfi_def_cfa_offset
Tutorial3.s:506:Rest of line ignored. 1st junk character valued 49 (1).
Tutorial3.s:508:Unknown pseudo-op: .cfi_offset
Tutorial3.s:508:Rest of line ignored. 1st junk character valued 37 (%).
Tutorial3.s:519:Unknown pseudo-op: .cfi_endproc
Tutorial3.s:526:Unknown pseudo-op: .cfi_startproc
Tutorial3.s:532:Unknown pseudo-op: .cfi_def_cfa_offset
Tutorial3.s:532:Rest of line ignored. 1st junk character valued 49 (1).
Tutorial3.s:541:Unknown pseudo-op: .cfi_endproc
Tutorial3.s:547:Unknown pseudo-op: .cfi_startproc
Tutorial3.s:559:Unknown pseudo-op: .cfi_endproc
Tutorial3.s:565:Unknown pseudo-op: .cfi_startproc
Tutorial3.s:571:Unknown pseudo-op: .cfi_def_cfa_offset
Tutorial3.s:571:Rest of line ignored. 1st junk character valued 51 (3).
Tutorial3.s:616:Unknown pseudo-op: .cfi_endproc
Tutorial3.s:622:Unknown pseudo-op: .cfi_startproc
Tutorial3.s:628:Unknown pseudo-op: .cfi_def_cfa_offset
Tutorial3.s:628:Rest of line ignored. 1st junk character valued 49 (1).
Tutorial3.s:637:Unknown pseudo-op: .cfi_endproc
Tutorial3.s:643:Unknown pseudo-op: .cfi_startproc
Tutorial3.s:655:Unknown pseudo-op: .cfi_endproc
Tutorial3.s:661:Unknown pseudo-op: .cfi_startproc
Tutorial3.s:662:Unknown pseudo-op: .cfi_personality
Tutorial3.s:662:Rest of line ignored. 1st junk character valued 49 (1).
Tutorial3.s:664:Unknown pseudo-op: .cfi_lsda
Tutorial3.s:664:Rest of line ignored. 1st junk character valued 49 (1).
Tutorial3.s:670:Unknown pseudo-op: .cfi_def_cfa_offset
Tutorial3.s:670:Rest of line ignored. 1st junk character valued 49 (1).
Tutorial3.s:673:Unknown pseudo-op: .cfi_def_cfa_offset
Tutorial3.s:673:Rest of line ignored. 1st junk character valued 50 (2).
Tutorial3.s:676:Unknown pseudo-op: .cfi_def_cfa_offset
Tutorial3.s:676:Rest of line ignored. 1st junk character valued 51 (3).
Tutorial3.s:679:Unknown pseudo-op: .cfi_def_cfa_offset
Tutorial3.s:679:Rest of line ignored. 1st junk character valued 52 (4).
Tutorial3.s:682:Unknown pseudo-op: .cfi_def_cfa_offset
Tutorial3.s:682:Rest of line ignored. 1st junk character valued 52 (4).
Tutorial3.s:685:Unknown pseudo-op: .cfi_def_cfa_offset
Tutorial3.s:685:Rest of line ignored. 1st junk character valued 53 (5).
Tutorial3.s:688:Unknown pseudo-op: .cfi_def_cfa_offset
Tutorial3.s:688:Rest of line ignored. 1st junk character valued 52 (4).
Tutorial3.s:690:Unknown pseudo-op: .cfi_offset
Tutorial3.s:690:Rest of line ignored. 1st junk character valued 37 (%).
Tutorial3.s:692:Unknown pseudo-op: .cfi_offset
Tutorial3.s:692:Rest of line ignored. 1st junk character valued 37 (%).
Tutorial3.s:694:Unknown pseudo-op: .cfi_offset
Tutorial3.s:694:Rest of line ignored. 1st junk character valued 37 (%).
Tutorial3.s:696:Unknown pseudo-op: .cfi_offset
Tutorial3.s:696:Rest of line ignored. 1st junk character valued 37 (%).
Tutorial3.s:698:Unknown pseudo-op: .cfi_offset
Tutorial3.s:698:Rest of line ignored. 1st junk character valued 37 (%).
Tutorial3.s:700:Unknown pseudo-op: .cfi_offset
Tutorial3.s:700:Rest of line ignored. 1st junk character valued 37 (%).
Tutorial3.s:873:Unknown pseudo-op: .cfi_endproc

Original comment by Tristan....@gmail.com on 8 Jun 2011 at 5:47

GoogleCodeExporter commented 9 years ago
I will analyze Comment 8 a bit.

You added -l/usr/lib/libstdc++-static.a -l states library and -L library path. 
You might want to try adding /usr/lib/ as a library search path and 
libstdc++-static.a as a library in LLVM Preference page (Window -> Preferences 
-> LLVM).

-lstdc++ gets included actually twice. This is because the default value for 
linker is that and because it is set automatically too.

I have now removed default value for linker and keep adding stdc++ lib 
automatically only for Win and Linux. Mac OS is now free of any preset linker 
flags.

PS: I don't know what those Unknown pseudo-op errors are. Not related to 
plug-in directly.

Original comment by petri.tuononen@gmail.com on 8 Jun 2011 at 6:12

GoogleCodeExporter commented 9 years ago
I've been able to replicate the Unknown pseudo-op error outside of Eclipse. 
Therefore I think this issue ( can't find std++ library ) is resolved for Mac. 
Linking manually to `/usr/lib/libstdc++-static.a` appears to work.

Original comment by Tristan....@gmail.com on 9 Jun 2011 at 2:32

GoogleCodeExporter commented 9 years ago
Ok, nice to hear that. I assume you were able to build and run projects 
succesfully on Mac?

Original comment by petri.tuononen@gmail.com on 9 Jun 2011 at 3:14

GoogleCodeExporter commented 9 years ago
Not yet, but my errors seem unrelated to llvm4eclipsecdt at this point.

Original comment by Tristan....@gmail.com on 9 Jun 2011 at 3:31

GoogleCodeExporter commented 9 years ago
I'm having the same error as Tristan, and this is extremely frustrating.

**** Internal Builder is used for build               ****
clang++ -std=c++0x -stdlib=libstdc++ -O0 -emit-llvm -g3 -Wall -c 
-fmessage-length=0 -o src/ClangTest.bc ../src/ClangTest.cpp
llvm-ld -v -L/usr/lib -native -o ClangTest src/ClangTest.bc -lstdc++
  Linking bitcode file 'src/ClangTest.bc'
  Linked in file 'src/ClangTest.bc'
Generating Bitcode To ClangTest.bc
Generating Assembly With: 
'/opt/local/libexec/llvm-3.1/bin/llc' '-x86-asm-syntax=att' '-o' 'ClangTest.s' 
'ClangTest.bc' 
Generating Native Executable With:
'/usr/bin/gcc' '-fno-strict-aliasing' '-O3' '-o' 'ClangTest' 'ClangTest.s' 
'-L/usr/lib' '-lstdc++' 
ClangTest.s:39:Unknown pseudo-op: .cfi_startproc
ClangTest.s:46:Unknown pseudo-op: .cfi_def_cfa_offset
ClangTest.s:46:Rest of line ignored. 1st junk character valued 49 (1).
ClangTest.s:59:Unknown pseudo-op: .cfi_endproc
ClangTest.s:64:Unknown pseudo-op: .cfi_startproc
ClangTest.s:68:Unknown pseudo-op: .cfi_def_cfa_offset
ClangTest.s:68:Rest of line ignored. 1st junk character valued 49 (1).
ClangTest.s:70:Unknown pseudo-op: .cfi_offset
ClangTest.s:70:Rest of line ignored. 1st junk character valued 37 (%).
ClangTest.s:80:Unknown pseudo-op: .cfi_endproc
llvm-ld: 
Build error occurred, build is stopped
Time consumed: 1011  ms.  

Original comment by arjungme...@gmail.com on 26 Mar 2012 at 8:22

GoogleCodeExporter commented 9 years ago
Hi,

The more details you can give the more detailed solution I can provide.
Especially what OS are you using? It is really important factor in this
issue, because the library locations differ etc. It could also narrow down
this issue.

This issue is on my top priority list for sure, but please note that my
time I can provide for this great project has become very limited.
Therefore I cannot promise any specific date this issue will be fixed,
unfortunately.

BR

Original comment by petri.tuononen@gmail.com on 28 Mar 2012 at 5:25

GoogleCodeExporter commented 9 years ago
The plug-in is built in a way that library stdc++ is defined for the linker as 
default library value. That library is needed to build C++ projects. The 
problem is usually if the path to the libstdc++ file is not defined or it 
cannot be found.

Original comment by petri.tuononen@gmail.com on 28 Mar 2012 at 5:31

GoogleCodeExporter commented 9 years ago
Hi. I am a linux user, but I also have a windows installation in my /windows 
folder. llvm4eclipsecdt automaticly finds stdc++ library in a very strange 
place /windows/QtSDK/mingw/lib/gcc/mingw32/4.4.0/. This is my windows Qt 
installation. And linux linker fails to process libstdc++ in this folder. 
Please, fix search algorythm or add an opportunity to turn it off.

Original comment by telpe.ni...@gmail.com on 10 Apr 2013 at 10:12

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
UPD There is a file /windows/QtSDK/mingw/lib/gcc/mingw32/4.4.0/libstdc++.a on 
my filesystem.

Original comment by telpe.ni...@gmail.com on 10 Apr 2013 at 10:30