Hey all... great to be back (for Lachie's last hurrah competition)...!
Quick Q here: I have a C++ library I want to link into an FB program, and when I try to compile I get hit with linker errors like "undefined reference to `__std_terminate'", which I think means it can't find the c++ runtime. I'm using the C emitter FYI, but backend doesn't seem to make a difference.
Anybody know how to get these symbols into my binary? Thanks!
Been a while...
Re: Been a while...
Are you linking the C++ runtime? If not then do so e.g. using:
fbc -lstdc++
fbc -lstdc++
Re: Been a while...
I wasn't! I get "invalid command line option" when I try this (i.e. directly adding -lstdc++ to my compiler invocation). Is this wrong/dumb/both?
Last edited by Zamaster on Dec 08, 2018 8:01, edited 1 time in total.
Re: Been a while...
Yeah so not being an bright and just specifying "-l stdc++" doesn't get me anywhere, it compiles but with the usual undefined reference errors.
Re: Been a while...
Ah right, sorry, forgot that fbc wants a space character between -l and the library name (in contrast to gcc, which doesn't).
As linking stdc++ doesn't seem to fix the issue for you some more hints: Note that C++ isn't binary compatible among different compiler versions or compilers. So ideally make sure you're compiling your C++ library using the same toolchain as you're compiling your FreeBasic application with. If that isn't possible you have to link the correct C++ runtime library at least. But again, in general avoid mixing different compiler versions (or even worse: different compilers) whenever possible.
As linking stdc++ doesn't seem to fix the issue for you some more hints: Note that C++ isn't binary compatible among different compiler versions or compilers. So ideally make sure you're compiling your C++ library using the same toolchain as you're compiling your FreeBasic application with. If that isn't possible you have to link the correct C++ runtime library at least. But again, in general avoid mixing different compiler versions (or even worse: different compilers) whenever possible.
Who is online
Users browsing this forum: No registered users and 15 guests