linking with g++ instead of gcc

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Guys, when I link with g++ instead of gcc printf does not work.  I'm quessing I need to supply the gcc standard library but I have no joy finding any specifics.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

By default there is a link with "-lc" (so libc.a) whereas for C++ it needs to be the C++ standard lib. I forget what it's called (which is why StackOverflow was invented) but you need -lstdc++ or whatever it is to force it into the link. Actually probably -Wl,-l....etc

 

BTW you are only about the 10 gazillionth person reinventing this wheel so any question you could possibly ask about this HAS already been asked on StackOverflow.