Been a while...

General FreeBASIC programming questions.
Zamaster
Posts: 1024
Joined: Jun 20, 2005 21:40
Contact:

Been a while...

Postby Zamaster » Dec 06, 2018 8:10

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!
St_W
Posts: 1489
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: Been a while...

Postby St_W » Dec 06, 2018 12:01

Are you linking the C++ runtime? If not then do so e.g. using:
fbc -lstdc++
Zamaster
Posts: 1024
Joined: Jun 20, 2005 21:40
Contact:

Re: Been a while...

Postby Zamaster » Dec 08, 2018 0:24

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.
Zamaster
Posts: 1024
Joined: Jun 20, 2005 21:40
Contact:

Re: Been a while...

Postby Zamaster » Dec 08, 2018 7:51

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.
St_W
Posts: 1489
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: Been a while...

Postby St_W » Dec 08, 2018 18:57

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.

Return to “General”

Who is online

Users browsing this forum: Google [Bot] and 8 guests